All of lore.kernel.org
 help / color / mirror / Atom feed
From: Goffredo Baroncelli <kreijack@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: miaox@cn.fujitsu.com, Jeff Liu <jeff.liu@oracle.com>,
	linux-btrfs@vger.kernel.org, anand.jain@oracle.com
Subject: Re: [RFC PATCH V6 2/2] Btrfs: Add a new ioctl to change the label of a mounted file system
Date: Tue, 18 Dec 2012 19:00:48 +0100	[thread overview]
Message-ID: <50D0AF50.3090503@gmail.com> (raw)
In-Reply-To: <50CFE3AC.9000705@cn.fujitsu.com>

Hi Jeff,

On 12/18/2012 04:31 AM, Miao Xie wrote:
[...]
>> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
[...]

>> +static int btrfs_ioctl_set_fslabel(struct file *file, void __user *arg)
>> +{
>> +	struct btrfs_root *root = BTRFS_I(fdentry(file)->d_inode)->root;
>> +	struct btrfs_super_block *super_block = root->fs_info->super_copy;
>> +	struct btrfs_trans_handle *trans;
>> +	char label[BTRFS_LABEL_SIZE];
>> +	int ret;
>> +
>> +	if (!capable(CAP_SYS_ADMIN))
>> +		return -EPERM;
>> +
>> +	if (copy_from_user(label, arg, sizeof(label)))
>> +		return -EFAULT;
>> +
>> +	if (strnlen(label, BTRFS_LABEL_SIZE) == BTRFS_LABEL_SIZE)
>> +		return -EINVAL;
>> +
>> +	ret = mnt_want_write_file(file);
>> +	if (ret)
>> +		return ret;
>> +
>> +	mutex_lock(&root->fs_info->volume_mutex);
>> +	trans = btrfs_start_transaction(root, 1);
>> +	if (IS_ERR(trans)) {
>> +		ret = PTR_ERR(trans);
>> +		goto out_unlock;
>> +	}
>> +
>> +	strcpy(super_block->label, label);

I think that you removed for mistake the following line

+	label[BTRFS_LABEL_SIZE - 1] = '\0';

In the V5 patch it was present.

May be we could replace strcpy() with strlcpy(super_block->label, label,
BTRFS_LABEL_SIZE-1) ?

BR
G.Baroncelli

-- 
gpg @keyserver.linux.it: Goffredo Baroncelli (kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5

  reply	other threads:[~2012-12-18 18:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-18  3:05 [RFC PATCH V6 0/2] Btrfs: get/set label of a mounted file system Jeff Liu
2012-12-18  3:05 ` [RFC PATCH V6 2/1] Btrfs: Add a new ioctl to get the " Jeff Liu
2012-12-18  3:06 ` [RFC PATCH V6 2/2] Btrfs: Add a new ioctl to change " Jeff Liu
2012-12-18  3:31   ` Miao Xie
2012-12-18 18:00     ` Goffredo Baroncelli [this message]
2012-12-19  3:42       ` Jeff Liu
2012-12-19 14:21   ` David Sterba
2012-12-20  8:18     ` Jeff Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50D0AF50.3090503@gmail.com \
    --to=kreijack@gmail.com \
    --cc=anand.jain@oracle.com \
    --cc=jeff.liu@oracle.com \
    --cc=kreijack@inwind.it \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=miaox@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.