OSDN Git Service

btrfs: sysfs: export supported rescue= mount options
authorJosef Bacik <josef@toxicpanda.com>
Fri, 16 Oct 2020 15:29:15 +0000 (11:29 -0400)
committerDavid Sterba <dsterba@suse.com>
Tue, 8 Dec 2020 14:53:40 +0000 (15:53 +0100)
We're going to be adding a variety of different rescue options, we
should advertise which ones we support to make user spaces life easier
in the future.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/sysfs.c

index 8424f5d..8f0462d 100644 (file)
@@ -329,10 +329,32 @@ static ssize_t send_stream_version_show(struct kobject *kobj,
 }
 BTRFS_ATTR(static_feature, send_stream_version, send_stream_version_show);
 
+static const char *rescue_opts[] = {
+       "usebackuproot",
+       "nologreplay",
+};
+
+static ssize_t supported_rescue_options_show(struct kobject *kobj,
+                                            struct kobj_attribute *a,
+                                            char *buf)
+{
+       ssize_t ret = 0;
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(rescue_opts); i++)
+               ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s%s",
+                                (i ? " " : ""), rescue_opts[i]);
+       ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\n");
+       return ret;
+}
+BTRFS_ATTR(static_feature, supported_rescue_options,
+          supported_rescue_options_show);
+
 static struct attribute *btrfs_supported_static_feature_attrs[] = {
        BTRFS_ATTR_PTR(static_feature, rmdir_subvol),
        BTRFS_ATTR_PTR(static_feature, supported_checksums),
        BTRFS_ATTR_PTR(static_feature, send_stream_version),
+       BTRFS_ATTR_PTR(static_feature, supported_rescue_options),
        NULL
 };