Skip to content

Commit 037369b

Browse files
mikulas-patockatorvalds
authored andcommitted
hpfs: implement the show_options method
The HPFS filesystem used generic_show_options to produce string that is displayed in /proc/mounts. However, there is a problem that the options may disappear after remount. If we mount the filesystem with option1 and then remount it with option2, /proc/mounts should show both option1 and option2, however it only shows option2 because the whole option string is replaced with replace_mount_options in hpfs_remount_fs. To fix this bug, implement the hpfs_show_options function that prints options that are currently selected. Signed-off-by: Mikulas Patocka <[email protected]> Cc: [email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 01d6e08 commit 037369b

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

fs/hpfs/super.c

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/sched.h>
1616
#include <linux/bitmap.h>
1717
#include <linux/slab.h>
18+
#include <linux/seq_file.h>
1819

1920
/* Mark the filesystem dirty, so that chkdsk checks it when os/2 booted */
2021

@@ -453,10 +454,6 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
453454
int lowercase, eas, chk, errs, chkdsk, timeshift;
454455
int o;
455456
struct hpfs_sb_info *sbi = hpfs_sb(s);
456-
char *new_opts = kstrdup(data, GFP_KERNEL);
457-
458-
if (data && !new_opts)
459-
return -ENOMEM;
460457

461458
sync_filesystem(s);
462459

@@ -493,18 +490,44 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
493490

494491
if (!(*flags & MS_RDONLY)) mark_dirty(s, 1);
495492

496-
if (new_opts)
497-
replace_mount_options(s, new_opts);
498-
499493
hpfs_unlock(s);
500494
return 0;
501495

502496
out_err:
503497
hpfs_unlock(s);
504-
kfree(new_opts);
505498
return -EINVAL;
506499
}
507500

501+
static int hpfs_show_options(struct seq_file *seq, struct dentry *root)
502+
{
503+
struct hpfs_sb_info *sbi = hpfs_sb(root->d_sb);
504+
505+
seq_printf(seq, ",uid=%u", from_kuid_munged(&init_user_ns, sbi->sb_uid));
506+
seq_printf(seq, ",gid=%u", from_kgid_munged(&init_user_ns, sbi->sb_gid));
507+
seq_printf(seq, ",umask=%03o", (~sbi->sb_mode & 0777));
508+
if (sbi->sb_lowercase)
509+
seq_printf(seq, ",case=lower");
510+
if (!sbi->sb_chk)
511+
seq_printf(seq, ",check=none");
512+
if (sbi->sb_chk == 2)
513+
seq_printf(seq, ",check=strict");
514+
if (!sbi->sb_err)
515+
seq_printf(seq, ",errors=continue");
516+
if (sbi->sb_err == 2)
517+
seq_printf(seq, ",errors=panic");
518+
if (!sbi->sb_chkdsk)
519+
seq_printf(seq, ",chkdsk=no");
520+
if (sbi->sb_chkdsk == 2)
521+
seq_printf(seq, ",chkdsk=always");
522+
if (!sbi->sb_eas)
523+
seq_printf(seq, ",eas=no");
524+
if (sbi->sb_eas == 1)
525+
seq_printf(seq, ",eas=ro");
526+
if (sbi->sb_timeshift)
527+
seq_printf(seq, ",timeshift=%d", sbi->sb_timeshift);
528+
return 0;
529+
}
530+
508531
/* Super operations */
509532

510533
static const struct super_operations hpfs_sops =
@@ -515,7 +538,7 @@ static const struct super_operations hpfs_sops =
515538
.put_super = hpfs_put_super,
516539
.statfs = hpfs_statfs,
517540
.remount_fs = hpfs_remount_fs,
518-
.show_options = generic_show_options,
541+
.show_options = hpfs_show_options,
519542
};
520543

521544
static int hpfs_fill_super(struct super_block *s, void *options, int silent)
@@ -538,8 +561,6 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
538561

539562
int o;
540563

541-
save_mount_options(s, options);
542-
543564
sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
544565
if (!sbi) {
545566
return -ENOMEM;

0 commit comments

Comments
 (0)