I am trying to set the file attributes as follows:
when I am trying to setxattr for this as
if (setxattr("foo.txt", "user.test", "test", 4, XATTR_CREATE) == -1)
    perror("");
I am getting the error as Operation not supported
Is there any thing to enable? How to resolve this?
From 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, either your file system doesn't support extended attributes (ext[234], cifs, btrfs do, for example) or they are disabled at the kernel build or at mount time.
For NFS there is no separate switch to enable extended attributes in the kernel config. From the source fs/nfs/dir.c, it seems to be enabled, when you enable support for CONFIG_NFS_V3 or CONFIG_NFS_V4. But NFS still depends on the underlying file system. So you must enable extended attributes on the server side as well.
From man mount 
Mount options for ext2
...
user_xattr|nouser_xattr
Support "user." extended attributes (or not).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With