[gpfsug-discuss] GPFS API Question - extended attributes

Marc A Kaplan makaplan at us.ibm.com
Fri Nov 20 17:39:04 GMT 2015


If you're using policy rules and the xattr() SQL function, then you should 
consider using the setXattr() SQL function, to set or change the value of 
any particular extended attributes.

Notice that the doc says: gpfs_igetattrs() subroutine: Retrieves extended 
file attributes in opaque format.
What it does is pickup all the extended attributes of a given file and 
return them in a "blob".  The structure of the blob is undocumented,
so you should not use it to set individual extended attributes.  The 
intended use is for backup and restore of a file's extended attributes,
and you get an ACL also as a bonus. The doc says:
"This subroutine is intended for use by a backup program to save all 
extended file attributes (ACLs, attributes, and so forth)."

If you are determined to use a C API to manipulate extended attributes,  I 
personally recommend that you first see and try if
the standard OS methods will work for you.  That means your code will work 
for any file system that can be mounted on you OS that supports extended 
attributes.  BUT, unfortunately I have found that some extended attribute 
names with special prefix values cannot be accessed with the standard 
Linux or AIX or Posix commands or APIs.   In that case you need to use the 
gpfs API, GPFS_FCNTL_SET_XATTR (see gpfs_fcntl.h) Which is indeed what 
setXattr() is using and what the mmchattr command ultimately uses.

Notice that setXattr() requires you pass the new value as an SQL string. 
So what if you need to store a numeric value as a "binary" value? 
Well first figure out how to represent the value as a hexadecimal constant 
and then use this notation:
  setXattr('user.whatever', X'0123456789ABCDEF')

In some common situations you can use the m4 processor to build or tear 
down binary and/or hexadecimal values and strings.
For some examples of how to do that add this to a test policy rules file:

debugfile(/tmp/m4xdeb)
dumpdef

And peek into the resulting m4xdeb file!






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gpfsug.org/pipermail/gpfsug-discuss_gpfsug.org/attachments/20151120/2a111046/attachment.htm>


More information about the gpfsug-discuss mailing list