From: Su Yue <l@damenly.su>
To: Sidong Yang <realwakka@gmail.com>
Cc: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.cz>
Subject: Re: [PATCH] btrfs-progs: subvolume: Add warning on deleting default subvolume
Date: Wed, 30 Sep 2020 09:33:31 +0800 [thread overview]
Message-ID: <blhogiac.fsf@damenly.su> (raw)
In-Reply-To: <20200928150729.2239-1-realwakka@gmail.com>
On Mon 28 Sep 2020 at 23:07, Sidong Yang <realwakka@gmail.com>
wrote:
> This patch add warning messages when user try to delete default
> subvolume. When deleting default subvolume, kernel will not
> allow and
> make error message on syslog. but there is only message that
> permission
> denied on userspace. User can be noticed the reason by this
> warning message.
>
> This patch implements github issue.
> https://github.com/kdave/btrfs-progs/issues/274
>
> Signed-off-by: Sidong Yang <realwakka@gmail.com>
> ---
> cmds/subvolume.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/cmds/subvolume.c b/cmds/subvolume.c
> index 2020e486..0cdf7a68 100644
> --- a/cmds/subvolume.c
> +++ b/cmds/subvolume.c
> @@ -264,6 +264,7 @@ static int cmd_subvol_delete(const struct
> cmd_struct *cmd,
> struct seen_fsid *seen_fsid_hash[SEEN_FSID_HASH_SIZE] = {
> NULL, };
> enum { COMMIT_AFTER = 1, COMMIT_EACH = 2 };
> enum btrfs_util_error err;
> + uint64_t default_subvol_id = 0, target_subvol_id = 0;
>
> optind = 0;
> while (1) {
> @@ -360,6 +361,25 @@ again:
> goto out;
> }
>
> + err = btrfs_util_get_default_subvolume_fd(fd,
> &default_subvol_id);
> + if (fd < 0) {
>
Should it be
" if (err) {
|
error_btrfs_util(err);
...
"?
> + ret = 1;
> + goto out;
> + }
> +
> + if (subvolid > 0)
> + target_subvol_id = subvolid;
> + else {
> + err = btrfs_util_subvolume_id(path, &target_subvol_id);
> + if (fd < 0) {
>
And here.
> + ret = 1;
> + goto out;
> + }
> + }
> +
> + if (target_subvol_id == default_subvol_id)
> + warning("trying to delete default subvolume.");
> +
> pr_verbose(MUST_LOG, "Delete subvolume (%s): ",
> commit_mode == COMMIT_EACH ||
> (commit_mode == COMMIT_AFTER && cnt + 1 == argc) ?
next prev parent reply other threads:[~2020-09-30 1:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-28 15:07 [PATCH] btrfs-progs: subvolume: Add warning on deleting default subvolume Sidong Yang
2020-09-29 21:37 ` David Sterba
2020-09-30 1:33 ` Su Yue [this message]
2020-09-24 12:45 ` Sidong Yang
2020-09-30 16:26 ` David Sterba
2020-09-30 16:27 ` David Sterba
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=blhogiac.fsf@damenly.su \
--to=l@damenly.su \
--cc=linux-btrfs@vger.kernel.org \
--cc=realwakka@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox