public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Karel Zak <kzak@redhat.com>
To: Andi Drebes <lists-receive@programmierforen.de>
Cc: linux-btrfs@vger.kernel.org, Chris Mason <chris.mason@oracle.com>,
	"Yan, Zheng" <yanzheng@21cn.com>
Subject: Re: [PATCH 1/2] btrfs-progs: multidevice support for check_mounted
Date: Mon, 23 Nov 2009 10:01:43 +0100	[thread overview]
Message-ID: <20091123090143.GB10852@nb.net.home> (raw)
In-Reply-To: <200911221433.13074.lists-receive@programmierforen.de>

On Sun, Nov 22, 2009 at 02:33:13PM +0100, Andi Drebes wrote:
> In the new patch below, is_pseudo_fs() is replaced by
> is_existing_blk_or_reg_file(). We ignore entries associated with an
> invalid path or paths that don't point to a regular or block file.
> However, if a path used in a pseudo-filesystem entry points to the
> file that is being checked, check_mounted() returns 1. In my eyes,
> this is extremely unlikely.
...
> +/* Checks if a file exists and is a block or regular file*/
> +int is_existing_blk_or_reg_file(const char* filename)
> +{
> +	struct stat st_buf;
> +
> +	if(stat(filename, &st_buf) < 0) {
> +		if(errno == ENOENT)
> +			return 0;
> +		else
> +			return -errno;
> +	}
> +
> +	return (S_ISBLK(st_buf.st_mode) || S_ISREG(st_buf.st_mode));
> +}

 Yes, this looks better.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>

  reply	other threads:[~2009-11-23  9:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-21 14:33 [PATCH 0/2] btrfs-progs: mounted filesystems checks Andi Drebes
2009-11-21 14:38 ` [PATCH 1/2] btrfs-progs: multidevice support for check_mounted Andi Drebes
2009-11-21 20:21   ` Karel Zak
2009-11-22 13:33     ` Andi Drebes
2009-11-23  9:01       ` Karel Zak [this message]
2009-11-21 14:39 ` [PATCH 2/2] btrfs-progs: prevent btrfsck to run on mounted filesystems Andi Drebes

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=20091123090143.GB10852@nb.net.home \
    --to=kzak@redhat.com \
    --cc=chris.mason@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=lists-receive@programmierforen.de \
    --cc=yanzheng@21cn.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