Message ID | 8ac207c64e2917d7980570e6c9f696e234baf070.1602273837.git.josef@toxicpanda.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | New rescue mount options | expand |
On 2020/10/10 上午4:07, Josef Bacik wrote: > 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. > > Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reveiwed-by: Qu Wenruo <wqu@suse.com> Thanks, Qu > --- > fs/btrfs/sysfs.c | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c > index 279d9262b676..5c558e65c1ba 100644 > --- a/fs/btrfs/sysfs.c > +++ b/fs/btrfs/sysfs.c > @@ -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 > }; > >
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 279d9262b676..5c558e65c1ba 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -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 };
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. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/btrfs/sysfs.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)