Why must a 'user.' be prepended to the name when setting a file's xattr with os.setxattr()?

m.a.d.cat :

I am saving data that I guess could be deemed metadata on a JSON serialized file:

os.setxattr('/var/tmp/test.json', 'user.keyname', b'value')

and I can get the bytes value back via:

os.getxattr('/var/tmp/test.json', 'user.keyname')

The only way I can get this to work is by putting user. in front of the key/name that I want to use. Why is this?

Peter Wood :

https://www.tuxera.com/community/ntfs-3g-advanced/extended-attributes/

On Linux, specifically, four categories of extended attributes have been defined :

  • trusted: to record properties which should only be accessed by the kernel,
  • security: to record security properties of a file,
  • system: to record other system related properties on which the file owner has some control,
  • user: to record properties defined by applications.

The names of the extended attributes must be prefixed by the name of the category and a dot, hence these categories are generally qualified as name spaces.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=379868&siteId=1