* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* Jan-Simon Pendry at Imperial College, London.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* @(#)mount_fs.c 5.3 (Berkeley) 5/12/91
* $Id: mount_fs.c,v 5.2.1.4 91/05/07 22:18:13 jsp Alpha $
typedef nfs_fh fhandle_t
;
* HP-UX has an annoying feature of printing
* error msgs on /dev/console
struct opt_tab mnt_flags
[] = {
{ "nocache", M_NOCACHE
},
int compute_mount_flags(mnt
)
* Crack basic mount options
for (opt
= mnt_flags
; opt
->opt
; opt
++)
flags
|= hasmntopt(mnt
, opt
->opt
) ? opt
->flag
: 0;
int mount_fs
P((struct mntent
*mnt
, int flags
, caddr_t mnt_data
, int retry
, MTYPE_TYPE type
));
int mount_fs(mnt
, flags
, mnt_data
, retry
, type
)
dlog("%s fstype %s (%s) flags %#x (%s)",
mnt
->mnt_dir
, type
, mnt
->mnt_type
, flags
, mnt
->mnt_opts
);
dlog("%s fstype %d (%s) flags %#x (%s)",
mnt
->mnt_dir
, type
, mnt
->mnt_type
, flags
, mnt
->mnt_opts
);
* Fake some mount table entries for the automounter
#ifdef FASCIST_DF_COMMAND
* Some systems have a df command which blows up when
* presented with an unknown mount type.
if (STREQ(mnt
->mnt_type
, MNTTYPE_AUTO
)) {
* Try it with the normal name
mnt
->mnt_type
= MNTTYPE_NFS
;
#endif /* FASCIST_DF_COMMAND */
error
= MOUNT_TRAP(type
, mnt
, flags
, mnt_data
);
plog(XLOG_ERROR
, "%s: mount: %m", mnt
->mnt_dir
);
if (error
< 0 && --retry
> 0) {
* Add the extra dev= field to the mount table.
if (lstat(mnt
->mnt_dir
, &stb
) == 0) {
char *zopts
= (char *) xmalloc(strlen(mnt
->mnt_opts
) + 32);
if (sizeof(stb
.st_dev
) == 2) {
sprintf(zopts
, "%s,%s=%s%04lx", xopts
, MNTINFO_DEV
,
MNTINFO_PREF
, (u_long
) stb
.st_dev
& 0xffff);
sprintf(zopts
, "%s,%s=%s%08lx", xopts
, MNTINFO_DEV
,
MNTINFO_PREF
, (u_long
) stb
.st_dev
);
* Additional fields in struct mntent
#ifdef NEED_MNTOPT_PARSER
* Some systems don't provide these to the user,
* but amd needs them, so...
* From: Piete Brooks <pb@cl.cam.ac.uk>
static char *nextmntopt(p
)
while (*cp
&& isspace(*cp
))
* Scan to send of string or separator
while (*cp
&& *cp
!= ',')
* If separator found the overwrite with nul char.
* Return value for next call
char *hasmntopt(mnt
, opt
)
strcpy(t
, mnt
->mnt_opts
);
while (*(f
= nextmntopt(&o
)))
if (strncmp(opt
, f
, l
) == 0)
return f
- t
+ mnt
->mnt_opts
;
#endif /* NEED_MNTOPT_PARSER */
#ifdef MOUNT_HELPER_SOURCE
#include MOUNT_HELPER_SOURCE
#endif /* MOUNT_HELPER_SOURCE */