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

Question:

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?

Asked By: user11924970

||

Answers:

https://jp-andre.pagesperso-orange.fr/extend-attr.html

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.

Answered By: Peter Wood
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.