cmsfs: export extra file attributes via xattr Signed-off-by: Josef 'Jeff' Sipek diff --git a/fs/cmsfs/xattr.c b/fs/cmsfs/xattr.c new file mode 100644 index 0000000..df48aed --- /dev/null +++ b/fs/cmsfs/xattr.c @@ -0,0 +1,74 @@ +#include +#include +#include +#include + +#include + +#include "cmsfs.h" + +ssize_t cmsfs_getxattr(struct dentry *dentry, const char *name, void *value, + size_t size) +{ + char tmp[16]; + char *out = NULL; + + if (!strcmp("system.recfm", name)) { + switch (CMSFS_I(dentry->d_inode)->recfm) { + case RECFM_FIXED: + out = "fixed"; + break; + case RECFM_VAR: + out = "variable"; + break; + default: + out = "???"; + break; + } + } else if (!strcmp("system.lrecl", name)) { + snprintf(tmp, 16, "%d", CMSFS_I(dentry->d_inode)->lrecl); + out = tmp; + } else if (!strcmp("system.items", name)) { + snprintf(tmp, 16, "%d", CMSFS_I(dentry->d_inode)->items); + out = tmp; + } + + if (!out) + return -ENODATA; + + if (!value && !size) + return strlen(out); + + if (size < strlen(out)) + return -ERANGE; + + strcpy(value, out); + + return strlen(out); +} + +#define ATTRLIST "system.recfm\0system.lrecl\0system.items\0" + +ssize_t cmsfs_listxattr(struct dentry *dentry, char *list, size_t size) +{ + if (!list || !size) + return sizeof(ATTRLIST); + + if (size < sizeof(ATTRLIST)) + return -ERANGE; + + memcpy(list, ATTRLIST, sizeof(ATTRLIST)); + + return sizeof(ATTRLIST); +} + +int cmsfs_setxattr(struct dentry *dentry, const char *name, const void *value, + size_t size, int flags) +{ + return -EOPNOTSUPP; +} + +int cmsfs_removexattr(struct dentry *dentry, const char *name) +{ + return -EOPNOTSUPP; +}