linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Goffredo Baroncelli <kreijack@inwind.it>
To: boris <6401e46d@opayq.com>
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: File test operator for subvols; possible bug in 'btrfs show <directory>'
Date: Tue, 25 Nov 2014 08:32:36 +0100	[thread overview]
Message-ID: <54743094.8050200@inwind.it> (raw)
In-Reply-To: <loom.20141125T024507-20@post.gmane.org>

On 11/25/2014 03:11 AM, boris wrote:
> Hi all,
> 
> I was looking for a quick method of testing whether a working directory is a 
> subvolume.

Currently btrfs check that:
- the inode number is 255
- the path is a directory

>From cmds-subvolume.c

[...]
/*
 * test if path is a subvolume:
 * this function return
 * 0-> path exists but it is not a subvolume
 * 1-> path exists and it is  a subvolume
 * -1 -> path is unaccessible
 */
int test_issubvolume(char *path)
{
        struct stat     st;
        int             res;

        res = stat(path, &st);
        if(res < 0 )
                return -1;

        return (st.st_ino == 256) && S_ISDIR(st.st_mode);
}
[---]
> 
> Couldn't see an obvious one, so tried 'btrfs show <somesubvol≥'. It printed 
> a fail message as expected but returned 0 exit status. Bug?
> 
> Can I put in a feature request for a shell file test operator for subvols, 
> please (or something of the kind)? http://tldp.org/LDP/abs/html/fto.html . 
> The letter v (for volume, both upper and lower case forms; one for subvol, 
> other for snapshots) is unused afaict. 
> 
> Have I missed the obvious? Or scored a false positive?
> 
> TIA.
> 
> --
> 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
> 


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

  parent reply	other threads:[~2014-11-25  7:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-25  2:11 File test operator for subvols; possible bug in 'btrfs show <directory>' boris
2014-11-25  5:33 ` Gui Hecheng
2014-11-25  7:32 ` Goffredo Baroncelli [this message]
2014-11-27 17:21   ` 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=54743094.8050200@inwind.it \
    --to=kreijack@inwind.it \
    --cc=6401e46d@opayq.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).