Commit 810c1b2e authored by Al Viro's avatar Al Viro

udf: fix i_nlink limit

(256 << sizeof(x)) - 1 is not the maximal possible value of x...
In reality, the maximal allowed value for UDF FileLinkCount is
65535.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 99890a3b
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#include <linux/crc-itu-t.h> #include <linux/crc-itu-t.h>
#include <linux/exportfs.h> #include <linux/exportfs.h>
enum { UDF_MAX_LINKS = 0xffff };
static inline int udf_match(int len1, const unsigned char *name1, int len2, static inline int udf_match(int len1, const unsigned char *name1, int len2,
const unsigned char *name2) const unsigned char *name2)
{ {
...@@ -650,7 +652,7 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -650,7 +652,7 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
struct udf_inode_info *iinfo; struct udf_inode_info *iinfo;
err = -EMLINK; err = -EMLINK;
if (dir->i_nlink >= (256 << sizeof(dir->i_nlink)) - 1) if (dir->i_nlink >= UDF_MAX_LINKS)
goto out; goto out;
err = -EIO; err = -EIO;
...@@ -1034,9 +1036,8 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir, ...@@ -1034,9 +1036,8 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
struct fileIdentDesc cfi, *fi; struct fileIdentDesc cfi, *fi;
int err; int err;
if (inode->i_nlink >= (256 << sizeof(inode->i_nlink)) - 1) { if (inode->i_nlink >= UDF_MAX_LINKS)
return -EMLINK; return -EMLINK;
}
fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err);
if (!fi) { if (!fi) {
...@@ -1131,9 +1132,7 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1131,9 +1132,7 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
goto end_rename; goto end_rename;
retval = -EMLINK; retval = -EMLINK;
if (!new_inode && if (!new_inode && new_dir->i_nlink >= UDF_MAX_LINKS)
new_dir->i_nlink >=
(256 << sizeof(new_dir->i_nlink)) - 1)
goto end_rename; goto end_rename;
} }
if (!nfi) { if (!nfi) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment