[PATCH 5/5] FAT: add 'notify' mount option
From: Denis Karpov
Date: Thu Jun 11 2009 - 08:26:00 EST
Implement FAT fs mount option 'notify'. The effect of this option
is that user space is notified of file system's run-rime errors
with an uevent.
The uevent is associated with fs kobject's attribute value 'fs_fault'
(/sys/fs/fat/<partition>/fs_fault).
Signed-off-by: Denis Karpov <ext-denis.2.karpov@xxxxxxxxx>
---
Documentation/filesystems/vfat.txt | 4 ++++
fs/fat/fat.h | 3 ++-
fs/fat/inode.c | 11 +++++++++--
fs/fat/misc.c | 4 ++--
4 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/Documentation/filesystems/vfat.txt b/Documentation/filesystems/vfat.txt
index 3a5ddc9..16cfcb3 100644
--- a/Documentation/filesystems/vfat.txt
+++ b/Documentation/filesystems/vfat.txt
@@ -132,6 +132,10 @@ 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.
+notify -- notify userspace of filesystem faults using sysfs interface
+ /sys/fs/fat/<partition>/fs_fault and uevent
+ (KOBJ_CHANGE, uevent's environment variable FS_FAULT=1).
+
<bool>: 0,1,yes,no,true,false
TODO
diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index ebf4c62..84030ac 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -39,7 +39,8 @@ struct fat_mount_options {
nocase:1, /* Does this need case conversion? 0=need case conversion*/
usefree:1, /* Use free_clusters for FAT32 */
tz_utc:1, /* Filesystem timestamps are in UTC */
- rodir:1; /* allow ATTR_RO for directory */
+ rodir:1, /* allow ATTR_RO for directory */
+ err_notify:1; /* Notify userspace on fs errors */
};
#define FAT_HASH_BITS 8
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index b1a0c8d..559ccea 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -844,6 +844,8 @@ static int fat_show_options(struct seq_file *m, struct vfsmount *mnt)
seq_puts(m, ",flush");
if (opts->tz_utc)
seq_puts(m, ",tz=UTC");
+ if (opts->err_notify)
+ seq_puts(m, ",notify");
return 0;
}
@@ -856,7 +858,7 @@ enum {
Opt_charset, Opt_shortname_lower, Opt_shortname_win95,
Opt_shortname_winnt, Opt_shortname_mixed, Opt_utf8_no, Opt_utf8_yes,
Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes,
- Opt_obsolate, Opt_flush, Opt_tz_utc, Opt_rodir, Opt_err,
+ Opt_obsolate, Opt_flush, Opt_tz_utc, Opt_rodir, Opt_err_notify, Opt_err,
};
static const match_table_t fat_tokens = {
@@ -892,6 +894,7 @@ static const match_table_t fat_tokens = {
{Opt_obsolate, "posix"},
{Opt_flush, "flush"},
{Opt_tz_utc, "tz=UTC"},
+ {Opt_err_notify, "notify"},
{Opt_err, NULL},
};
static const match_table_t msdos_tokens = {
@@ -961,6 +964,7 @@ static int parse_options(char *options, int is_vfat, int silent, int *debug,
opts->numtail = 1;
opts->usefree = opts->nocase = 0;
opts->tz_utc = 0;
+ opts->err_notify = 0;
*debug = 0;
if (!options)
@@ -1053,6 +1057,9 @@ static int parse_options(char *options, int is_vfat, int silent, int *debug,
case Opt_tz_utc:
opts->tz_utc = 1;
break;
+ case Opt_err_notify:
+ opts->err_notify = 1;
+ break;
/* msdos specific */
case Opt_dots:
@@ -1226,7 +1233,7 @@ static struct fat_attr fat_attr_##_name = { \
#define ATTR_LIST(name) (&fat_attr_ ##name.attr)
-FAT_SBI_RO_ATTR(fs_fault);
+FAT_SBI_RO_ATTR_NOTIFY(fs_fault);
static struct attribute *fat_attrs[] = {
ATTR_LIST(fs_fault),
diff --git a/fs/fat/misc.c b/fs/fat/misc.c
index 8cdefd8..7a84104 100644
--- a/fs/fat/misc.c
+++ b/fs/fat/misc.c
@@ -35,7 +35,7 @@ void fat_fs_error(struct super_block *s, const char *function,
printk(KERN_ERR " File system has been set read-only\n");
}
- FAT_FS_FAULT_SET(sbi, 1, 0);
+ FAT_FS_FAULT_SET(sbi, 1, sbi->options.err_notify);
}
EXPORT_SYMBOL_GPL(fat_fs_error);
@@ -58,7 +58,7 @@ void fat_fs_warning(struct super_block *s, const char * function,
printk("\n");
va_end(args);
- FAT_FS_FAULT_SET(sbi, 1, 0);
+ FAT_FS_FAULT_SET(sbi, 1, sbi->options.err_notify);
}
EXPORT_SYMBOL_GPL(fat_fs_warning);
--
1.6.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/