namei.c (42249094f79422fbf5ed4b54eeb48ff096809b8f) | namei.c (8ca577223f75230a746a06f4566c53943f78d5d0) |
---|---|
1/* 2 * linux/fs/affs/namei.c 3 * 4 * (c) 1996 Hans-Joachim Widmaier - Rewritten 5 * 6 * (C) 1993 Ray Burr - Modified for Amiga FFS filesystem. 7 * 8 * (C) 1991 Linus Torvalds - minix filesystem --- 46 unchanged lines hidden (view full) --- 55{ 56 return AFFS_SB(sb)->s_flags & SF_INTL ? affs_intl_toupper : affs_toupper; 57} 58 59/* 60 * Note: the dentry argument is the parent dentry. 61 */ 62static inline int | 1/* 2 * linux/fs/affs/namei.c 3 * 4 * (c) 1996 Hans-Joachim Widmaier - Rewritten 5 * 6 * (C) 1993 Ray Burr - Modified for Amiga FFS filesystem. 7 * 8 * (C) 1991 Linus Torvalds - minix filesystem --- 46 unchanged lines hidden (view full) --- 55{ 56 return AFFS_SB(sb)->s_flags & SF_INTL ? affs_intl_toupper : affs_toupper; 57} 58 59/* 60 * Note: the dentry argument is the parent dentry. 61 */ 62static inline int |
63__affs_hash_dentry(struct qstr *qstr, toupper_t toupper) | 63__affs_hash_dentry(struct qstr *qstr, toupper_t toupper, bool notruncate) |
64{ 65 const u8 *name = qstr->name; 66 unsigned long hash; 67 int i; 68 | 64{ 65 const u8 *name = qstr->name; 66 unsigned long hash; 67 int i; 68 |
69 i = affs_check_name(qstr->name, qstr->len); | 69 i = affs_check_name(qstr->name, qstr->len, notruncate); |
70 if (i) 71 return i; 72 73 hash = init_name_hash(); 74 i = min(qstr->len, 30u); 75 for (; i > 0; name++, i--) 76 hash = partial_name_hash(toupper(*name), hash); 77 qstr->hash = end_name_hash(hash); 78 79 return 0; 80} 81 82static int 83affs_hash_dentry(const struct dentry *dentry, struct qstr *qstr) 84{ | 70 if (i) 71 return i; 72 73 hash = init_name_hash(); 74 i = min(qstr->len, 30u); 75 for (; i > 0; name++, i--) 76 hash = partial_name_hash(toupper(*name), hash); 77 qstr->hash = end_name_hash(hash); 78 79 return 0; 80} 81 82static int 83affs_hash_dentry(const struct dentry *dentry, struct qstr *qstr) 84{ |
85 return __affs_hash_dentry(qstr, affs_toupper); | 85 return __affs_hash_dentry(qstr, affs_toupper, 86 affs_nofilenametruncate(dentry)); 87 |
86} | 88} |
89 |
|
87static int 88affs_intl_hash_dentry(const struct dentry *dentry, struct qstr *qstr) 89{ | 90static int 91affs_intl_hash_dentry(const struct dentry *dentry, struct qstr *qstr) 92{ |
90 return __affs_hash_dentry(qstr, affs_intl_toupper); | 93 return __affs_hash_dentry(qstr, affs_intl_toupper, 94 affs_nofilenametruncate(dentry)); 95 |
91} 92 93static inline int __affs_compare_dentry(unsigned int len, | 96} 97 98static inline int __affs_compare_dentry(unsigned int len, |
94 const char *str, const struct qstr *name, toupper_t toupper) | 99 const char *str, const struct qstr *name, toupper_t toupper, 100 bool notruncate) |
95{ 96 const u8 *aname = str; 97 const u8 *bname = name->name; 98 99 /* 100 * 'str' is the name of an already existing dentry, so the name 101 * must be valid. 'name' must be validated first. 102 */ 103 | 101{ 102 const u8 *aname = str; 103 const u8 *bname = name->name; 104 105 /* 106 * 'str' is the name of an already existing dentry, so the name 107 * must be valid. 'name' must be validated first. 108 */ 109 |
104 if (affs_check_name(name->name, name->len)) | 110 if (affs_check_name(name->name, name->len, notruncate)) |
105 return 1; 106 107 /* 108 * If the names are longer than the allowed 30 chars, 109 * the excess is ignored, so their length may differ. 110 */ 111 if (len >= 30) { 112 if (name->len < 30) --- 8 unchanged lines hidden (view full) --- 121 122 return 0; 123} 124 125static int 126affs_compare_dentry(const struct dentry *parent, const struct dentry *dentry, 127 unsigned int len, const char *str, const struct qstr *name) 128{ | 111 return 1; 112 113 /* 114 * If the names are longer than the allowed 30 chars, 115 * the excess is ignored, so their length may differ. 116 */ 117 if (len >= 30) { 118 if (name->len < 30) --- 8 unchanged lines hidden (view full) --- 127 128 return 0; 129} 130 131static int 132affs_compare_dentry(const struct dentry *parent, const struct dentry *dentry, 133 unsigned int len, const char *str, const struct qstr *name) 134{ |
129 return __affs_compare_dentry(len, str, name, affs_toupper); | 135 136 return __affs_compare_dentry(len, str, name, affs_toupper, 137 affs_nofilenametruncate(parent)); |
130} | 138} |
139 |
|
131static int 132affs_intl_compare_dentry(const struct dentry *parent, const struct dentry *dentry, 133 unsigned int len, const char *str, const struct qstr *name) 134{ | 140static int 141affs_intl_compare_dentry(const struct dentry *parent, const struct dentry *dentry, 142 unsigned int len, const char *str, const struct qstr *name) 143{ |
135 return __affs_compare_dentry(len, str, name, affs_intl_toupper); | 144 return __affs_compare_dentry(len, str, name, affs_intl_toupper, 145 affs_nofilenametruncate(parent)); 146 |
136} 137 138/* 139 * NOTE! unlike strncmp, affs_match returns 1 for success, 0 for failure. 140 */ 141 142static inline int 143affs_match(struct dentry *dentry, const u8 *name2, toupper_t toupper) --- 262 unchanged lines hidden (view full) --- 406 struct super_block *sb = old_dir->i_sb; 407 struct buffer_head *bh = NULL; 408 int retval; 409 410 pr_debug("AFFS: rename(old=%u,\"%*s\" to new=%u,\"%*s\")\n", 411 (u32)old_dir->i_ino, (int)old_dentry->d_name.len, old_dentry->d_name.name, 412 (u32)new_dir->i_ino, (int)new_dentry->d_name.len, new_dentry->d_name.name); 413 | 147} 148 149/* 150 * NOTE! unlike strncmp, affs_match returns 1 for success, 0 for failure. 151 */ 152 153static inline int 154affs_match(struct dentry *dentry, const u8 *name2, toupper_t toupper) --- 262 unchanged lines hidden (view full) --- 417 struct super_block *sb = old_dir->i_sb; 418 struct buffer_head *bh = NULL; 419 int retval; 420 421 pr_debug("AFFS: rename(old=%u,\"%*s\" to new=%u,\"%*s\")\n", 422 (u32)old_dir->i_ino, (int)old_dentry->d_name.len, old_dentry->d_name.name, 423 (u32)new_dir->i_ino, (int)new_dentry->d_name.len, new_dentry->d_name.name); 424 |
414 retval = affs_check_name(new_dentry->d_name.name,new_dentry->d_name.len); | 425 retval = affs_check_name(new_dentry->d_name.name, 426 new_dentry->d_name.len, 427 affs_nofilenametruncate(old_dentry)); 428 |
415 if (retval) 416 return retval; 417 418 /* Unlink destination if it already exists */ 419 if (new_dentry->d_inode) { 420 retval = affs_remove_header(new_dentry); 421 if (retval) 422 return retval; --- 26 unchanged lines hidden --- | 429 if (retval) 430 return retval; 431 432 /* Unlink destination if it already exists */ 433 if (new_dentry->d_inode) { 434 retval = affs_remove_header(new_dentry); 435 if (retval) 436 return retval; --- 26 unchanged lines hidden --- |