Skip to contentSkip to conversation

f2fs: replace ERANGE with ENAMETOOLONG in file name length check

PATCH In review Wang Xiaojun 3 participants 5 messages Jun 15, 2021 – Jun 16, 2021 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: replace ERANGE with ENAMETOOLONG in file name length check

ERANGE indicates that the math result is not representative. Here, ENAMETOOLONG is used to replace ERANGE.

---
 fs/f2fs/xattr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/xattr.c +2 -2
index c8f34decbf8e..eb827c10e970 100644
@@ -529,7 +529,7 @@ int f2fs_getxattr(struct inode *inode, int index, const char *name,
 
 	len = strlen(name);
 	if (len > F2FS_NAME_LEN)
-		return -ERANGE;
+		return -ENAMETOOLONG;
 
 	down_read(&F2FS_I(inode)->i_xattr_sem);
 	error = lookup_all_xattrs(inode, ipage, index, len, name,
@@ -646,7 +646,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
 	len = strlen(name);
 
 	if (len > F2FS_NAME_LEN)
-		return -ERANGE;
+		return -ENAMETOOLONG;
 
 	if (size > MAX_VALUE_LEN(inode))
 		return -E2BIG;
Signature · 8 lines
2.25.4



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#1 lore raw
Quoted 4 lines · Wang Xiaojun

ERANGE indicates that the math result is not representative. Here, ENAMETOOLONG is used to replace ERANGE.

I don't think ENAMETOOLONG is a valid return code for {g,s}etxattr.
https://man7.org/linux/man-pages/man2/getxattr.2.html
https://man7.org/linux/man-pages/man2/setxattr.2.html
instead of ERANGE.

please also see ext4 / xfs implementations.

Thanks,
Gao Xiang

Quoted 35 lines
---
 fs/f2fs/xattr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/xattr.c +2 -2
index c8f34decbf8e..eb827c10e970 100644
@@ -529,7 +529,7 @@ int f2fs_getxattr(struct inode *inode, int index, const char *name,
 
 	len = strlen(name);
 	if (len > F2FS_NAME_LEN)
-		return -ERANGE;
+		return -ENAMETOOLONG;
 
 	down_read(&F2FS_I(inode)->i_xattr_sem);
 	error = lookup_all_xattrs(inode, ipage, index, len, name,
@@ -646,7 +646,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
 	len = strlen(name);
 
 	if (len > F2FS_NAME_LEN)
-		return -ERANGE;
+		return -ENAMETOOLONG;
 
 	if (size > MAX_VALUE_LEN(inode))
 		return -E2BIG;
Signature · 8 lines
2.25.4



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#2 lore raw
Quoted 10 lines · Gao Xiang
Quoted 4 lines · Wang Xiaojun

ERANGE indicates that the math result is not representative. Here, ENAMETOOLONG is used to replace ERANGE.

I don't think ENAMETOOLONG is a valid return code for {g,s}etxattr.
https://man7.org/linux/man-pages/man2/getxattr.2.html
https://man7.org/linux/man-pages/man2/setxattr.2.html
instead of ERANGE.

Quoted 4 lines

please also see ext4 / xfs implementations.

Thanks,
Gao Xiang

Hi Xiang, You're right. Thanks for your comments.

Quoted 32 lines
Quoted 32 lines
---
  fs/f2fs/xattr.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/xattr.c +2 -2
index c8f34decbf8e..eb827c10e970 100644
@@ -529,7 +529,7 @@ int f2fs_getxattr(struct inode *inode, int index, const char *name,
 
  	len = strlen(name);
  	if (len > F2FS_NAME_LEN)
-		return -ERANGE;
+		return -ENAMETOOLONG;
 
  	down_read(&F2FS_I(inode)->i_xattr_sem);
  	error = lookup_all_xattrs(inode, ipage, index, len, name,
@@ -646,7 +646,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
  	len = strlen(name);
 
  	if (len > F2FS_NAME_LEN)
-		return -ERANGE;
+		return -ENAMETOOLONG;
 
  	if (size > MAX_VALUE_LEN(inode))
  		return -E2BIG;
Signature · 1 line
2.25.4
Quoted 5 lines
Quoted 4 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#3 lore raw
Quoted 12 lines · wangxiaojun (N)
Quoted 10 lines · Gao Xiang
Quoted 4 lines · Wang Xiaojun

ERANGE indicates that the math result is not representative. Here, ENAMETOOLONG is used to replace ERANGE.

I don't think ENAMETOOLONG is a valid return code for {g,s}etxattr.
https://man7.org/linux/man-pages/man2/getxattr.2.html
https://man7.org/linux/man-pages/man2/setxattr.2.html
instead of ERANGE.

Quoted 6 lines
Quoted 4 lines

please also see ext4 / xfs implementations.

Thanks,
Gao Xiang

Hi Xiang, You're right. Thanks for your comments.

Hi Xiaojun,

Yeah, currently ENAMETOOLONG is strictly specific for pathname. If we change like this, I'm not sure if it could break some exist user programs.

IOW, it should be a wide discussion or modification at least.

Thanks,
Gao Xiang

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines

---
  fs/f2fs/xattr.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/xattr.c +2 -2
index c8f34decbf8e..eb827c10e970 100644
@@ -529,7 +529,7 @@ int f2fs_getxattr(struct inode *inode, int index, const char *name,
  	len = strlen(name);
  	if (len > F2FS_NAME_LEN)
-		return -ERANGE;
+		return -ENAMETOOLONG;
  	down_read(&F2FS_I(inode)->i_xattr_sem);
  	error = lookup_all_xattrs(inode, ipage, index, len, name,
@@ -646,7 +646,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
  	len = strlen(name);
  	if (len > F2FS_NAME_LEN)
-		return -ERANGE;
+		return -ENAMETOOLONG;
  	if (size > MAX_VALUE_LEN(inode))
  		return -E2BIG;
Signature · 1 line
2.25.4
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

maintainer
#4 lore raw
In reply to Gao Xiang
Quoted 10 lines · Gao Xiang
Quoted 4 lines · Wang Xiaojun

ERANGE indicates that the math result is not representative. Here, ENAMETOOLONG is used to replace ERANGE.

I don't think ENAMETOOLONG is a valid return code for {g,s}etxattr.
https://man7.org/linux/man-pages/man2/getxattr.2.html
https://man7.org/linux/man-pages/man2/setxattr.2.html
instead of ERANGE.

Agreed, it should implement according to man of {g,s}etxattr.

Thanks,

Quoted 38 lines

please also see ext4 / xfs implementations.

Thanks,
Gao Xiang

Quoted 31 lines
---
  fs/f2fs/xattr.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/xattr.c +2 -2
index c8f34decbf8e..eb827c10e970 100644
@@ -529,7 +529,7 @@ int f2fs_getxattr(struct inode *inode, int index, const char *name,
 
  	len = strlen(name);
  	if (len > F2FS_NAME_LEN)
-		return -ERANGE;
+		return -ENAMETOOLONG;
 
  	down_read(&F2FS_I(inode)->i_xattr_sem);
  	error = lookup_all_xattrs(inode, ipage, index, len, name,
@@ -646,7 +646,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
  	len = strlen(name);
 
  	if (len > F2FS_NAME_LEN)
-		return -ERANGE;
+		return -ENAMETOOLONG;
 
  	if (size > MAX_VALUE_LEN(inode))
  		return -E2BIG;
Signature · 1 line
2.25.4
Quoted 11 lines
Quoted 4 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel