Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6eb0b8df authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: rename MAXPATHLEN to XFS_SYMLINK_MAXLEN



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: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
parent 2192b0ba
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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;
+2 −2
Original line number Diff line number Diff line
@@ -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);
}

/*
+1 −1
Original line number Diff line number Diff line
@@ -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;

+0 −1
Original line number Diff line number Diff line
@@ -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))
Loading