/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1989-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
*/
static const char mount_usage[] =
"[-?\n@(#)$Id: mount (AT&T Research) 2011-02-11 $\n]"
"[+NAME?mount - mount and display filesystems]"
"[+DESCRIPTION?\bmount\b attaches a named filesystem \afs\a to the"
" directory \adir\a, which must already exist. The contents of \adir\a"
" are hidden until the filesystem is unmounted. The filesystem mount"
" table is consulted if either of \afs\a or \adir\a are omitted."
" Information on all mounted filesystems is displayed if both"
" \afs\a and \adir\a are omitted.]"
"[a:all?Operate on all filesystems in the filesystem table. The \b--host\b"
" and \b--type\b options can be used to match parts of the table.]"
"[f:show|fake?Display but do not execute the underlying \bmount\b(2)"
" system calls.]"
"[h:hosts?Limit the filesystem table scan to entries matching the \ahost\a"
" names. A leading \b!\b inverts the match sense.]:[[!]]host,...]"
"[M:mtab|fstab?Use \afile\a instead of the default filesystem table.]:[file]"
"[b:omit?Omit filesystem table entries matching any of the \atype\a"
" names.]:[[!]]type,...]"
"[o:options?Specify filesystem specific mount options. Options are a comma"
" separated list of words preceded by an optional \bno\b to turn the"
" option off, or \aname=value\a pairs. Multiple \b--options\b are"
" concatenated with a \bcomma\b separator. See \bfstab\b(4) for"
" a detailed description of mount options.]:[[no]]name[=value]][,...]]]"
"[p:portable?Print information in \bfstab\b(4) format.]"
"[r:readonly?Mount the filesystems read only. Equivalent to \b--option=ro\b.]"
"[t|T:types?Limit the filesystem table scan to entries matching the \atype\a"
" names. A leading \b!\b inverts the match sense.]:[[!]]type,...]"
"[u:unmount|umount?Unmount the matched filesystems.]"
"[c:check?Ignored by this implementation.]"
"[m:multiplex|nproc?Distribute multiple mounts across \anproc\a processes."
" Ignored by this implementation.]"
"[P:prefix?Ignored by this implementation.]:[string]"
"[n!:tab?Ignored by this implementation.]"
"[v:verbose?Ignored by this implementation.]"
"\n"
"\n[ fs [ dir ] ]\n"
"\n"
"[+SEE ALSO?\bdf\b(1), \bumount\b(1), \bmount\b(2), \bfstab\b(4)]"
;
static const char unmount_usage[] =
"[-?\n@(#)$Id: umount (AT&T Research) 1999-11-19 $\n]"
"[+NAME?umount - unmount filesystems]"
"[+DESCRIPTION?\bumount\b unmounts one or more currently mounted filesystems,"
" which can be specified either as mounted-on directories or"
" filesystems.]"
"[a:all?Operate on all filesystems in the filesystem table. The \b--host\b"
" and \b--type\b options can be used to match parts of the table.]"
"[f:show|fake?Display but do not execute the underlying \bumount\b(2)"
" system calls.]"
"[h:hosts?Limit the filesystem table scan to entries matching the \ahost\a"
" names. A leading \b!\b inverts the match sense.]:[[!]]host,...]"
"[M:mtab|fstab?Use \afile\a instead of the default filesystem table.]:[file]"
"[b:omit?Omit filesystem table entries matching any of the \atype\a"
" names.]:[[!]]type,...]"
"[t|T:types?Limit the filesystem table scan to entries matching the \atype\a"
" names. A leading \b!\b inverts the match sense.]:[[!]]type,...]"
"[m:multiplex|nproc?Distribute multiple mounts across \anproc\a processes."
" Ignored by this implementation.]"
"[P:prefix?Ignored by this implementation.]:[string]"
"[v:verbose?Ignored by this implementation.]"
"\n"
"\n[ fs | dir ]\n"
"\n"
"[+SEE ALSO?\bdf\b(1), \bmount\b(1), \bumount\b(2), \bfstab\b(4)]"
;
#if defined(__STDPP__directive) && defined(__STDPP__hide)
#else
#define mount ______mount
#define umount ______umount
#define unmount ______unmount
#endif
#include <ast.h>
#include <error.h>
#include <cdt.h>
#include <ctype.h>
#include <ls.h>
#include <mnt.h>
#include <ast_fs.h>
#if _sys_mount
#endif
#ifndef NGROUPS
#endif
#endif
#if defined(__STDPP__directive) && defined(__STDPP__hide)
#else
#endif
extern int mount(const char*, const char*, int, const char*, const char*, int);
extern int umount(const char*, int);
extern int unmount(const char*);
#if _lib_unmount && !_lib_umount
#endif
#ifndef FSTAB
#endif
#ifndef MS_DATA
#endif
typedef int (*Cmp_f)(const char*, const char*);
typedef struct
{
int flags;
} Match_t;
typedef struct
{
int all;
int check;
int fake;
int fstabable;
int notab;
int nproc;
int unmount;
int verbose;
char* host;
char* mtab;
char* options;
char* prefix;
char* type;
int matchflags;
} State_t;
static int
{
}
static void
{
register int c;
register char* b;
register Match_t* p;
{
}
if (*s == '!')
{
s++;
flags <<= 1;
}
for (;;)
{
while (isspace(*s))
s++;
for (b = s; (c = *s) && c != ',' && !isspace(c); s++);
if (s == b)
break;
if (c)
*s = 0;
{
}
if (!c)
break;
*s++ = c;
}
}
static int
matchhost(char* s)
{
char* t;
char* u;
char* v;
Match_t* p;
return 1;
if (!(t = strchr(s, ':')))
return 0;
*t = 0;
for (u = s; v = strchr(u, '.'); u = v)
{
*v = 0;
*v++ = '.';
if (p)
break;
u = v;
}
*t = ':';
return p && (p->flags & MATCH_HOST);
return !p || !(p->flags & MATCH_NOHOST);
}
static int
matchtype(char* s)
{
Match_t* p;
return 1;
return p && (p->flags & MATCH_TYPE);
return !p || !(p->flags & MATCH_NOTYPE);
}
static void
{
char* s;
int n;
{
}
else
{
sfprintf(sfstderr, "mount(\"%s\",\"%s\",0x%08x,\"%s\",\"%s\",%d)\n", mnt->fs, mnt->dir, mnt->flags|MS_DATA, mnt->type, s, n);
}
}
int
{
register char* s;
const char* usage;
void* mp;
char* p;
int trydefault;
s++;
else
s = *argv;
error_info.id = s;
state.matchflags = 0;
for (;;)
{
{
case 'a':
continue;
case 'b':
continue;
case 'c':
continue;
case 'f':
continue;
case 'h':
continue;
case 'm':
continue;
case 'n':
continue;
case 'o':
continue;
case 'p':
continue;
case 'r':
continue;
case 't':
case 'T':
continue;
case 'u':
continue;
case 'v':
continue;
case 'M':
continue;
case 'P':
continue;
case '?':
break;
case ':':
break;
case 0:
break;
default:
break;
}
break;
}
if (error_info.errors)
if ((s = *argv) && !*++argv && !state.mtab || state.mtab && (!*state.mtab || streq(state.mtab, "-")) || !state.mtab && (state.all || state.match))
{
else
}
if (!s)
{
{
}
{
}
else
{
}
}
else if (!*argv)
{
for (;;)
{
{
while (*p)
{
{
break;
}
while (*p && *p++ != ',');
}
{
break;
}
}
if (!mnt)
{
{
trydefault = 0;
continue;
}
}
break;
}
}
else if (!*(argv + 1))
{
}
else
exit(0);
}
#else
int
{
register char* s;
s++;
else
s = *argv;
}
#endif