]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: Remove all strlen in all xfs_attr_* functions for attr names.
authorAllison Henderson <allison.henderson@oracle.com>
Sat, 14 Mar 2020 02:59:48 +0000 (22:59 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Sat, 14 Mar 2020 02:59:48 +0000 (22:59 -0400)
Source kernel commit: d29f781c32b1d1366c8ac10be31dad1e1f39c336

This helps to pre-simplify the extra handling of the null terminator in
delayed operations which use memcpy rather than strlen.  Later
when we introduce parent pointers, attribute names will become binary,
so strlen will not work at all.  Removing uses of strlen now will
help reduce complexities later

Signed-off-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
db/attrset.c
libxfs/xfs_attr.c
libxfs/xfs_attr.h

index 8eecf46538effa621d67593fdf33218454126678..d96b78dc8660bc3852cd3f5cb75bf7a2cdaf5a41 100644 (file)
@@ -146,7 +146,7 @@ attr_set_f(
                goto out;
        }
 
-       if (libxfs_attr_set(ip, (unsigned char *)name,
+       if (libxfs_attr_set(ip, (unsigned char *)name, strlen(name),
                                (unsigned char *)value, valuelen, flags)) {
                dbprintf(_("failed to set attr %s on inode %llu\n"),
                        name, (unsigned long long)iocur_top->ino);
@@ -222,7 +222,7 @@ attr_remove_f(
                goto out;
        }
 
-       if (libxfs_attr_remove(ip, (unsigned char *)name, flags)) {
+       if (libxfs_attr_remove(ip, (unsigned char *)name, strlen(name), flags)){
                dbprintf(_("failed to remove attr %s from inode %llu\n"),
                        name, (unsigned long long)iocur_top->ino);
                goto out;
index 800dd2b2107620c6af7251503247ff19540f6655..5110bb4326117c3d90882288b9193e8eb985dd2d 100644 (file)
@@ -61,6 +61,7 @@ xfs_attr_args_init(
        struct xfs_da_args      *args,
        struct xfs_inode        *dp,
        const unsigned char     *name,
+       size_t                  namelen,
        int                     flags)
 {
 
@@ -73,7 +74,7 @@ xfs_attr_args_init(
        args->dp = dp;
        args->flags = flags;
        args->name = name;
-       args->namelen = strlen((const char *)name);
+       args->namelen = namelen;
        if (args->namelen >= MAXNAMELEN)
                return -EFAULT;         /* match IRIX behaviour */
 
@@ -138,6 +139,7 @@ int
 xfs_attr_get(
        struct xfs_inode        *ip,
        const unsigned char     *name,
+       size_t                  namelen,
        unsigned char           **value,
        int                     *valuelenp,
        int                     flags)
@@ -153,7 +155,7 @@ xfs_attr_get(
        if (XFS_FORCED_SHUTDOWN(ip->i_mount))
                return -EIO;
 
-       error = xfs_attr_args_init(&args, ip, name, flags);
+       error = xfs_attr_args_init(&args, ip, name, namelen, flags);
        if (error)
                return error;
 
@@ -337,6 +339,7 @@ int
 xfs_attr_set(
        struct xfs_inode        *dp,
        const unsigned char     *name,
+       size_t                  namelen,
        unsigned char           *value,
        int                     valuelen,
        int                     flags)
@@ -352,7 +355,7 @@ xfs_attr_set(
        if (XFS_FORCED_SHUTDOWN(dp->i_mount))
                return -EIO;
 
-       error = xfs_attr_args_init(&args, dp, name, flags);
+       error = xfs_attr_args_init(&args, dp, name, namelen, flags);
        if (error)
                return error;
 
@@ -441,6 +444,7 @@ int
 xfs_attr_remove(
        struct xfs_inode        *dp,
        const unsigned char     *name,
+       size_t                  namelen,
        int                     flags)
 {
        struct xfs_mount        *mp = dp->i_mount;
@@ -452,7 +456,7 @@ xfs_attr_remove(
        if (XFS_FORCED_SHUTDOWN(dp->i_mount))
                return -EIO;
 
-       error = xfs_attr_args_init(&args, dp, name, flags);
+       error = xfs_attr_args_init(&args, dp, name, namelen, flags);
        if (error)
                return error;
 
index 91c2cb14276e2c9620a6a28b824011ffc8160e76..4243b2272642ba9c0037b945d1d80b49160439f7 100644 (file)
@@ -148,11 +148,13 @@ int xfs_attr_list_int(struct xfs_attr_list_context *);
 int xfs_inode_hasattr(struct xfs_inode *ip);
 int xfs_attr_get_ilocked(struct xfs_inode *ip, struct xfs_da_args *args);
 int xfs_attr_get(struct xfs_inode *ip, const unsigned char *name,
-                unsigned char **value, int *valuelenp, int flags);
+                size_t namelen, unsigned char **value, int *valuelenp,
+                int flags);
 int xfs_attr_set(struct xfs_inode *dp, const unsigned char *name,
-                unsigned char *value, int valuelen, int flags);
+                size_t namelen, unsigned char *value, int valuelen, int flags);
 int xfs_attr_set_args(struct xfs_da_args *args);
-int xfs_attr_remove(struct xfs_inode *dp, const unsigned char *name, int flags);
+int xfs_attr_remove(struct xfs_inode *dp, const unsigned char *name,
+                   size_t namelen, int flags);
 int xfs_attr_remove_args(struct xfs_da_args *args);
 int xfs_attr_list(struct xfs_inode *dp, char *buffer, int bufsize,
                  int flags, struct attrlist_cursor_kern *cursor);