Hi, Anand On fri, 16 Nov 2012 12:52:25 +0800, Anand jain wrote: > +static int btrfs_ioctl_subvol_getlabel(struct btrfs_root *root, > + void __user *arg) > +{ > + char *label; > + > + label = btrfs_root_label(&root->root_item); > + if (copy_to_user(arg, label, BTRFS_SUBVOL_LABEL_SIZE)) > + return -EFAULT; > + return 0; > +} > + > +static int btrfs_ioctl_subvol_setlabel(struct btrfs_root *root, > + void __user *arg) > +{ > + char label[BTRFS_SUBVOL_LABEL_SIZE+1]; > + struct btrfs_trans_handle *trans; > + > + if (copy_from_user(label, arg, BTRFS_SUBVOL_LABEL_SIZE)) > + return -EFAULT; > + trans = btrfs_join_transaction(root); > + if (IS_ERR(trans)) > + return PTR_ERR(trans); > + btrfs_root_set_label(&root->root_item, label); > + btrfs_end_transaction(trans, root);
We need a lock to protect the label, and besides that, we need to get the write access before we set the label for the subvolume. Thanks Miao -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html