From: Anand Jain <anand.jain@oracle.com> Signed-off-by: Anand Jain <anand.jain@oracle.com> --- fs/btrfs/ctree.h | 10 ++++++++++ fs/btrfs/ioctl.c | 30 ++++++++++++++++++++++++++++++ fs/btrfs/ioctl.h | 2 ++ 3 files changed, 42 insertions(+), 0 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 4bab807..eff506f 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2583,6 +2583,16 @@ BTRFS_SETGET_STACK_FUNCS(super_csum_type, struct btrfs_super_block, BTRFS_SETGET_STACK_FUNCS(super_cache_generation, struct btrfs_super_block, cache_generation, 64); +static inline char * btrfs_super_label(struct btrfs_super_block *s) +{ + return s->label; +} +static inline void btrfs_set_super_label(struct btrfs_super_block *s, + char *val) +{ + memcpy(s->label,val,BTRFS_LABEL_SIZE); +} + static inline int btrfs_super_csum_size(struct btrfs_super_block *s) { int t = btrfs_super_csum_type(s); diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 7bb7556..b472942 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3687,6 +3687,32 @@ out: return ret; } +static int btrfs_ioctl_get_label(struct btrfs_root *root, void __user *arg) +{ + char *label; + label = btrfs_super_label(root->fs_info->super_copy); + if (copy_to_user(arg, label, BTRFS_LABEL_SIZE)) + return -EFAULT; + return 0; +} + +static int btrfs_ioctl_set_label(struct btrfs_root *root, void __user *arg) +{ + struct btrfs_trans_handle *trans; + char label[BTRFS_LABEL_SIZE+1]; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + if (copy_from_user(label, arg, BTRFS_LABEL_SIZE)) + return -EFAULT; + label[BTRFS_LABEL_SIZE] = ''\0''; + trans = btrfs_start_transaction(root, 1); + btrfs_set_super_label(root->fs_info->super_copy, label); + btrfs_commit_transaction(trans, root); + + return 0; +} + long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -3785,6 +3811,10 @@ long btrfs_ioctl(struct file *file, unsigned int return btrfs_ioctl_qgroup_create(root, argp); case BTRFS_IOC_QGROUP_LIMIT: return btrfs_ioctl_qgroup_limit(root, argp); + case BTRFS_IOC_GET_LABEL: + return btrfs_ioctl_get_label(root, argp); + case BTRFS_IOC_SET_LABEL: + return btrfs_ioctl_set_label(root, argp); } return -ENOTTY; diff --git a/fs/btrfs/ioctl.h b/fs/btrfs/ioctl.h index 731e287..0c60fcb 100644 --- a/fs/btrfs/ioctl.h +++ b/fs/btrfs/ioctl.h @@ -453,4 +453,6 @@ struct btrfs_ioctl_send_args { struct btrfs_ioctl_qgroup_limit_args) #define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, \ struct btrfs_ioctl_get_dev_stats) +#define BTRFS_IOC_GET_LABEL _IOR(BTRFS_IOCTL_MAGIC, 53, __u64) +#define BTRFS_IOC_SET_LABEL _IOW(BTRFS_IOCTL_MAGIC, 54, __u64) #endif -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Anand Jain <anand.jain@oracle.com> Signed-off-by: Anand Jain <anand.jain@oracle.com> --- btrfslabel.c | 90 ++++++++++++++++++++++++++++++++++++++-------------------- ioctl.h | 2 + utils.h | 1 + 3 files changed, 62 insertions(+), 31 deletions(-) diff --git a/btrfslabel.c b/btrfslabel.c index bf73802..3676db0 100644 --- a/btrfslabel.c +++ b/btrfslabel.c @@ -51,6 +51,10 @@ static void change_label_unmounted(char *dev, char *nLabel) struct btrfs_root *root; struct btrfs_trans_handle *trans; + if(check_mounted(dev)) { + fprintf(stderr, "ERROR: dev is mounted, use mount point\n"); + return; + } /* Open the super_block at the default location * and as read-write. */ @@ -67,10 +71,57 @@ static void change_label_unmounted(char *dev, char *nLabel) close_ctree(root); } +static void set_fs_label(char *mnt, char *label) +{ + int fd, e=0; + char fslabel[BTRFS_LABEL_SIZE+1]; + + memset(fslabel, 0, BTRFS_LABEL_SIZE+1); + strncpy(fslabel,label,BTRFS_LABEL_SIZE); + + fd = open(mnt, O_RDONLY| O_NOATIME); + if (fd < 0) { + fprintf(stderr, "ERROR: Open %s failed\n", mnt); + return; + } + + if(ioctl(fd, BTRFS_IOC_SET_LABEL, fslabel) < 0) { + e = errno; + fprintf(stderr, "ERROR: get label failed, %s\n", + strerror(e)); + } + close(fd); +} + +static void get_fs_label(char *path) +{ + int fd, e=0; + char label[BTRFS_LABEL_SIZE+1]; + + fd = open(path, O_RDONLY| O_NOATIME); + if (fd < 0) { + fprintf(stderr, "ERROR: Open %s failed\n", path); + return; + } + + if(ioctl(fd, BTRFS_IOC_GET_LABEL, label) < 0) { + e = errno; + fprintf(stderr, "ERROR: get label failed, %s\n", + strerror(e)); + return; + } + printf("%s\n",label); + close(fd); +} + static void get_label_unmounted(char *dev) { struct btrfs_root *root; + if(check_mounted(dev)) { + fprintf(stderr, "ERROR: dev is mounted, use mount point\n"); + return; + } /* Open the super_block at the default location * and as read-only. */ @@ -84,41 +135,18 @@ static void get_label_unmounted(char *dev) int get_label(char *btrfs_dev) { - - int ret; - ret = check_mounted(btrfs_dev); - if (ret < 0) - { - fprintf(stderr, "FATAL: error checking %s mount status\n", btrfs_dev); - return -1; - } - - if(ret != 0) - { - fprintf(stderr, "FATAL: the filesystem has to be unmounted\n"); - return -2; - } - get_label_unmounted(btrfs_dev); + if(is_existing_blk_or_reg_file(btrfs_dev)) + get_label_unmounted(btrfs_dev); + else + get_fs_label(btrfs_dev); return 0; } - int set_label(char *btrfs_dev, char *nLabel) { - - int ret; - ret = check_mounted(btrfs_dev); - if (ret < 0) - { - fprintf(stderr, "FATAL: error checking %s mount status\n", btrfs_dev); - return -1; - } - - if(ret != 0) - { - fprintf(stderr, "FATAL: the filesystem has to be unmounted\n"); - return -2; - } - change_label_unmounted(btrfs_dev, nLabel); + if(is_existing_blk_or_reg_file(btrfs_dev)) + change_label_unmounted(btrfs_dev, nLabel); + else + set_fs_label(btrfs_dev, nLabel); return 0; } diff --git a/ioctl.h b/ioctl.h index d6f3d07..7e1dcda 100644 --- a/ioctl.h +++ b/ioctl.h @@ -370,4 +370,6 @@ struct btrfs_ioctl_clone_range_args { struct btrfs_ioctl_received_subvol_args) #define BTRFS_IOC_SEND _IOW(BTRFS_IOCTL_MAGIC, 38, struct btrfs_ioctl_send_args) +#define BTRFS_IOC_GET_LABEL _IOR(BTRFS_IOCTL_MAGIC, 53, __u64) +#define BTRFS_IOC_SET_LABEL _IOW(BTRFS_IOCTL_MAGIC, 54, __u64) #endif diff --git a/utils.h b/utils.h index c147c12..ba088fe 100644 --- a/utils.h +++ b/utils.h @@ -48,4 +48,5 @@ int check_label(char *input); int get_mountpt(char *dev, char *mntpt, size_t size); int btrfs_scan_block_devices(int run_ioctl); +int is_existing_blk_or_reg_file(const char* filename); #endif -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Anand, I have posted a patch for set label back to last year, which can be found at: https://patchwork.kernel.org/patch/1124642/ Besides that, we have discussed to use 50 as the ioctl(2) number at that time. task assignment in our wiki page: https://btrfs.wiki.kernel.org/index.php/Project_ideas#Set.2Fchange_file_system_label Thanks, -Jeff On 08/29/12 16:46, Anand jain wrote:> From: Anand Jain <anand.jain@oracle.com> > > Signed-off-by: Anand Jain <anand.jain@oracle.com> > --- > fs/btrfs/ctree.h | 10 ++++++++++ > fs/btrfs/ioctl.c | 30 ++++++++++++++++++++++++++++++ > fs/btrfs/ioctl.h | 2 ++ > 3 files changed, 42 insertions(+), 0 deletions(-) > > diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h > index 4bab807..eff506f 100644 > --- a/fs/btrfs/ctree.h > +++ b/fs/btrfs/ctree.h > @@ -2583,6 +2583,16 @@ BTRFS_SETGET_STACK_FUNCS(super_csum_type, struct btrfs_super_block, > BTRFS_SETGET_STACK_FUNCS(super_cache_generation, struct btrfs_super_block, > cache_generation, 64); > > +static inline char * btrfs_super_label(struct btrfs_super_block *s) > +{ > + return s->label; > +} > +static inline void btrfs_set_super_label(struct btrfs_super_block *s, > + char *val) > +{ > + memcpy(s->label,val,BTRFS_LABEL_SIZE); > +} > + > static inline int btrfs_super_csum_size(struct btrfs_super_block *s) > { > int t = btrfs_super_csum_type(s); > diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c > index 7bb7556..b472942 100644 > --- a/fs/btrfs/ioctl.c > +++ b/fs/btrfs/ioctl.c > @@ -3687,6 +3687,32 @@ out: > return ret; > } > > +static int btrfs_ioctl_get_label(struct btrfs_root *root, void __user *arg) > +{ > + char *label; > + label = btrfs_super_label(root->fs_info->super_copy); > + if (copy_to_user(arg, label, BTRFS_LABEL_SIZE)) > + return -EFAULT; > + return 0; > +} > + > +static int btrfs_ioctl_set_label(struct btrfs_root *root, void __user *arg) > +{ > + struct btrfs_trans_handle *trans; > + char label[BTRFS_LABEL_SIZE+1]; > + > + if (!capable(CAP_SYS_ADMIN)) > + return -EPERM; > + if (copy_from_user(label, arg, BTRFS_LABEL_SIZE)) > + return -EFAULT; > + label[BTRFS_LABEL_SIZE] = ''\0''; > + trans = btrfs_start_transaction(root, 1); > + btrfs_set_super_label(root->fs_info->super_copy, label); > + btrfs_commit_transaction(trans, root); > + > + return 0; > +} > + > long btrfs_ioctl(struct file *file, unsigned int > cmd, unsigned long arg) > { > @@ -3785,6 +3811,10 @@ long btrfs_ioctl(struct file *file, unsigned int > return btrfs_ioctl_qgroup_create(root, argp); > case BTRFS_IOC_QGROUP_LIMIT: > return btrfs_ioctl_qgroup_limit(root, argp); > + case BTRFS_IOC_GET_LABEL: > + return btrfs_ioctl_get_label(root, argp); > + case BTRFS_IOC_SET_LABEL: > + return btrfs_ioctl_set_label(root, argp); > } > > return -ENOTTY; > diff --git a/fs/btrfs/ioctl.h b/fs/btrfs/ioctl.h > index 731e287..0c60fcb 100644 > --- a/fs/btrfs/ioctl.h > +++ b/fs/btrfs/ioctl.h > @@ -453,4 +453,6 @@ struct btrfs_ioctl_send_args { > struct btrfs_ioctl_qgroup_limit_args) > #define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, \ > struct btrfs_ioctl_get_dev_stats) > +#define BTRFS_IOC_GET_LABEL _IOR(BTRFS_IOCTL_MAGIC, 53, __u64) > +#define BTRFS_IOC_SET_LABEL _IOW(BTRFS_IOCTL_MAGIC, 54, __u64) > #endif-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Ah. I missed that. Thanks. So should use your original patch. -Anand On 29/08/12 17:00, Jie Liu wrote:> Hi Anand, > > I have posted a patch for set label back to last year, which can be > found at: > https://patchwork.kernel.org/patch/1124642/ > > Besides that, we have discussed to use 50 as the ioctl(2) number at > that time. > > task assignment in our wiki page: > https://btrfs.wiki.kernel.org/index.php/Project_ideas#Set.2Fchange_file_system_label > > Thanks, > -Jeff > > On 08/29/12 16:46, Anand jain wrote: >> From: Anand Jain<anand.jain@oracle.com> >> >> Signed-off-by: Anand Jain<anand.jain@oracle.com> >> --- >> fs/btrfs/ctree.h | 10 ++++++++++ >> fs/btrfs/ioctl.c | 30 ++++++++++++++++++++++++++++++ >> fs/btrfs/ioctl.h | 2 ++ >> 3 files changed, 42 insertions(+), 0 deletions(-) >> >> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h >> index 4bab807..eff506f 100644 >> --- a/fs/btrfs/ctree.h >> +++ b/fs/btrfs/ctree.h >> @@ -2583,6 +2583,16 @@ BTRFS_SETGET_STACK_FUNCS(super_csum_type, struct btrfs_super_block, >> BTRFS_SETGET_STACK_FUNCS(super_cache_generation, struct btrfs_super_block, >> cache_generation, 64); >> >> +static inline char * btrfs_super_label(struct btrfs_super_block *s) >> +{ >> + return s->label; >> +} >> +static inline void btrfs_set_super_label(struct btrfs_super_block *s, >> + char *val) >> +{ >> + memcpy(s->label,val,BTRFS_LABEL_SIZE); >> +} >> + >> static inline int btrfs_super_csum_size(struct btrfs_super_block *s) >> { >> int t = btrfs_super_csum_type(s); >> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c >> index 7bb7556..b472942 100644 >> --- a/fs/btrfs/ioctl.c >> +++ b/fs/btrfs/ioctl.c >> @@ -3687,6 +3687,32 @@ out: >> return ret; >> } >> >> +static int btrfs_ioctl_get_label(struct btrfs_root *root, void __user *arg) >> +{ >> + char *label; >> + label = btrfs_super_label(root->fs_info->super_copy); >> + if (copy_to_user(arg, label, BTRFS_LABEL_SIZE)) >> + return -EFAULT; >> + return 0; >> +} >> + >> +static int btrfs_ioctl_set_label(struct btrfs_root *root, void __user *arg) >> +{ >> + struct btrfs_trans_handle *trans; >> + char label[BTRFS_LABEL_SIZE+1]; >> + >> + if (!capable(CAP_SYS_ADMIN)) >> + return -EPERM; >> + if (copy_from_user(label, arg, BTRFS_LABEL_SIZE)) >> + return -EFAULT; >> + label[BTRFS_LABEL_SIZE] = ''\0''; >> + trans = btrfs_start_transaction(root, 1); >> + btrfs_set_super_label(root->fs_info->super_copy, label); >> + btrfs_commit_transaction(trans, root); >> + >> + return 0; >> +} >> + >> long btrfs_ioctl(struct file *file, unsigned int >> cmd, unsigned long arg) >> { >> @@ -3785,6 +3811,10 @@ long btrfs_ioctl(struct file *file, unsigned int >> return btrfs_ioctl_qgroup_create(root, argp); >> case BTRFS_IOC_QGROUP_LIMIT: >> return btrfs_ioctl_qgroup_limit(root, argp); >> + case BTRFS_IOC_GET_LABEL: >> + return btrfs_ioctl_get_label(root, argp); >> + case BTRFS_IOC_SET_LABEL: >> + return btrfs_ioctl_set_label(root, argp); >> } >> >> return -ENOTTY; >> diff --git a/fs/btrfs/ioctl.h b/fs/btrfs/ioctl.h >> index 731e287..0c60fcb 100644 >> --- a/fs/btrfs/ioctl.h >> +++ b/fs/btrfs/ioctl.h >> @@ -453,4 +453,6 @@ struct btrfs_ioctl_send_args { >> struct btrfs_ioctl_qgroup_limit_args) >> #define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, \ >> struct btrfs_ioctl_get_dev_stats) >> +#define BTRFS_IOC_GET_LABEL _IOR(BTRFS_IOCTL_MAGIC, 53, __u64) >> +#define BTRFS_IOC_SET_LABEL _IOW(BTRFS_IOCTL_MAGIC, 54, __u64) >> #endif > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff, I don''t find the get label ioctl part unless I am missing something. Any idea? Thxs, -Anand On 30/08/12 09:54, Anand Jain wrote:> > Ah. I missed that. Thanks. > So should use your original patch. > > -Anand > > On 29/08/12 17:00, Jie Liu wrote: >> Hi Anand, >> >> I have posted a patch for set label back to last year, which can be >> found at: >> https://patchwork.kernel.org/patch/1124642/ >> >> Besides that, we have discussed to use 50 as the ioctl(2) number at >> that time. >> >> task assignment in our wiki page: >> https://btrfs.wiki.kernel.org/index.php/Project_ideas#Set.2Fchange_file_system_label >> >> Thanks, >> -Jeff >> >> On 08/29/12 16:46, Anand jain wrote: >>> From: Anand Jain<anand.jain@oracle.com> >>> >>> Signed-off-by: Anand Jain<anand.jain@oracle.com> >>> --- >>> fs/btrfs/ctree.h | 10 ++++++++++ >>> fs/btrfs/ioctl.c | 30 ++++++++++++++++++++++++++++++ >>> fs/btrfs/ioctl.h | 2 ++ >>> 3 files changed, 42 insertions(+), 0 deletions(-) >>> >>> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h >>> index 4bab807..eff506f 100644 >>> --- a/fs/btrfs/ctree.h >>> +++ b/fs/btrfs/ctree.h >>> @@ -2583,6 +2583,16 @@ BTRFS_SETGET_STACK_FUNCS(super_csum_type, struct btrfs_super_block, >>> BTRFS_SETGET_STACK_FUNCS(super_cache_generation, struct btrfs_super_block, >>> cache_generation, 64); >>> >>> +static inline char * btrfs_super_label(struct btrfs_super_block *s) >>> +{ >>> + return s->label; >>> +} >>> +static inline void btrfs_set_super_label(struct btrfs_super_block *s, >>> + char *val) >>> +{ >>> + memcpy(s->label,val,BTRFS_LABEL_SIZE); >>> +} >>> + >>> static inline int btrfs_super_csum_size(struct btrfs_super_block *s) >>> { >>> int t = btrfs_super_csum_type(s); >>> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c >>> index 7bb7556..b472942 100644 >>> --- a/fs/btrfs/ioctl.c >>> +++ b/fs/btrfs/ioctl.c >>> @@ -3687,6 +3687,32 @@ out: >>> return ret; >>> } >>> >>> +static int btrfs_ioctl_get_label(struct btrfs_root *root, void __user *arg) >>> +{ >>> + char *label; >>> + label = btrfs_super_label(root->fs_info->super_copy); >>> + if (copy_to_user(arg, label, BTRFS_LABEL_SIZE)) >>> + return -EFAULT; >>> + return 0; >>> +} >>> + >>> +static int btrfs_ioctl_set_label(struct btrfs_root *root, void __user *arg) >>> +{ >>> + struct btrfs_trans_handle *trans; >>> + char label[BTRFS_LABEL_SIZE+1]; >>> + >>> + if (!capable(CAP_SYS_ADMIN)) >>> + return -EPERM; >>> + if (copy_from_user(label, arg, BTRFS_LABEL_SIZE)) >>> + return -EFAULT; >>> + label[BTRFS_LABEL_SIZE] = ''\0''; >>> + trans = btrfs_start_transaction(root, 1); >>> + btrfs_set_super_label(root->fs_info->super_copy, label); >>> + btrfs_commit_transaction(trans, root); >>> + >>> + return 0; >>> +} >>> + >>> long btrfs_ioctl(struct file *file, unsigned int >>> cmd, unsigned long arg) >>> { >>> @@ -3785,6 +3811,10 @@ long btrfs_ioctl(struct file *file, unsigned int >>> return btrfs_ioctl_qgroup_create(root, argp); >>> case BTRFS_IOC_QGROUP_LIMIT: >>> return btrfs_ioctl_qgroup_limit(root, argp); >>> + case BTRFS_IOC_GET_LABEL: >>> + return btrfs_ioctl_get_label(root, argp); >>> + case BTRFS_IOC_SET_LABEL: >>> + return btrfs_ioctl_set_label(root, argp); >>> } >>> >>> return -ENOTTY; >>> diff --git a/fs/btrfs/ioctl.h b/fs/btrfs/ioctl.h >>> index 731e287..0c60fcb 100644 >>> --- a/fs/btrfs/ioctl.h >>> +++ b/fs/btrfs/ioctl.h >>> @@ -453,4 +453,6 @@ struct btrfs_ioctl_send_args { >>> struct btrfs_ioctl_qgroup_limit_args) >>> #define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, \ >>> struct btrfs_ioctl_get_dev_stats) >>> +#define BTRFS_IOC_GET_LABEL _IOR(BTRFS_IOCTL_MAGIC, 53, __u64) >>> +#define BTRFS_IOC_SET_LABEL _IOW(BTRFS_IOCTL_MAGIC, 54, __u64) >>> #endif >> >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 08/30/12 13:44, Anand Jain wrote:> > Jeff, > > I don''t find the get label ioctl part unless I am missing something. > Any idea?Yes, you''re right, I have not post the get label at that time. The original patch could be revised with this support easily. How about using one structure and one ioctl number for both of them? i.e, #define BTRFS_IOC_FSLABEL_CTL _IOW(BTRFS_IOCTL_MAGIC, 50, struct btrfs_ioctl_fslabel_ctl_args) #define BTRFS_FSLABEL_CTL_GET 0 #define BTRFS_FSLABEL_CTL_SET 1 struct btrfs_ioctl_fslabel_ctl_args { char label[BTRFS_LABEL_SIZE]; u32 flags; }; so that get/set label from user tools would looks like, struct btrfs_ioctl_fslabel_ctl_args arg; arg.flags = BTRFS_FSLABEL_CTL_GET; /* get label */ or arg.flags = BTRFS_FSLABEL_CTL_SET; /* set label */ .... ioctl(fd, BTRFS_FSLABEL_CTL, &arg); Thanks, -Jeff> > Thxs, -Anand > > > On 30/08/12 09:54, Anand Jain wrote: >> >> Ah. I missed that. Thanks. >> So should use your original patch. >> >> -Anand >> >> On 29/08/12 17:00, Jie Liu wrote: >>> Hi Anand, >>> >>> I have posted a patch for set label back to last year, which can be >>> found at: >>> https://patchwork.kernel.org/patch/1124642/ >>> >>> Besides that, we have discussed to use 50 as the ioctl(2) number at >>> that time. >>> >>> task assignment in our wiki page: >>> https://btrfs.wiki.kernel.org/index.php/Project_ideas#Set.2Fchange_file_system_label >>> >>> >>> Thanks, >>> -Jeff >>> >>> On 08/29/12 16:46, Anand jain wrote: >>>> From: Anand Jain<anand.jain@oracle.com> >>>> >>>> Signed-off-by: Anand Jain<anand.jain@oracle.com> >>>> --- >>>> fs/btrfs/ctree.h | 10 ++++++++++ >>>> fs/btrfs/ioctl.c | 30 ++++++++++++++++++++++++++++++ >>>> fs/btrfs/ioctl.h | 2 ++ >>>> 3 files changed, 42 insertions(+), 0 deletions(-) >>>> >>>> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h >>>> index 4bab807..eff506f 100644 >>>> --- a/fs/btrfs/ctree.h >>>> +++ b/fs/btrfs/ctree.h >>>> @@ -2583,6 +2583,16 @@ BTRFS_SETGET_STACK_FUNCS(super_csum_type, >>>> struct btrfs_super_block, >>>> BTRFS_SETGET_STACK_FUNCS(super_cache_generation, struct >>>> btrfs_super_block, >>>> cache_generation, 64); >>>> >>>> +static inline char * btrfs_super_label(struct btrfs_super_block *s) >>>> +{ >>>> + return s->label; >>>> +} >>>> +static inline void btrfs_set_super_label(struct btrfs_super_block *s, >>>> + char *val) >>>> +{ >>>> + memcpy(s->label,val,BTRFS_LABEL_SIZE); >>>> +} >>>> + >>>> static inline int btrfs_super_csum_size(struct btrfs_super_block *s) >>>> { >>>> int t = btrfs_super_csum_type(s); >>>> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c >>>> index 7bb7556..b472942 100644 >>>> --- a/fs/btrfs/ioctl.c >>>> +++ b/fs/btrfs/ioctl.c >>>> @@ -3687,6 +3687,32 @@ out: >>>> return ret; >>>> } >>>> >>>> +static int btrfs_ioctl_get_label(struct btrfs_root *root, void >>>> __user *arg) >>>> +{ >>>> + char *label; >>>> + label = btrfs_super_label(root->fs_info->super_copy); >>>> + if (copy_to_user(arg, label, BTRFS_LABEL_SIZE)) >>>> + return -EFAULT; >>>> + return 0; >>>> +} >>>> + >>>> +static int btrfs_ioctl_set_label(struct btrfs_root *root, void >>>> __user *arg) >>>> +{ >>>> + struct btrfs_trans_handle *trans; >>>> + char label[BTRFS_LABEL_SIZE+1]; >>>> + >>>> + if (!capable(CAP_SYS_ADMIN)) >>>> + return -EPERM; >>>> + if (copy_from_user(label, arg, BTRFS_LABEL_SIZE)) >>>> + return -EFAULT; >>>> + label[BTRFS_LABEL_SIZE] = ''\0''; >>>> + trans = btrfs_start_transaction(root, 1); >>>> + btrfs_set_super_label(root->fs_info->super_copy, label); >>>> + btrfs_commit_transaction(trans, root); >>>> + >>>> + return 0; >>>> +} >>>> + >>>> long btrfs_ioctl(struct file *file, unsigned int >>>> cmd, unsigned long arg) >>>> { >>>> @@ -3785,6 +3811,10 @@ long btrfs_ioctl(struct file *file, unsigned >>>> int >>>> return btrfs_ioctl_qgroup_create(root, argp); >>>> case BTRFS_IOC_QGROUP_LIMIT: >>>> return btrfs_ioctl_qgroup_limit(root, argp); >>>> + case BTRFS_IOC_GET_LABEL: >>>> + return btrfs_ioctl_get_label(root, argp); >>>> + case BTRFS_IOC_SET_LABEL: >>>> + return btrfs_ioctl_set_label(root, argp); >>>> } >>>> >>>> return -ENOTTY; >>>> diff --git a/fs/btrfs/ioctl.h b/fs/btrfs/ioctl.h >>>> index 731e287..0c60fcb 100644 >>>> --- a/fs/btrfs/ioctl.h >>>> +++ b/fs/btrfs/ioctl.h >>>> @@ -453,4 +453,6 @@ struct btrfs_ioctl_send_args { >>>> struct btrfs_ioctl_qgroup_limit_args) >>>> #define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, \ >>>> struct btrfs_ioctl_get_dev_stats) >>>> +#define BTRFS_IOC_GET_LABEL _IOR(BTRFS_IOCTL_MAGIC, 53, __u64) >>>> +#define BTRFS_IOC_SET_LABEL _IOW(BTRFS_IOCTL_MAGIC, 54, __u64) >>>> #endif >>> >>> >>> -- >>> To unsubscribe from this list: send the line "unsubscribe >>> linux-btrfs" in >>> the body of a message to majordomo@vger.kernel.org >>> More majordomo info at http://vger.kernel.org/majordomo-info.html >> -- >> To unsubscribe from this list: send the line "unsubscribe >> linux-btrfs" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 08/30/12 13:55, Jie Liu wrote:> On 08/30/12 13:44, Anand Jain wrote: >> Jeff, >> >> I don''t find the get label ioctl part unless I am missing something. >> Any idea?Sorry, I took for granted that this patch has already been merged last year. :( To honor your efforts, I''d like to re-send a revised version with set label only, if other folks like it, you can proceed to add the get label routine based on it. Are you happy? :) Thanks, -Jeff> Yes, you''re right, I have not post the get label at that time. > > The original patch could be revised with this support easily. > How about using one structure and one ioctl number for both of them? i.e, > > #define BTRFS_IOC_FSLABEL_CTL _IOW(BTRFS_IOCTL_MAGIC, 50, struct > btrfs_ioctl_fslabel_ctl_args) > > #define BTRFS_FSLABEL_CTL_GET 0 > #define BTRFS_FSLABEL_CTL_SET 1 > > struct btrfs_ioctl_fslabel_ctl_args { > char label[BTRFS_LABEL_SIZE]; > u32 flags; > }; > > so that get/set label from user tools would looks like, > > struct btrfs_ioctl_fslabel_ctl_args arg; > arg.flags = BTRFS_FSLABEL_CTL_GET; /* get label */ > or > arg.flags = BTRFS_FSLABEL_CTL_SET; /* set label */ > .... > > ioctl(fd, BTRFS_FSLABEL_CTL, &arg); > > > Thanks, > -Jeff >> Thxs, -Anand >> >> >> On 30/08/12 09:54, Anand Jain wrote: >>> Ah. I missed that. Thanks. >>> So should use your original patch. >>> >>> -Anand >>> >>> On 29/08/12 17:00, Jie Liu wrote: >>>> Hi Anand, >>>> >>>> I have posted a patch for set label back to last year, which can be >>>> found at: >>>> https://patchwork.kernel.org/patch/1124642/ >>>> >>>> Besides that, we have discussed to use 50 as the ioctl(2) number at >>>> that time. >>>> >>>> task assignment in our wiki page: >>>> https://btrfs.wiki.kernel.org/index.php/Project_ideas#Set.2Fchange_file_system_label >>>> >>>> >>>> Thanks, >>>> -Jeff >>>> >>>> On 08/29/12 16:46, Anand jain wrote: >>>>> From: Anand Jain<anand.jain@oracle.com> >>>>> >>>>> Signed-off-by: Anand Jain<anand.jain@oracle.com> >>>>> --- >>>>> fs/btrfs/ctree.h | 10 ++++++++++ >>>>> fs/btrfs/ioctl.c | 30 ++++++++++++++++++++++++++++++ >>>>> fs/btrfs/ioctl.h | 2 ++ >>>>> 3 files changed, 42 insertions(+), 0 deletions(-) >>>>> >>>>> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h >>>>> index 4bab807..eff506f 100644 >>>>> --- a/fs/btrfs/ctree.h >>>>> +++ b/fs/btrfs/ctree.h >>>>> @@ -2583,6 +2583,16 @@ BTRFS_SETGET_STACK_FUNCS(super_csum_type, >>>>> struct btrfs_super_block, >>>>> BTRFS_SETGET_STACK_FUNCS(super_cache_generation, struct >>>>> btrfs_super_block, >>>>> cache_generation, 64); >>>>> >>>>> +static inline char * btrfs_super_label(struct btrfs_super_block *s) >>>>> +{ >>>>> + return s->label; >>>>> +} >>>>> +static inline void btrfs_set_super_label(struct btrfs_super_block *s, >>>>> + char *val) >>>>> +{ >>>>> + memcpy(s->label,val,BTRFS_LABEL_SIZE); >>>>> +} >>>>> + >>>>> static inline int btrfs_super_csum_size(struct btrfs_super_block *s) >>>>> { >>>>> int t = btrfs_super_csum_type(s); >>>>> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c >>>>> index 7bb7556..b472942 100644 >>>>> --- a/fs/btrfs/ioctl.c >>>>> +++ b/fs/btrfs/ioctl.c >>>>> @@ -3687,6 +3687,32 @@ out: >>>>> return ret; >>>>> } >>>>> >>>>> +static int btrfs_ioctl_get_label(struct btrfs_root *root, void >>>>> __user *arg) >>>>> +{ >>>>> + char *label; >>>>> + label = btrfs_super_label(root->fs_info->super_copy); >>>>> + if (copy_to_user(arg, label, BTRFS_LABEL_SIZE)) >>>>> + return -EFAULT; >>>>> + return 0; >>>>> +} >>>>> + >>>>> +static int btrfs_ioctl_set_label(struct btrfs_root *root, void >>>>> __user *arg) >>>>> +{ >>>>> + struct btrfs_trans_handle *trans; >>>>> + char label[BTRFS_LABEL_SIZE+1]; >>>>> + >>>>> + if (!capable(CAP_SYS_ADMIN)) >>>>> + return -EPERM; >>>>> + if (copy_from_user(label, arg, BTRFS_LABEL_SIZE)) >>>>> + return -EFAULT; >>>>> + label[BTRFS_LABEL_SIZE] = ''\0''; >>>>> + trans = btrfs_start_transaction(root, 1); >>>>> + btrfs_set_super_label(root->fs_info->super_copy, label); >>>>> + btrfs_commit_transaction(trans, root); >>>>> + >>>>> + return 0; >>>>> +} >>>>> + >>>>> long btrfs_ioctl(struct file *file, unsigned int >>>>> cmd, unsigned long arg) >>>>> { >>>>> @@ -3785,6 +3811,10 @@ long btrfs_ioctl(struct file *file, unsigned >>>>> int >>>>> return btrfs_ioctl_qgroup_create(root, argp); >>>>> case BTRFS_IOC_QGROUP_LIMIT: >>>>> return btrfs_ioctl_qgroup_limit(root, argp); >>>>> + case BTRFS_IOC_GET_LABEL: >>>>> + return btrfs_ioctl_get_label(root, argp); >>>>> + case BTRFS_IOC_SET_LABEL: >>>>> + return btrfs_ioctl_set_label(root, argp); >>>>> } >>>>> >>>>> return -ENOTTY; >>>>> diff --git a/fs/btrfs/ioctl.h b/fs/btrfs/ioctl.h >>>>> index 731e287..0c60fcb 100644 >>>>> --- a/fs/btrfs/ioctl.h >>>>> +++ b/fs/btrfs/ioctl.h >>>>> @@ -453,4 +453,6 @@ struct btrfs_ioctl_send_args { >>>>> struct btrfs_ioctl_qgroup_limit_args) >>>>> #define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, \ >>>>> struct btrfs_ioctl_get_dev_stats) >>>>> +#define BTRFS_IOC_GET_LABEL _IOR(BTRFS_IOCTL_MAGIC, 53, __u64) >>>>> +#define BTRFS_IOC_SET_LABEL _IOW(BTRFS_IOCTL_MAGIC, 54, __u64) >>>>> #endif >>>> >>>> -- >>>> To unsubscribe from this list: send the line "unsubscribe >>>> linux-btrfs" in >>>> the body of a message to majordomo@vger.kernel.org >>>> More majordomo info at http://vger.kernel.org/majordomo-info.html >>> -- >>> To unsubscribe from this list: send the line "unsubscribe >>> linux-btrfs" in >>> the body of a message to majordomo@vger.kernel.org >>> More majordomo info at http://vger.kernel.org/majordomo-info.html > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> The original patch could be revised with this support easily. > How about using one structure and one ioctl number for both of them? i.e, > > #define BTRFS_IOC_FSLABEL_CTL _IOW(BTRFS_IOCTL_MAGIC, 50, struct > btrfs_ioctl_fslabel_ctl_args) > > #define BTRFS_FSLABEL_CTL_GET 0 > #define BTRFS_FSLABEL_CTL_SET 1 > > struct btrfs_ioctl_fslabel_ctl_args { > char label[BTRFS_LABEL_SIZE]; > u32 flags; > }; > > so that get/set label from user tools would looks like, > > struct btrfs_ioctl_fslabel_ctl_args arg; > arg.flags = BTRFS_FSLABEL_CTL_GET; /* get label */ > or > arg.flags = BTRFS_FSLABEL_CTL_SET; /* set label */ > .... > > ioctl(fd, BTRFS_FSLABEL_CTL,&arg);I would prefer separating GET and SET label ioctl, (to have one operation with an ioctl define) that will be similar to rest of the ioctl in btrfs. Further we don''t need ioctl-arg-struct here, unless if you are keeping the flags. And in my understanding in kernel memcpy are better instead of strcpy. If you could add GET that will be nicer. I would need this for an experiment to add the label for the subvol/snapshots. Thanks, Anand -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 08/30/12 14:28, Anand Jain wrote:> >> The original patch could be revised with this support easily. >> How about using one structure and one ioctl number for both of them? >> i.e, >> >> #define BTRFS_IOC_FSLABEL_CTL _IOW(BTRFS_IOCTL_MAGIC, 50, struct >> btrfs_ioctl_fslabel_ctl_args) >> >> #define BTRFS_FSLABEL_CTL_GET 0 >> #define BTRFS_FSLABEL_CTL_SET 1 >> >> struct btrfs_ioctl_fslabel_ctl_args { >> char label[BTRFS_LABEL_SIZE]; >> u32 flags; >> }; >> >> so that get/set label from user tools would looks like, >> >> struct btrfs_ioctl_fslabel_ctl_args arg; >> arg.flags = BTRFS_FSLABEL_CTL_GET; /* get label */ >> or >> arg.flags = BTRFS_FSLABEL_CTL_SET; /* set label */ >> .... >> >> ioctl(fd, BTRFS_FSLABEL_CTL,&arg); > > > I would prefer separating GET and SET label ioctl, > (to have one operation with an ioctl define) that > will be similar to rest of the ioctl in btrfs. > Further we don''t need ioctl-arg-struct here, unless > if you are keeping the flags. >Thanks for the suggestions. Yes, I noticed Btrfs perform add/rm devices, as well as set/set flags, etc... all with two separated ioctls, It''s better to make the code style in a manner consistent with them. However, get/set label is assigned one number in previous, the next number(51) has been assigned to David, 51 - compressed file size - David Sterba To make the code style in a consistent manner, We can re-assign those numbers if Chris and David would happy to hear that.> And in my understanding in kernel memcpy are better > instead of strcpy.If we do copy binary structure/elements, memcpy is nice. However, consider we''re copying a label in string, I think the difference between them in kernel is same to the user lib, which means that the copy is stops or not when it encounters a NUL. By contrast , I think strcpy is better here, if the label is specified with a NUL(''\0'', why do that?) in the middle of it, and we do memcpy for it in kernel, but, the user will get surprised when he/she fetch the label and printf(3) it out. Thanks, -Jeff> > If you could add GET that will be nicer. > > I would need this for an experiment to add the label > for the subvol/snapshots. > > Thanks, Anand-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Goffredo Baroncelli
2012-Aug-30 18:27 UTC
Re: [PATCH] Btrfs-progs: Add get/set label ioctl
Hi Anand, please updates the man page, because it says that it is impossible to change the label of a mounted filesystem [...] btrfs filesystem label <dev> [newlabel] Show or update the label of a filesystem. <dev> is used to iden‐ tify the filesystem. If a newlabel optional argument is passed, the label is changed. The following costraints exist for a label: - the maximum allowable lenght shall be less or equal than 256 chars - the label shall not contain the ''/'' or ''\'' characters. NOTE: Currently there are the following limitations: - the filesystem has to be unmounted - the filesystem should not have more than one device. [...] Thanks G.Baroncelli On 08/29/2012 10:46 AM, Anand jain wrote:> From: Anand Jain<anand.jain@oracle.com> > > Signed-off-by: Anand Jain<anand.jain@oracle.com> > --- > btrfslabel.c | 90 ++++++++++++++++++++++++++++++++++++++-------------------- > ioctl.h | 2 + > utils.h | 1 + > 3 files changed, 62 insertions(+), 31 deletions(-) > > diff --git a/btrfslabel.c b/btrfslabel.c > index bf73802..3676db0 100644 > --- a/btrfslabel.c > +++ b/btrfslabel.c > @@ -51,6 +51,10 @@ static void change_label_unmounted(char *dev, char *nLabel) > struct btrfs_root *root; > struct btrfs_trans_handle *trans; > > + if(check_mounted(dev)) { > + fprintf(stderr, "ERROR: dev is mounted, use mount point\n"); > + return; > + } > /* Open the super_block at the default location > * and as read-write. > */ > @@ -67,10 +71,57 @@ static void change_label_unmounted(char *dev, char *nLabel) > close_ctree(root); > } > > +static void set_fs_label(char *mnt, char *label) > +{ > + int fd, e=0; > + char fslabel[BTRFS_LABEL_SIZE+1]; > + > + memset(fslabel, 0, BTRFS_LABEL_SIZE+1); > + strncpy(fslabel,label,BTRFS_LABEL_SIZE); > + > + fd = open(mnt, O_RDONLY| O_NOATIME); > + if (fd< 0) { > + fprintf(stderr, "ERROR: Open %s failed\n", mnt); > + return; > + } > + > + if(ioctl(fd, BTRFS_IOC_SET_LABEL, fslabel)< 0) { > + e = errno; > + fprintf(stderr, "ERROR: get label failed, %s\n", > + strerror(e)); > + } > + close(fd); > +} > + > +static void get_fs_label(char *path) > +{ > + int fd, e=0; > + char label[BTRFS_LABEL_SIZE+1]; > + > + fd = open(path, O_RDONLY| O_NOATIME); > + if (fd< 0) { > + fprintf(stderr, "ERROR: Open %s failed\n", path); > + return; > + } > + > + if(ioctl(fd, BTRFS_IOC_GET_LABEL, label)< 0) { > + e = errno; > + fprintf(stderr, "ERROR: get label failed, %s\n", > + strerror(e)); > + return; > + } > + printf("%s\n",label); > + close(fd); > +} > + > static void get_label_unmounted(char *dev) > { > struct btrfs_root *root; > > + if(check_mounted(dev)) { > + fprintf(stderr, "ERROR: dev is mounted, use mount point\n"); > + return; > + } > /* Open the super_block at the default location > * and as read-only. > */ > @@ -84,41 +135,18 @@ static void get_label_unmounted(char *dev) > > int get_label(char *btrfs_dev) > { > - > - int ret; > - ret = check_mounted(btrfs_dev); > - if (ret< 0) > - { > - fprintf(stderr, "FATAL: error checking %s mount status\n", btrfs_dev); > - return -1; > - } > - > - if(ret != 0) > - { > - fprintf(stderr, "FATAL: the filesystem has to be unmounted\n"); > - return -2; > - } > - get_label_unmounted(btrfs_dev); > + if(is_existing_blk_or_reg_file(btrfs_dev)) > + get_label_unmounted(btrfs_dev); > + else > + get_fs_label(btrfs_dev); > return 0; > } > > - > int set_label(char *btrfs_dev, char *nLabel) > { > - > - int ret; > - ret = check_mounted(btrfs_dev); > - if (ret< 0) > - { > - fprintf(stderr, "FATAL: error checking %s mount status\n", btrfs_dev); > - return -1; > - } > - > - if(ret != 0) > - { > - fprintf(stderr, "FATAL: the filesystem has to be unmounted\n"); > - return -2; > - } > - change_label_unmounted(btrfs_dev, nLabel); > + if(is_existing_blk_or_reg_file(btrfs_dev)) > + change_label_unmounted(btrfs_dev, nLabel); > + else > + set_fs_label(btrfs_dev, nLabel); > return 0; > } > diff --git a/ioctl.h b/ioctl.h > index d6f3d07..7e1dcda 100644 > --- a/ioctl.h > +++ b/ioctl.h > @@ -370,4 +370,6 @@ struct btrfs_ioctl_clone_range_args { > struct btrfs_ioctl_received_subvol_args) > #define BTRFS_IOC_SEND _IOW(BTRFS_IOCTL_MAGIC, 38, struct btrfs_ioctl_send_args) > > +#define BTRFS_IOC_GET_LABEL _IOR(BTRFS_IOCTL_MAGIC, 53, __u64) > +#define BTRFS_IOC_SET_LABEL _IOW(BTRFS_IOCTL_MAGIC, 54, __u64) > #endif > diff --git a/utils.h b/utils.h > index c147c12..ba088fe 100644 > --- a/utils.h > +++ b/utils.h > @@ -48,4 +48,5 @@ int check_label(char *input); > int get_mountpt(char *dev, char *mntpt, size_t size); > > int btrfs_scan_block_devices(int run_ioctl); > +int is_existing_blk_or_reg_file(const char* filename); > #endif-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Anand jain
2012-Sep-14 06:03 UTC
[PATCH 1/1] Btrfs-progs: Update btrfs man page to indicate label for a mounted fs can be changed
From: Anand Jain <anand.jain@oracle.com> Signed-off-by: Anand Jain <anand.jain@oracle.com> --- man/btrfs.8.in | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-) diff --git a/man/btrfs.8.in b/man/btrfs.8.in index 4b0a9f9..0258d87 100644 --- a/man/btrfs.8.in +++ b/man/btrfs.8.in @@ -25,7 +25,7 @@ btrfs \- control a btrfs filesystem .PP \fBbtrfs\fP \fBfilesystem resize\fP\fI [devid:][+/\-]<size>[gkm]|[devid:]max <filesystem>\fP .PP -\fBbtrfs\fP \fBfilesystem label\fP\fI <dev> [newlabel]\fP +\fBbtrfs\fP \fBfilesystem label\fP\fI <dev>|<path> [newlabel]\fP .PP \fBbtrfs\fP \fBsubvolume find-new\fP\fI <subvolume> <last_gen>\fP .PP @@ -197,8 +197,8 @@ it with the new desired size. When recreating the partition make sure to use the same starting disk cylinder as before. .TP -\fBfilesystem label\fP\fI <dev> [newlabel]\fP -Show or update the label of a filesystem. \fI<dev>\fR is used to identify the +\fBfilesystem label\fP\fI <dev>|<path> [newlabel]\fP +Show or update the label of a filesystem. \fI<dev>|<path>\fR is used to identify the filesystem. If a \fInewlabel\fR optional argument is passed, the label is changed. The following constraints exist for a label: @@ -207,11 +207,9 @@ following constraints exist for a label: .IP - the label shall not contain the ''/'' or ''\\'' characters. -NOTE: Currently there are the following limitations: -.IP -- the filesystem has to be unmounted -.IP -- the filesystem should not have more than one device. +Note: +As of now a btrfs filesystem containing more than one device must be +mounted to change its filesystem label. .TP \fBfilesystem show\fR [--all-devices|<uuid>|<label>]\fR -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html