]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
xfs: rename MAXPATHLEN to XFS_SYMLINK_MAXLEN
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 7 Jul 2017 15:37:26 +0000 (08:37 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Fri, 7 Jul 2017 15:37:26 +0000 (08:37 -0700)
XFS has a maximum symlink target length of 1024 bytes; this is a
holdover from the Irix days.  Unfortunately, the constant establishing
this is 'MAXPATHLEN' and is /not/ the same as the Linux MAXPATHLEN,
which is 4096.

The kernel enforces its 1024 byte MAXPATHLEN on symlink targets, but
xfsprogs picks up the (Linux) system 4096 byte MAXPATHLEN, which means
that xfs_repair doesn't complain about oversized symlinks.

Since this is an on-disk format constraint, put the define in the XFS
namespace and move everything over to use the new name.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
fs/xfs/libxfs/xfs_format.h
fs/xfs/libxfs/xfs_symlink_remote.c
fs/xfs/libxfs/xfs_trans_resv.c
fs/xfs/xfs_iops.c
fs/xfs/xfs_linux.h
fs/xfs/xfs_symlink.c

index e204a942e5bf308c0e56c6e683fb7e1c65540a74..23229f0c5b15d95f1a8be937902eec725ea5e4d0 100644 (file)
@@ -1211,6 +1211,7 @@ struct xfs_dsymlink_hdr {
 
 #define XFS_SYMLINK_CRC_OFF    offsetof(struct xfs_dsymlink_hdr, sl_crc)
 
+#define XFS_SYMLINK_MAXLEN     1024
 /*
  * The maximum pathlen is 1024 bytes. Since the minimum file system
  * blocksize is 512 bytes, we can get a max of 3 extents back from
index 2e2c6716b6239199c88708170ef0cd24d2a029cb..c484877129a0d0b55c6f94517c0a1ac1703550fc 100644 (file)
@@ -114,7 +114,7 @@ xfs_symlink_verify(
        if (bp->b_bn != be64_to_cpu(dsl->sl_blkno))
                return false;
        if (be32_to_cpu(dsl->sl_offset) +
-                               be32_to_cpu(dsl->sl_bytes) >= MAXPATHLEN)
+                               be32_to_cpu(dsl->sl_bytes) >= XFS_SYMLINK_MAXLEN)
                return false;
        if (dsl->sl_owner == 0)
                return false;
index b456cca1bfb23fbf6f318648949ea3d9fe73cad4..6bd916bd35e24a6144940bbd34a1cbab63afc09b 100644 (file)
@@ -477,14 +477,14 @@ xfs_calc_mkdir_reservation(
 /*
  * Making a new symplink is the same as creating a new file, but
  * with the added blocks for remote symlink data which can be up to 1kB in
- * length (MAXPATHLEN).
+ * length (XFS_SYMLINK_MAXLEN).
  */
 STATIC uint
 xfs_calc_symlink_reservation(
        struct xfs_mount        *mp)
 {
        return xfs_calc_create_reservation(mp) +
-              xfs_calc_buf_res(1, MAXPATHLEN);
+              xfs_calc_buf_res(1, XFS_SYMLINK_MAXLEN);
 }
 
 /*
index 077e2b2ac773453dc1afea4c1d635aeb52578ce3..469c9fa4c178d98d06445b2456d82edc86d17f63 100644 (file)
@@ -460,7 +460,7 @@ xfs_vn_get_link(
        if (!dentry)
                return ERR_PTR(-ECHILD);
 
-       link = kmalloc(MAXPATHLEN+1, GFP_KERNEL);
+       link = kmalloc(XFS_SYMLINK_MAXLEN+1, GFP_KERNEL);
        if (!link)
                goto out_err;
 
index ecdae42267d319128a3de5234826d7b78c53d9ca..44abaecd1481e341dbc86fa0ed6b01f7bffb6f1d 100644 (file)
@@ -143,7 +143,6 @@ typedef __u32                       xfs_nlink_t;
 #define __return_address __builtin_return_address(0)
 
 #define XFS_PROJID_DEFAULT     0
-#define MAXPATHLEN     1024
 
 #define MIN(a,b)       (min(a,b))
 #define MAX(a,b)       (max(a,b))
index 493804857d67a54facfcaedbbfcd4a7432237959..12cd9cf7de416f03890ad09f108c2a8f9e0c505a 100644 (file)
@@ -143,7 +143,7 @@ xfs_readlink(
        if (!pathlen)
                goto out;
 
-       if (pathlen < 0 || pathlen > MAXPATHLEN) {
+       if (pathlen < 0 || pathlen > XFS_SYMLINK_MAXLEN) {
                xfs_alert(mp, "%s: inode (%llu) bad symlink length (%lld)",
                         __func__, (unsigned long long) ip->i_ino,
                         (long long) pathlen);
@@ -202,7 +202,7 @@ xfs_symlink(
         * Check component lengths of the target path name.
         */
        pathlen = strlen(target_path);
-       if (pathlen >= MAXPATHLEN)      /* total string too long */
+       if (pathlen >= XFS_SYMLINK_MAXLEN)      /* total string too long */
                return -ENAMETOOLONG;
 
        udqp = gdqp = NULL;
@@ -559,7 +559,7 @@ xfs_inactive_symlink(
                return 0;
        }
 
-       if (pathlen < 0 || pathlen > MAXPATHLEN) {
+       if (pathlen < 0 || pathlen > XFS_SYMLINK_MAXLEN) {
                xfs_alert(mp, "%s: inode (0x%llx) bad symlink length (%d)",
                         __func__, (unsigned long long)ip->i_ino, pathlen);
                xfs_iunlock(ip, XFS_ILOCK_EXCL);