Subodh Nijsure wrote:I will double check, my tree is based off linux-rc2, may be I messed up things.diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.cAccording to 3.4-rc6,
index ad6e550..cec3ffab 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -292,6 +292,14 @@ static int ubifs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
mutex_unlock() is here.
ubifs_release_budget(c,&req);out_cancel:
insert_inode_hash(inode);
+
+ err = ubifs_init_security(dir, inode,&dentry->d_name);
+ if (err) {
+ ubifs_err("cannot initialize extended attribute, error %d",
+ err);
+ goto out_cancel;
+ }
+
d_instantiate(dentry, inode);
return 0;
mutex_unlock() is also here...
Same for the rest.
the above condition you referred to implies that caller passed in buffer that was too short, in that case we don't need to copy the data. Typical usage would be caller call listxattr with null and list size of zero, we return size of the buffer etc.diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.cIf (list&& total_len> list_size), the caller will see total_len
index 85b2722..49c426a 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -568,3 +600,91 @@ out_free:
kfree(xent);
return err;
}
+
+size_t
+ubifs_security_listxattr(struct dentry *d, char *list, size_t list_size,
+ const char *name, size_t name_len, int flags)
+{
+ const int prefix_len = XATTR_SECURITY_PREFIX_LEN;
+ const size_t total_len = prefix_len + name_len + 1;
+ if (list&& total_len<= list_size) {
+ memcpy(list, XATTR_SECURITY_PREFIX, prefix_len);
+ memcpy(list+prefix_len, name, name_len);
+ list[prefix_len + name_len] = '\0';
+ }
but no data is copied to list. Is it OK?
I will modify that.+ return total_len;Maybe nice to have kstrdup2(const char *str1, const char *str2, gfp_t flags).
+}
+static int ubifs_initxattrs(struct inode *inode,
+ const struct xattr *xattr_array, void *fs_info)
+{
+ const struct xattr *xattr;
+ char *name;
+ int err = 0;
+
+ for (xattr = xattr_array; xattr->name != NULL; xattr++) {
+ name = kmalloc(XATTR_SECURITY_PREFIX_LEN +
+ strlen(xattr->name) + 1, GFP_NOFS);
-Subodh+ if (!name) {
+ err = -ENOMEM;
+ break;
+ }
+ strcpy(name, XATTR_SECURITY_PREFIX);
+ strcpy(name + XATTR_SECURITY_PREFIX_LEN, xattr->name);
+ err = __ubifs_setxattr(inode, name, xattr->value,
+ xattr->value_len, 0);
+ kfree(name);
+ if (err< 0)
+ break;
+ }
+ return err;
+}