Replace deprecated ustat using fstatfs

This resolves FTBFS with glibc 2.28

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 830ea2b69f)
pull/20/head
Slávek Banko 6 years ago
parent 77ff405a13
commit c9b5233204
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -42,11 +42,6 @@
#include <fcntl.h>
#include <sys/ioctl.h>
/* this is for glibc 2.x which the ust structure in ustat.h not stat.h */
#ifdef __GLIBC__
#include <sys/ustat.h>
#endif
#ifdef __FreeBSD__
#include <sys/param.h>
#include <sys/ucred.h>

@ -263,10 +263,9 @@
/*
* There are two alternative ways of checking a device containing a
* mounted filesystem. Define BSD_MOUNTTEST for the test using
* getmntent(). Undefine it for using the SVR4 ustat().
* getmntent(). Undefine it for using the fstatfs().
* I built in the choice, because it's not clear which method should
* be used in Linux. The ustat manpage tells us since 1995, that
* fstat() should be used, but I'm too dumb to do so.
* be used in Linux.
*/
#define BSD_MOUNTTEST

@ -30,22 +30,14 @@
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
#include <ustat.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include "include/wm_config.h"
/*
* this is for glibc 2.x which the ust structure in
* ustat.h not stat.h
*/
#ifdef __GLIBC__
#include <sys/ustat.h>
#endif
#include <sys/time.h>
#include <sys/scsi.h>
@ -294,13 +286,13 @@ int
gen_eject( struct wm_drive *d )
{
struct stat stbuf;
struct ustat ust;
struct statfs sfsbuf;
if (fstat(d->fd, &stbuf) != 0)
return (-2);
/* Is this a mounted filesystem? */
if (ustat(stbuf.st_rdev, &ust) == 0)
if (fstatfs(d->fd, &sfsbuf) == 0)
return (-3);
return (wm_scsi2_eject(d));

@ -58,13 +58,7 @@ typedef unsigned long long __u64;
#if defined(BSD_MOUNTTEST)
#include <mntent.h>
#else
/*
* this is for glibc 2.x which defines ust structure in
* ustat.h not stat.h
*/
#ifdef __GLIBC__
#include <sys/ustat.h>
#endif
#include <sys/statfs.h>
#endif
@ -604,7 +598,7 @@ gen_eject(struct wm_drive *d)
{
struct stat stbuf;
#if !defined(BSD_MOUNTTEST)
struct ustat ust;
struct statfs sfsbuf;
#else
struct mntent *mnt;
FILE *fp;
@ -619,7 +613,7 @@ gen_eject(struct wm_drive *d)
/* Is this a mounted filesystem? */
#if !defined(BSD_MOUNTTEST)
if (ustat(stbuf.st_rdev, &ust) == 0)
if (fstatfs(d->fd, &sfsbuf) == 0)
return (-3);
#else
/*

@ -32,11 +32,11 @@ static char plat_news_id[] = "$Id$";
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
#include <ustat.h>
#include <CD.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include <sys/time.h>
#include "include/wm_config.h"
@ -362,13 +362,13 @@ int
gen_eject( struct wm_drive *d )
{
struct stat stbuf;
struct ustat ust;
struct statfs sfsbuf;
if (fstat(d->fd, &stbuf) != 0)
return (-2);
/* Is this a mounted filesystem? */
if (ustat(stbuf.st_rdev, &ust) == 0)
if (fstatfs(d->fd, &sfsbuf) == 0)
return (-3);
if (CD_AutoEject(d->fd))

@ -45,11 +45,6 @@
#include "include/wm_cdrom.h"
#include "include/wm_helpers.h"
/* this is for glibc 2.x which defines the ust structure in ustat.h not stat.h */
#ifdef __GLIBC__
#include <sys/ustat.h>
#endif
#include <sys/time.h>
#include <string.h>
#include <sys/ioctl.h>

@ -33,8 +33,8 @@
#include <fcntl.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/ststfd.h>
#include <sys/time.h>
#include <ustat.h>
#include <string.h>
/* #include <sys/rzdisk.h>
#include <sys/cdrom.h> */
@ -424,13 +424,13 @@ gen_eject(struct wm_drive *d)
{
/* On some systems, we can check to see if the CD is mounted. */
struct stat stbuf;
struct ustat ust;
struct statfs sfsbuf;
if (fstat(d->fd, &stbuf) != 0)
return (-2);
/* Is this a mounted filesystem? */
if (ustat(stbuf.st_rdev, &ust) == 0)
if (fstatfs(d->fd, &sfsbuf) == 0)
return (-3);
return (ioctl(d->fd, CDROM_EJECT_CADDY, 0));

@ -36,6 +36,7 @@ static char plat_sun_id[] = "$Id$";
#include <string.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include <sys/time.h>
#include <sys/ioctl.h>
@ -44,7 +45,6 @@ static char plat_sun_id[] = "$Id$";
#include "include/wm_cdrom.h"
#include "include/wm_cdtext.h"
#include <ustat.h>
#include <unistd.h>
#include <signal.h>
#ifdef solbourne
@ -602,13 +602,13 @@ int
gen_eject( struct wm_drive *d )
{
struct stat stbuf;
struct ustat ust;
struct statfs sfsbuf;
if (fstat(d->fd, &stbuf) != 0)
return (-2);
/* Is this a mounted filesystem? */
if (ustat(stbuf.st_rdev, &ust) == 0)
if (fstatfs(d->fd, &sfsbuf) == 0)
return (-3);
IFCDDA(d) {

@ -36,8 +36,8 @@ static char plat_ultrix_id[] = "$Id$";
#include <fcntl.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include <sys/time.h>
#include <ustat.h>
#include <string.h>
#include <sys/rzdisk.h>
#include <sys/cdrom.h>
@ -475,13 +475,13 @@ gen_eject(struct wm_drive *d)
{
/* On some systems, we can check to see if the CD is mounted. */
struct stat stbuf;
struct ustat ust;
struct statfs sfsbuf;
if (fstat(d->fd, &stbuf) != 0)
return (-2);
/* Is this a mounted filesystem? */
if (ustat(stbuf.st_rdev, &ust) == 0)
if (fstatfs(d->fd, &sfsbuf) == 0)
return (-3);
return (ioctl(d->fd, CDROM_EJECT_CADDY));

Loading…
Cancel
Save