udf: Parameterize output length in udf_put_filename
authorAndrew Gabbasov <andrew_gabbasov@mentor.com>
Fri, 15 Jan 2016 08:44:19 +0000 (02:44 -0600)
committerJan Kara <jack@suse.cz>
Tue, 9 Feb 2016 12:05:23 +0000 (13:05 +0100)
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>
fs/udf/namei.c
fs/udf/udfdecl.h
fs/udf/unicode.c

index 42eafb91f7ff3c092fd38f6fb6136862ca6508c8..f82c70d73aba92c90728e168dd3e14f73f26378c 100644 (file)
@@ -362,8 +362,9 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
                        *err = -EINVAL;
                        goto out_err;
                }
-               namelen = udf_put_filename(sb, dentry->d_name.name, name,
-                                                dentry->d_name.len);
+               namelen = udf_put_filename(sb, dentry->d_name.name,
+                                          dentry->d_name.len,
+                                          name, UDF_NAME_LEN);
                if (!namelen) {
                        *err = -ENAMETOOLONG;
                        goto out_err;
@@ -997,8 +998,9 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
                }
 
                if (pc->componentType == 5) {
-                       namelen = udf_put_filename(sb, compstart, name,
-                                                  symname - compstart);
+                       namelen = udf_put_filename(sb, compstart,
+                                                  symname - compstart,
+                                                  name, UDF_NAME_LEN);
                        if (!namelen)
                                goto out_no_entry;
 
index fa0044b6b81d226223aa7ea61dd56c9f83e146e9..4a47c72676143efcd38f61700579444495f631f4 100644 (file)
@@ -216,8 +216,8 @@ udf_get_lb_pblock(struct super_block *sb, struct kernel_lb_addr *loc,
 /* unicode.c */
 extern int udf_get_filename(struct super_block *, uint8_t *, int, uint8_t *,
                            int);
-extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *,
-                           int);
+extern int udf_put_filename(struct super_block *, const uint8_t *, int,
+                           uint8_t *, int);
 extern int udf_build_ustr(struct ustr *, dstring *, int);
 extern int udf_CS0toUTF8(struct ustr *, const struct ustr *);
 
index e788a05aab83670de6be03dc48eb519e2d2ae5d9..47e61883275d440ea97b76fd13ee8b4fab21258d 100644 (file)
@@ -395,22 +395,22 @@ out1:
        return ret;
 }
 
-int udf_put_filename(struct super_block *sb, const uint8_t *sname,
-                    uint8_t *dname, int flen)
+int udf_put_filename(struct super_block *sb, const uint8_t *sname, int slen,
+                    uint8_t *dname, int dlen)
 {
        struct ustr unifilename;
        int namelen;
 
-       if (!udf_char_to_ustr(&unifilename, sname, flen))
+       if (!udf_char_to_ustr(&unifilename, sname, slen))
                return 0;
 
        if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
-               namelen = udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN);
+               namelen = udf_UTF8toCS0(dname, &unifilename, dlen);
                if (!namelen)
                        return 0;
        } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
                namelen = udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname,
-                                       &unifilename, UDF_NAME_LEN);
+                                       &unifilename, dlen);
                if (!namelen)
                        return 0;
        } else