diff options
author | Andrew Gabbasov <andrew_gabbasov@mentor.com> | 2016-01-15 03:44:19 -0500 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2016-02-09 07:05:23 -0500 |
commit | 525e2c56c341cb8b31bbe1694f0582077f454969 (patch) | |
tree | bc3abd9e1f07f0e4322d290fac0fcac90a38d63e /fs/udf | |
parent | 7955118eafc4a2621fd88e92b505919af344583f (diff) |
udf: Parameterize output length in udf_put_filename
Make the desired output length a parameter rather than have it
hard-coded to UDF_NAME_LEN. Although all call sites still have
this length the same, this parameterization will make the function
more universal and also consistent with udf_get_filename.
Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf')
-rw-r--r-- | fs/udf/namei.c | 10 | ||||
-rw-r--r-- | fs/udf/udfdecl.h | 4 | ||||
-rw-r--r-- | fs/udf/unicode.c | 10 |
3 files changed, 13 insertions, 11 deletions
diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 42eafb91f7ff..f82c70d73aba 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c | |||
@@ -362,8 +362,9 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
362 | *err = -EINVAL; | 362 | *err = -EINVAL; |
363 | goto out_err; | 363 | goto out_err; |
364 | } | 364 | } |
365 | namelen = udf_put_filename(sb, dentry->d_name.name, name, | 365 | namelen = udf_put_filename(sb, dentry->d_name.name, |
366 | dentry->d_name.len); | 366 | dentry->d_name.len, |
367 | name, UDF_NAME_LEN); | ||
367 | if (!namelen) { | 368 | if (!namelen) { |
368 | *err = -ENAMETOOLONG; | 369 | *err = -ENAMETOOLONG; |
369 | goto out_err; | 370 | goto out_err; |
@@ -997,8 +998,9 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
997 | } | 998 | } |
998 | 999 | ||
999 | if (pc->componentType == 5) { | 1000 | if (pc->componentType == 5) { |
1000 | namelen = udf_put_filename(sb, compstart, name, | 1001 | namelen = udf_put_filename(sb, compstart, |
1001 | symname - compstart); | 1002 | symname - compstart, |
1003 | name, UDF_NAME_LEN); | ||
1002 | if (!namelen) | 1004 | if (!namelen) |
1003 | goto out_no_entry; | 1005 | goto out_no_entry; |
1004 | 1006 | ||
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h index fa0044b6b81d..4a47c7267614 100644 --- a/fs/udf/udfdecl.h +++ b/fs/udf/udfdecl.h | |||
@@ -216,8 +216,8 @@ udf_get_lb_pblock(struct super_block *sb, struct kernel_lb_addr *loc, | |||
216 | /* unicode.c */ | 216 | /* unicode.c */ |
217 | extern int udf_get_filename(struct super_block *, uint8_t *, int, uint8_t *, | 217 | extern int udf_get_filename(struct super_block *, uint8_t *, int, uint8_t *, |
218 | int); | 218 | int); |
219 | extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *, | 219 | extern int udf_put_filename(struct super_block *, const uint8_t *, int, |
220 | int); | 220 | uint8_t *, int); |
221 | extern int udf_build_ustr(struct ustr *, dstring *, int); | 221 | extern int udf_build_ustr(struct ustr *, dstring *, int); |
222 | extern int udf_CS0toUTF8(struct ustr *, const struct ustr *); | 222 | extern int udf_CS0toUTF8(struct ustr *, const struct ustr *); |
223 | 223 | ||
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c index e788a05aab83..47e61883275d 100644 --- a/fs/udf/unicode.c +++ b/fs/udf/unicode.c | |||
@@ -395,22 +395,22 @@ out1: | |||
395 | return ret; | 395 | return ret; |
396 | } | 396 | } |
397 | 397 | ||
398 | int udf_put_filename(struct super_block *sb, const uint8_t *sname, | 398 | int udf_put_filename(struct super_block *sb, const uint8_t *sname, int slen, |
399 | uint8_t *dname, int flen) | 399 | uint8_t *dname, int dlen) |
400 | { | 400 | { |
401 | struct ustr unifilename; | 401 | struct ustr unifilename; |
402 | int namelen; | 402 | int namelen; |
403 | 403 | ||
404 | if (!udf_char_to_ustr(&unifilename, sname, flen)) | 404 | if (!udf_char_to_ustr(&unifilename, sname, slen)) |
405 | return 0; | 405 | return 0; |
406 | 406 | ||
407 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { | 407 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { |
408 | namelen = udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN); | 408 | namelen = udf_UTF8toCS0(dname, &unifilename, dlen); |
409 | if (!namelen) | 409 | if (!namelen) |
410 | return 0; | 410 | return 0; |
411 | } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { | 411 | } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { |
412 | namelen = udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname, | 412 | namelen = udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname, |
413 | &unifilename, UDF_NAME_LEN); | 413 | &unifilename, dlen); |
414 | if (!namelen) | 414 | if (!namelen) |
415 | return 0; | 415 | return 0; |
416 | } else | 416 | } else |