cifs: use correct format characters
[GitHub/LineageOS/android_kernel_motorola_exynos9610.git] / fs / udf / super.c
index 93c59630512b2d7e074278f0478542d69c193bb9..242d960df9a17a2171a3824b2dea6405a05dec81 100644 (file)
@@ -673,7 +673,7 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
        sbi->s_dmode = uopt.dmode;
        write_unlock(&sbi->s_cred_lock);
 
-       if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
+       if ((bool)(*flags & MS_RDONLY) == sb_rdonly(sb))
                goto out_unlock;
 
        if (*flags & MS_RDONLY)
@@ -703,7 +703,7 @@ static loff_t udf_check_vsd(struct super_block *sb)
        else
                sectorsize = sb->s_blocksize;
 
-       sector += (sbi->s_session << sb->s_blocksize_bits);
+       sector += (((loff_t)sbi->s_session) << sb->s_blocksize_bits);
 
        udf_debug("Starting at sector %u (%ld byte sectors)\n",
                  (unsigned int)(sector >> sb->s_blocksize_bits),
@@ -922,16 +922,20 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
        }
 
        ret = udf_dstrCS0toUTF8(outstr, 31, pvoldesc->volIdent, 32);
-       if (ret < 0)
-               goto out_bh;
-
-       strncpy(UDF_SB(sb)->s_volume_ident, outstr, ret);
+       if (ret < 0) {
+               strcpy(UDF_SB(sb)->s_volume_ident, "InvalidName");
+               pr_warn("incorrect volume identification, setting to "
+                       "'InvalidName'\n");
+       } else {
+               strncpy(UDF_SB(sb)->s_volume_ident, outstr, ret);
+       }
        udf_debug("volIdent[] = '%s'\n", UDF_SB(sb)->s_volume_ident);
 
        ret = udf_dstrCS0toUTF8(outstr, 127, pvoldesc->volSetIdent, 128);
-       if (ret < 0)
+       if (ret < 0) {
+               ret = 0;
                goto out_bh;
-
+       }
        outstr[ret] = 0;
        udf_debug("volSetIdent[] = '%s'\n", outstr);
 
@@ -1017,7 +1021,7 @@ static int udf_load_metadata_files(struct super_block *sb, int partition,
 
                fe = udf_iget_special(sb, &addr);
                if (IS_ERR(fe)) {
-                       if (sb->s_flags & MS_RDONLY)
+                       if (sb_rdonly(sb))
                                udf_warn(sb, "bitmap inode efe not found but it's ok since the disc is mounted read-only\n");
                        else {
                                udf_err(sb, "bitmap inode efe not found and attempted read-write mount\n");
@@ -1341,7 +1345,7 @@ static int udf_load_partdesc(struct super_block *sb, sector_t block)
                 * writing to it (we overwrite blocks instead of relocating
                 * them).
                 */
-               if (!(sb->s_flags & MS_RDONLY)) {
+               if (!sb_rdonly(sb)) {
                        ret = -EACCES;
                        goto out_bh;
                }
@@ -2091,8 +2095,9 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
        bool lvid_open = false;
 
        uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT);
-       uopt.uid = INVALID_UID;
-       uopt.gid = INVALID_GID;
+       /* By default we'll use overflow[ug]id when UDF inode [ug]id == -1 */
+       uopt.uid = make_kuid(current_user_ns(), overflowuid);
+       uopt.gid = make_kgid(current_user_ns(), overflowgid);
        uopt.umask = 0;
        uopt.fmode = UDF_INVALID_MODE;
        uopt.dmode = UDF_INVALID_MODE;
@@ -2205,7 +2210,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
                        ret = -EINVAL;
                        goto error_out;
                } else if (minUDFWriteRev > UDF_MAX_WRITE_VERSION &&
-                          !(sb->s_flags & MS_RDONLY)) {
+                          !sb_rdonly(sb)) {
                        ret = -EACCES;
                        goto error_out;
                }
@@ -2226,7 +2231,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 
        if (sbi->s_partmaps[sbi->s_partition].s_partition_flags &
                        UDF_PART_FLAG_READ_ONLY &&
-           !(sb->s_flags & MS_RDONLY)) {
+           !sb_rdonly(sb)) {
                ret = -EACCES;
                goto error_out;
        }
@@ -2245,7 +2250,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
                         le16_to_cpu(ts.year), ts.month, ts.day,
                         ts.hour, ts.minute, le16_to_cpu(ts.typeAndTimezone));
        }
-       if (!(sb->s_flags & MS_RDONLY)) {
+       if (!sb_rdonly(sb)) {
                udf_open_lvid(sb);
                lvid_open = true;
        }
@@ -2332,7 +2337,7 @@ static void udf_put_super(struct super_block *sb)
        if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
                unload_nls(sbi->s_nls_map);
 #endif
-       if (!(sb->s_flags & MS_RDONLY))
+       if (!sb_rdonly(sb))
                udf_close_lvid(sb);
        brelse(sbi->s_lvid_bh);
        udf_sb_free_partitions(sb);