Setxattr does not work, operation is not supported

I am trying to set file attributes like this:

  • create file foo.txt with 0644 permissions
  • when i try setxattr for this like

    if (setxattr("foo.txt", "user.test", "test", 4, XATTR_CREATE) == -1)
        perror("");
    
          

I am getting an error because the operation is not supported

Is there anything to include? How to solve this problem?

+3


source to share


1 answer


Of setxattr

RETURN VALUE

   On success, zero is returned.  On failure, -1 is returned and errno is set
   appropriately.  
   ...  
   If extended attributes are not supported by the file system, or are disabled,
   errno is set to ENOTSUP.

      

So your filesystem does not support extended attributes (eg ext [234], cifs, btrfs do), or they are disabled during kernel build or mount time.



There is no separate switch for NFS to enable extended attributes in kernel configuration. From source fs/nfs/dir.c

it appears to be enabled when you enable support CONFIG_NFS_V3

or CONFIG_NFS_V4

. But NFS still depends on the underlying filesystem. So you have to enable extended attributes on the server side as well.

From man mount

Mount options for ext2
...
user_xattr | nouser_xattr
Support the "user". extended attributes (or not).

+5


source







All Articles