All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: xfs@oss.sgi.com, Christoph Hellwig <hch@infradead.org>,
	linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/6] libxfs/linux.c: Replace use of ustat by stat
Date: Sat, 3 Sep 2016 20:23:51 -0500	[thread overview]
Message-ID: <5d979944-cd03-dbdd-8308-cd8fe4eefe73@sandeen.net> (raw)
In-Reply-To: <20160112195945.GC568@nyan>

Ok, this has become a bit more urgent:

Building on F24 on arm64, I noticed this:

../libxfs/.libs/libxfs.a(linux.o): In function `platform_check_ismounted':
/root/sandeen/xfsprogs-dev/libxfs/linux.c:66: warning: ustat is not implemented and will always fail

And lo:

# xfs_metadump -o /dev/sda3 dump
# mount /dev/sda3 /mnt/scratch
# xfs_mdrestore dump /dev/sda3
# echo $?
0
#

Are we scared yet?

(I independently rewrote Felix's patch after seeing the above, then
searched and found this old thread)

We need to fix this, now.  Performance issues or not I'd advocate for
taking this patch, unless hch made any progress on the O_EXCL approach.

hch said:

> That being said I think ustat fits pretty well for this use case,
> so getting rid of it might need a little more justification.

but it looks like that ship has sailed.

So for this patch I'll add:

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

-Eric

On 1/12/16 1:59 PM, Felix Janda wrote:
> ustat has been used to check whether a device file is mounted.
> The function is deprecated and not supported by uclibc and musl.
> Now do the check using the *mntent functions.
> 
> Based on patch by Natanael Copa <ncopa@alpinelinux.org>.
> 
> Signed-off-by: Felix Janda <felix.janda@posteo.de>
> ---
>  libxfs/linux.c | 29 ++++++++++++++++++++---------
>  1 file changed, 20 insertions(+), 9 deletions(-)
> 
> diff --git a/libxfs/linux.c b/libxfs/linux.c
> index c532d65..e7adcf2 100644
> --- a/libxfs/linux.c
> +++ b/libxfs/linux.c
> @@ -16,11 +16,8 @@
>   * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
>   */
>  
> -#define ustat __kernel_ustat
>  #include <mntent.h>
>  #include <sys/stat.h>
> -#undef ustat
> -#include <sys/ustat.h>
>  #include <sys/mount.h>
>  #include <sys/ioctl.h>
>  #include <sys/sysinfo.h>
> @@ -51,9 +48,10 @@ static int max_block_alignment;
>  int
>  platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose)
>  {
> -	/* Pad ust; pre-2.6.28 linux copies out too much in 32bit compat mode */
> -	struct ustat	ust[2];
> -	struct stat64	st;
> +	FILE		*f;
> +	struct stat64	st, mst;
> +	struct mntent	*mnt;
> +	char		mounts[MAXPATHLEN];
>  
>  	if (!s) {
>  		if (stat64(block, &st) < 0)
> @@ -63,14 +61,27 @@ platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose)
>  		s = &st;
>  	}
>  
> -	if (ustat(s->st_rdev, ust) >= 0) {
> +	strcpy(mounts, (!access(PROC_MOUNTED, R_OK)) ? PROC_MOUNTED : MOUNTED);
> +	if ((f = setmntent(mounts, "r")) == NULL) {
> +		fprintf(stderr,
> +		    _("%s: %s possibly contains a mounted filesystem\n"),
> +		    progname, name);
> +		return 1;
> +	}
> +	while ((mnt = getmntent(f)) != NULL) {
> +		if (stat64(mnt->mnt_dir, &mst) < 0)
> +			continue;
> +		if (mst.st_dev != s->st_rdev)
> +			continue;
> +
>  		if (verbose)
>  			fprintf(stderr,
>  				_("%s: %s contains a mounted filesystem\n"),
>  				progname, name);
> -		return 1;
> +		break;
>  	}
> -	return 0;
> +	endmntent(f);
> +	return mnt == NULL;
>  }
>  
>  int
> 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2016-09-04  1:23 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1452627740.git.felix.janda@posteo.de>
2016-01-12 19:59 ` [PATCH 1/6] Move from __uint*_t types to uint*_t and likewise for __int*_t Felix Janda
2016-01-12 21:24   ` Dave Chinner
2016-01-12 21:46     ` Felix Janda
2016-01-12 22:02       ` Dave Chinner
2016-01-13  7:48     ` Christoph Hellwig
2016-01-20  0:46       ` Dave Chinner
2016-01-12 19:59 ` [PATCH 2/6] libxfs/linux.c: Replace use of ustat by stat Felix Janda
2016-01-12 21:24   ` Dave Chinner
2016-01-12 21:33     ` Felix Janda
2016-01-13  7:55   ` Christoph Hellwig
2016-01-13 17:42     ` Felix Janda
2016-01-14 10:20       ` Christoph Hellwig
2016-01-14 19:07         ` Felix Janda
2016-06-18 14:53         ` Felix Janda
2016-06-22 12:59           ` Christoph Hellwig
2016-09-04  1:23   ` Eric Sandeen [this message]
2016-09-08  0:00   ` Dave Chinner
2016-01-12 19:59 ` [PATCH 3/6] fsr/xfs_fsr.c: Include <paths.h> for _PATH_MOUNTED Felix Janda
2016-01-13  7:55   ` Christoph Hellwig
2016-01-12 20:00 ` [PATCH 4/6] linux.h: Use off64_t instead of loff_t Felix Janda
2016-01-13  7:55   ` Christoph Hellwig
2016-01-12 20:00 ` [PATCH 5/6] include/linux.h: Include <stdio.h> for fprintf and stderr Felix Janda
2016-01-13  7:55   ` Christoph Hellwig
2016-01-12 20:00 ` [PATCH 6/6] Add configure check for members of dirent for use in io/readdir.c Felix Janda
2016-01-12 21:30   ` Dave Chinner
2016-01-12 21:37     ` Felix Janda
2016-01-12 22:37       ` Dave Chinner
2016-01-13  7:58   ` Christoph Hellwig
2016-01-13 17:09     ` Felix Janda
2016-01-14 10:17       ` Christoph Hellwig
2016-01-14 19:06         ` Felix Janda

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=5d979944-cd03-dbdd-8308-cd8fe4eefe73@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=hch@infradead.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=xfs@oss.sgi.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.