version 1.7, 2003/04/05 20:31:58 |
version 1.8, 2003/05/14 01:34:35 |
|
|
* SUCH DAMAGE. |
* SUCH DAMAGE. |
*/ |
*/ |
|
|
|
#include "defs.h" |
#ifndef lint |
#ifndef lint |
#if 0 |
#if 0 |
static char RCSid[] = |
static char RCSid[] __attribute__((__unused__)) = |
"$From: filesys-os.c,v 6.17 1996/01/17 21:02:45 mcooper Exp mcooper $"; |
"$From: filesys-os.c,v 1.5 1999/08/04 15:57:33 christos Exp $"; |
#else |
#else |
static char RCSid[] = |
static char RCSid[] __attribute__((__unused__)) = |
"$OpenBSD$"; |
"$OpenBSD$"; |
#endif |
#endif |
|
|
static char sccsid[] = "@(#)filesys-os.c"; |
static char sccsid[] __attribute__((__unused__)) = |
|
"@(#)filesys-os.c"; |
|
|
static char copyright[] = |
static char copyright[] __attribute__((__unused__)) = |
"@(#) Copyright (c) 1983 Regents of the University of California.\n\ |
"@(#) Copyright (c) 1983 Regents of the University of California.\n\ |
All rights reserved.\n"; |
All rights reserved.\n"; |
#endif /* not lint */ |
#endif /* not lint */ |
|
|
* OS specific file system routines |
* OS specific file system routines |
*/ |
*/ |
|
|
#include "defs.h" |
|
#include "filesys.h" |
|
|
|
#if FSI_TYPE == FSI_GETFSSTAT |
#if FSI_TYPE == FSI_GETFSSTAT |
static struct statfs *mnt = NULL; |
static struct statfs *mnt = NULL; |
#if FSTYPENAME |
|
#define f_type_eq(a, b) (! strcmp (((struct statfs *) (a))->f_fstypename, (b))) |
|
#else /* !FSTYPENAME */ |
|
#define f_type_eq(a, b) (((struct statfs *) a)->f_type == (b)) |
|
#endif /* !FSTYPENAME */ |
|
#endif /* FSI_GETFSSTAT */ |
#endif /* FSI_GETFSSTAT */ |
|
|
#if FSI_TYPE == FSI_MNTCTL |
#if FSI_TYPE == FSI_MNTCTL |
|
|
/* |
/* |
* AIX version of setmountent() |
* AIX version of setmountent() |
*/ |
*/ |
FILE *setmountent(file, mode) |
FILE * |
/*ARGSUSED*/ |
setmountent(const char *file, const char *mode) |
char *file; |
|
char *mode; |
|
{ |
{ |
ulong size; |
ulong size; |
|
|
|
|
/* |
/* |
* getfsstat() version of get mount info routines. |
* getfsstat() version of get mount info routines. |
*/ |
*/ |
FILE *setmountent(file, mode) |
FILE * |
/*ARGSUSED*/ |
setmountent(const char *file, const char *mode) |
char *file; |
|
char *mode; |
|
{ |
{ |
long size; |
long size; |
|
|
|
|
/* |
/* |
* Iterate over mount entries |
* Iterate over mount entries |
*/ |
*/ |
mntent_t *getmountent(fptr) |
mntent_t * |
/*ARGSUSED*/ |
getmountent(FILE *fptr) |
FILE *fptr; |
|
{ |
{ |
static mntent_t mntstruct; |
static mntent_t mntstruct; |
|
|
|
|
/* |
/* |
* getfsstat() version of getmountent() |
* getfsstat() version of getmountent() |
*/ |
*/ |
mntent_t *getmountent(fptr) |
mntent_t * |
/*ARGSUSED*/ |
getmountent(FILE *fptr) |
FILE *fptr; |
|
{ |
{ |
static mntent_t mntstruct; |
static mntent_t mntstruct; |
static char remote_dev[MAXHOSTNAMELEN+MAXPATHLEN+1]; |
static char remote_dev[MAXHOSTNAMELEN+MAXPATHLEN+1]; |
|
|
if (mnt->f_flags & M_RDONLY) |
if (mnt->f_flags & M_RDONLY) |
mntstruct.me_flags |= MEFLAG_READONLY; |
mntstruct.me_flags |= MEFLAG_READONLY; |
#endif |
#endif |
if (f_type_eq(mnt, MOUNT_NFS)) { |
|
(void) snprintf(remote_dev, sizeof remote_dev, |
#ifdef HAVE_FSTYPENAME |
"%s", mnt->f_mntfromname); |
if (strcmp(mnt->f_fstypename, "nfs") == 0) |
|
#else |
|
if (mnt->f_type == MOUNT_NFS) |
|
#endif /* HAVE_FSTYPENAME */ |
|
{ |
|
strlcpy(remote_dev, mnt->f_mntfromname, sizeof(remote_dev)); |
mntstruct.me_path = remote_dev; |
mntstruct.me_path = remote_dev; |
mntstruct.me_type = METYPE_NFS; |
mntstruct.me_type = METYPE_NFS; |
} else { |
} else { |
|
|
/* |
/* |
* Done with iterations |
* Done with iterations |
*/ |
*/ |
void endmountent(fptr) |
void |
/*ARGSUSED*/ |
endmountent(FILE *fptr) |
FILE *fptr; |
|
{ |
{ |
mnt = NULL; |
mnt = NULL; |
|
|
|
|
/* |
/* |
* Prepare to iterate over mounted filesystem list |
* Prepare to iterate over mounted filesystem list |
*/ |
*/ |
FILE *setmountent(file, mode) |
FILE * |
/*ARGSUSED*/ |
setmountent(const char *file, const char *mode) |
char *file; |
|
char *mode; |
|
{ |
{ |
return(fopen(file, mode)); |
return(fopen(file, mode)); |
} |
} |
|
|
/* |
/* |
* Done with iteration |
* Done with iteration |
*/ |
*/ |
void endmountent(fptr) |
void |
/*ARGSUSED*/ |
endmountent(FILE *fptr) |
FILE *fptr; |
|
{ |
{ |
fclose(fptr); |
fclose(fptr); |
} |
} |
|
|
/* |
/* |
* Iterate over mount entries |
* Iterate over mount entries |
*/ |
*/ |
mntent_t *getmountent(fptr) |
mntent_t * |
FILE *fptr; |
getmountent(FILE *fptr) |
{ |
{ |
static mntent_t me; |
static mntent_t me; |
static struct mnttab mntent; |
static struct mnttab mntent; |
|
|
/* |
/* |
* Prepare to iterate over mounted filesystem list |
* Prepare to iterate over mounted filesystem list |
*/ |
*/ |
FILE *setmountent(file, mode) |
FILE * |
/*ARGSUSED*/ |
setmountent(const char *file, const char *mode) |
char *file; |
|
char *mode; |
|
{ |
{ |
return(setmntent(file, mode)); |
return(setmntent(file, mode)); |
} |
} |
|
|
/* |
/* |
* Done with iteration |
* Done with iteration |
*/ |
*/ |
void endmountent(fptr) |
void |
/*ARGSUSED*/ |
endmountent(FILE *fptr) |
FILE *fptr; |
|
{ |
{ |
endmntent(fptr); |
endmntent(fptr); |
} |
} |
|
|
/* |
/* |
* Iterate over mount entries |
* Iterate over mount entries |
*/ |
*/ |
mntent_t *getmountent(fptr) |
mntent_t * |
FILE *fptr; |
getmountent(FILE *fptr) |
{ |
{ |
static mntent_t me; |
static mntent_t me; |
struct mntent *mntent; |
struct mntent *mntent; |
|
|
bzero((char *)&me, sizeof(mntent_t)); |
bzero((char *)&me, sizeof(mntent_t)); |
|
|
if (mntent = getmntent(fptr)) { |
if ((mntent = getmntent(fptr)) != NULL) { |
me.me_path = mntent->mnt_dir; |
me.me_path = mntent->mnt_dir; |
me.me_type = mntent->mnt_type; |
me.me_type = mntent->mnt_type; |
if (mntent->mnt_opts && hasmntopt(mntent, MNTOPT_RO)) |
if (mntent->mnt_opts && hasmntopt(mntent, MNTOPT_RO)) |
|
|
|
|
static int startmounts = 0; |
static int startmounts = 0; |
|
|
FILE *setmountent(file, mode) |
FILE * |
/*ARGSUSED*/ |
setmountent(const char *file, const char *mode) |
char *file; |
|
char *mode; |
|
{ |
{ |
startmounts = 0; |
startmounts = 0; |
return(stdin); /* XXX - need to return something! */ |
return((FILE *) 1); |
} |
} |
|
|
void endmountent(fptr) |
void |
/*ARGSUSED*/ |
endmountent(FILE *fptr) |
FILE *fptr; |
|
{ |
{ |
/* NOOP */ |
/* NOOP */ |
} |
} |
|
|
/* |
/* |
* Iterate over mounted filesystems using getmnt() |
* Iterate over mounted filesystems using getmnt() |
*/ |
*/ |
mntent_t *getmountent(fptr) |
mntent_t * |
/*ARGSUSED*/ |
getmountent(FILE *fptr) |
FILE *fptr; |
|
{ |
{ |
struct fs_data fs_data; |
struct fs_data fs_data; |
static mntent_t me; |
static mntent_t me; |
|
|
/* |
/* |
* Make a new (copy) of a mntent structure. |
* Make a new (copy) of a mntent structure. |
*/ |
*/ |
mntent_t *newmountent(old) |
mntent_t * |
mntent_t *old; |
newmountent(const mntent_t *old) |
{ |
{ |
mntent_t *new; |
mntent_t *new; |
|
|