[PATCH 08/12] cmsfs: export extra file attributes via xattr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Josef 'Jeff' Sipek <jeffpc@xxxxxxxxxxxxxx>
---
 fs/cmsfs/xattr.c |   74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 74 insertions(+), 0 deletions(-)
 create mode 100644 fs/cmsfs/xattr.c

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 <linux/module.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/fs.h>
+
+#include <linux/errno.h>
+
+#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;
+}
-- 
1.5.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux