Thread (41 messages) 41 messages, 8 authors, 2013-03-01

Re: [PATCH v2] Btrfs: add label to snapshot and subvol

From: Miao Xie <hidden>
Date: 2012-11-16 06:32:48

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help