Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85c78591 authored by Denis Karpov's avatar Denis Karpov Committed by OGAWA Hirofumi
Browse files

FAT: add 'errors' mount option



On severe errors FAT remounts itself in read-only mode. Allow to
specify FAT fs desired behavior through 'errors' mount option:
panic, continue or remount read-only.

`mount -t [fat|vfat] -o errors=[panic,remount-ro,continue] \
	<bdev> <mount point>`

This is analog to ext2 fs 'errors' mount option.

Signed-off-by: default avatarDenis Karpov <ext-denis.2.karpov@nokia.com>
Signed-off-by: default avatarOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
parent 9fa7eb28
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -132,6 +132,11 @@ rodir -- FAT has the ATTR_RO (read-only) attribute. But on Windows,
		 If you want to use ATTR_RO as read-only flag even for
		 the directory, set this option.

errors=panic|continue|remount-ro
	      -- specify FAT behavior on critical errors: panic, continue
		 without doing anything or remount the partition in
		 read-only mode (default behavior).

<bool>: 0,1,yes,no,true,false

TODO
+3 −3
Original line number Diff line number Diff line
@@ -241,7 +241,7 @@ int fat_get_cluster(struct inode *inode, int cluster, int *fclus, int *dclus)
	while (*fclus < cluster) {
		/* prevent the infinite loop of cluster chain */
		if (*fclus > limit) {
			fat_fs_panic(sb, "%s: detected the cluster chain loop"
			fat_fs_error(sb, "%s: detected the cluster chain loop"
				     " (i_pos %lld)", __func__,
				     MSDOS_I(inode)->i_pos);
			nr = -EIO;
@@ -252,7 +252,7 @@ int fat_get_cluster(struct inode *inode, int cluster, int *fclus, int *dclus)
		if (nr < 0)
			goto out;
		else if (nr == FAT_ENT_FREE) {
			fat_fs_panic(sb, "%s: invalid cluster chain"
			fat_fs_error(sb, "%s: invalid cluster chain"
				     " (i_pos %lld)", __func__,
				     MSDOS_I(inode)->i_pos);
			nr = -EIO;
@@ -285,7 +285,7 @@ static int fat_bmap_cluster(struct inode *inode, int cluster)
	if (ret < 0)
		return ret;
	else if (ret == FAT_ENT_EOF) {
		fat_fs_panic(sb, "%s: request beyond EOF (i_pos %lld)",
		fat_fs_error(sb, "%s: request beyond EOF (i_pos %lld)",
			     __func__, MSDOS_I(inode)->i_pos);
		return -EIO;
	}
+1 −1
Original line number Diff line number Diff line
@@ -1334,7 +1334,7 @@ int fat_add_entries(struct inode *dir, void *slots, int nr_slots,
			goto error_remove;
		}
		if (dir->i_size & (sbi->cluster_size - 1)) {
			fat_fs_panic(sb, "Odd directory size");
			fat_fs_error(sb, "Odd directory size");
			dir->i_size = (dir->i_size + sbi->cluster_size - 1)
				& ~((loff_t)sbi->cluster_size - 1);
		}
+6 −1
Original line number Diff line number Diff line
@@ -17,6 +17,10 @@
#define VFAT_SFN_CREATE_WIN95	0x0100 /* emulate win95 rule for create */
#define VFAT_SFN_CREATE_WINNT	0x0200 /* emulate winnt rule for create */

#define FAT_ERRORS_CONT		1      /* ignore error and continue */
#define FAT_ERRORS_PANIC	2      /* panic on error */
#define FAT_ERRORS_RO		3      /* remount r/o on error */

struct fat_mount_options {
	uid_t fs_uid;
	gid_t fs_gid;
@@ -26,6 +30,7 @@ struct fat_mount_options {
	char *iocharset;          /* Charset used for filename input/display */
	unsigned short shortname; /* flags for shortname display/create rule */
	unsigned char name_check; /* r = relaxed, n = normal, s = strict */
	unsigned char errors;	  /* On error: continue, panic, remount-ro */
	unsigned short allow_utime;/* permission for setting the [am]time */
	unsigned quiet:1,         /* set = fake successful chmods and chowns */
		 showexec:1,      /* set = only set x bit for com/exe/bat */
@@ -310,7 +315,7 @@ extern int fat_fill_super(struct super_block *sb, void *data, int silent,
extern int fat_flush_inodes(struct super_block *sb, struct inode *i1,
		            struct inode *i2);
/* fat/misc.c */
extern void fat_fs_panic(struct super_block *s, const char *fmt, ...)
extern void fat_fs_error(struct super_block *s, const char *fmt, ...)
	__attribute__ ((format (printf, 2, 3))) __cold;
extern void fat_clusters_flush(struct super_block *sb);
extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster);
+2 −2
Original line number Diff line number Diff line
@@ -345,7 +345,7 @@ int fat_ent_read(struct inode *inode, struct fat_entry *fatent, int entry)

	if (entry < FAT_START_ENT || sbi->max_cluster <= entry) {
		fatent_brelse(fatent);
		fat_fs_panic(sb, "invalid access to FAT (entry 0x%08x)", entry);
		fat_fs_error(sb, "invalid access to FAT (entry 0x%08x)", entry);
		return -EIO;
	}

@@ -557,7 +557,7 @@ int fat_free_clusters(struct inode *inode, int cluster)
			err = cluster;
			goto error;
		} else if (cluster == FAT_ENT_FREE) {
			fat_fs_panic(sb, "%s: deleting FAT entry beyond EOF",
			fat_fs_error(sb, "%s: deleting FAT entry beyond EOF",
				     __func__);
			err = -EIO;
			goto error;
Loading