/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2010 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* mounted filesystem scan support
* where are the standards when you really need them
*/
#include <ast.h>
#include <mnt.h>
#include <ls.h>
#else
/*
* the original interface just had mode
*/
#define FIXARGS(p,m,s) do { \
if ((p)&&*(p)!='/') { \
mode = p; \
path = 0; \
} \
if (!path) \
path = s; \
} while (0)
typedef struct
{
char buf[128];
#if __CYGWIN__
char typ[128];
char opt[128];
#endif
} Header_t;
#if __CYGWIN__
#include <ast_windows.h>
#endif
static void
{
const char* x;
{
if (*++x && *x != '\\')
{
if (*x == '(')
{
fs = x;
type = "auto";
}
}
}
{
}
#if __CYGWIN__
{
char* s;
int mode;
char drive[4];
drive[3] = 0;
else
flags = 0;
s = strcopy(s, ",ignorecase");
if (options)
{
*s++ = ',';
}
}
#endif
}
#if _lib_getmntinfo && _sys_mount
/*
* 4.4 bsd
*
* what a crappy interface
* data returned in static buffer -- ok
* big chunk of allocated memory that cannot be freed -- come on
* *and* netbsd changed the interface somewhere along the line
* private interface? my bad -- public interface? par for the bsd course
*/
#endif
typedef struct
{
char opt[256];
} Handle_t;
#ifdef MFSNAMELEN
#define TYPE(f) ((f)->f_fstypename)
#else
#ifdef INITMOUNTNAMES
static const char* type[] = INITMOUNTNAMES;
#else
#if _sys_fs_types
#include <sys/fs_types.h>
#else
#endif
#endif
#endif
static struct Mnt_options_t
{
unsigned long flag;
const char* name;
}
options[] =
{
#ifdef MNT_RDONLY
MNT_RDONLY, "rdonly",
#endif
#ifdef MNT_SYNCHRONOUS
MNT_SYNCHRONOUS,"synchronous",
#endif
#ifdef MNT_NOEXEC
MNT_NOEXEC, "noexec",
#endif
#ifdef MNT_NOSUID
MNT_NOSUID, "nosuid",
#endif
#ifdef MNT_NODEV
MNT_NODEV, "nodev",
#endif
#ifdef MNT_UNION
MNT_UNION, "union",
#endif
#ifdef MNT_ASYNC
MNT_ASYNC, "async",
#endif
#ifdef MNT_NOCOREDUMP
MNT_NOCOREDUMP, "nocoredump",
#endif
#ifdef MNT_NOATIME
MNT_NOATIME, "noatime",
#endif
#ifdef MNT_SYMPERM
MNT_SYMPERM, "symperm",
#endif
#ifdef MNT_NODEVMTIME
MNT_NODEVMTIME, "nodevmtime",
#endif
#ifdef MNT_SOFTDEP
MNT_SOFTDEP, "softdep",
#endif
#ifdef MNT_EXRDONLY
MNT_EXRDONLY, "exrdonly",
#endif
#ifdef MNT_EXPORTED
MNT_EXPORTED, "exported",
#endif
#ifdef MNT_DEFEXPORTED
MNT_DEFEXPORTED,"defexported",
#endif
#ifdef MNT_EXPORTANON
MNT_EXPORTANON, "exportanon",
#endif
#ifdef MNT_EXKERB
MNT_EXKERB, "exkerb",
#endif
#ifdef MNT_EXNORESPORT
MNT_EXNORESPORT,"exnoresport",
#endif
#ifdef MNT_EXPUBLIC
MNT_EXPUBLIC, "expublic",
#endif
#ifdef MNT_LOCAL
MNT_LOCAL, "local",
#endif
#ifdef MNT_QUOTA
MNT_QUOTA, "quota",
#endif
#ifdef MNT_ROOTFS
MNT_ROOTFS, "rootfs",
#endif
0, "unknown",
};
void*
{
register int n;
return 0;
{
return 0;
}
return (void*)mp;
}
{
register int i;
register int n;
register unsigned long flags;
{
n = 0;
for (i = 0; i < elementsof(options); i++)
set(&mp->hdr, mp->next->f_mntfromname, mp->next->f_mntonname, TYPE(mp->next), n ? (mp->opt + 1) : (char*)0);
}
return 0;
}
int
{
if (!mp)
return -1;
return 0;
}
#else
#if _lib_mntctl && _sys_vmount
/*
* aix
*/
static const char* type[] =
{
"aix", "aix#1", "nfs", "jfs", "aix#4", "cdrom"
};
typedef struct
{
long count;
char remote[128];
char type[16];
} Handle_t;
void*
{
return 0;
{
return 0;
}
return (void*)mp;
}
{
register char* s;
register char* t;
register char* o;
{
{
}
else
else
o = NiL;
{
#ifdef MNT_AIX
case MNT_AIX:
t = "aix";
break;
#endif
#ifdef MNT_NFS
case MNT_NFS:
t = "nfs";
break;
#endif
#ifdef MNT_JFS
case MNT_JFS:
t = "jfs";
break;
#endif
#ifdef MNT_CDROM
case MNT_CDROM:
t = "cdrom";
break;
#endif
#ifdef MNT_SFS
case MNT_SFS:
t = "sfs";
break;
#endif
#ifdef MNT_CACHEFS
case MNT_CACHEFS:
t = "cachefs";
break;
#endif
#ifdef MNT_NFS3
case MNT_NFS3:
t = "nfs3";
break;
#endif
#ifdef MNT_AUTOFS
case MNT_AUTOFS:
t = "autofs";
break;
#endif
default:
break;
}
}
return 0;
}
int
{
if (!mp)
return -1;
return 0;
}
#else
#if !_lib_setmntent
#endif
#endif
#if defined(__STDPP__directive) && defined(__STDPP__hide)
#else
#define endmntent ______endmntent
#define getmntent ______getmntent
#endif
#include <stdio.h>
#if _hdr_mntent
#include <mntent.h>
#else
#endif
#if defined(__STDPP__directive) && defined(__STDPP__hide)
#else
#endif
#else
#if _hdr_mnttab
#include <mnttab.h>
#else
#if _sys_mnttab
#endif
#endif
#endif
#ifndef MOUNTED
#ifdef MNT_MNTTAB
#define MOUNTED MNT_MNTTAB
#else
#if _hdr_mnttab || _sys_mnttab
#else
#endif
#endif
#endif
#ifdef __Lynx__
#define SEP ':'
#endif
#if _lib_getmntent
typedef struct
#else
#endif
{
} Handle_t;
void*
{
return 0;
{
return 0;
}
return (void*)mp;
}
{
{
}
return 0;
}
int
{
if (!mp)
return -1;
return 0;
}
#else
#if _sys_mntent && _lib_w_getmntent
#define mnt_dir mnt_mountpoint
#define mnt_type mnt_fstname
#else
#endif
#else
#define MNTBUFSIZE sizeof(struct mntent)
#if !_mem_mt_dev_mnttab || !_mem_mt_filsys_mnttab
#endif
#if _hdr_mnttab
#define mnt_fsname mt_dev
#endif
#else
#endif
#else
struct mntent
{
char mnt_fsname[256];
char mnt_dir[256];
char mnt_type[32];
char mnt_opts[64];
};
#endif
#endif
typedef struct
{
#if _lib_w_getmntent
int count;
#endif
char buf[MNTBUFSIZE];
} Handle_t;
void*
{
return 0;
#if _lib_w_getmntent
else
#else
#endif
{
return 0;
}
return (void*)mp;
}
{
#if _lib_w_getmntent
{
return 0;
}
#else
#if _hdr_mnttab
{
#ifndef mnt_type
static char typ[32];
set(&mp->hdr, mp->mnt->mnt_fsname, mp->mnt->mnt_dir, stat(mp->mnt->mnt_dir, &st) ? FS_default : strncpy(typ, fmtfs(&st), sizeof(typ) - 1), OPTIONS(mp->mnt));
#else
#endif
}
return 0;
#else
register int c;
register char* s;
register char* m;
register char* b;
register int q;
register int x;
q = 0;
x = 0;
{
case EOF:
return 0;
case '"':
case '\'':
if (q == c)
q = 0;
else if (!q)
q = c;
break;
#ifdef SEP
case SEP:
#else
case ' ':
case '\t':
#endif
if (s != b && !q) switch (++x)
{
case 1:
*s = 0;
break;
case 2:
*s = 0;
break;
case 3:
*s = 0;
break;
case 4:
*s = 0;
b = s = m = 0;
break;
}
break;
case '\n':
if (x >= 3)
{
}
goto again;
default:
if (s < m)
*s++ = c;
break;
}
#endif
#endif
}
int
{
if (!mp)
return -1;
return 0;
}
#endif
#endif
#endif
/*
* currently no write
*/
int
{
return -1;
}
#endif