* $Id: mount_fs.c,v 5.2 90/06/23 22:19:42 jsp Rel $
* 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.
* %sccs.include.redist.c%
* @(#)mount_fs.c 5.1 (Berkeley) %G%
typedef nfs_fh fhandle_t
;
* System Vr4 / SunOS 4.1 compatibility
* - put dev= in the options list
* From: Brent Callaghan <brent@eng.sun.com>
#define MNTINFO_DEV "dev"
* 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(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
if (STREQ(mnt
->mnt_type
, MNTTYPE_AUTO
)) {
mnt
->mnt_fsname
= pid_fsname
;
* Try it with the normal name
* This is notdef'ed because some systems use
* the mount table in getwd() (esp. SunOS4) and
* if all the mount points are not marked it can
* cause major confusion. This can probably
* be changed when no-one is running SunOS 4.0
mnt
->mnt_type
= MNTTYPE_IGNORE
;
mnt
->mnt_type
= MNTTYPE_NFS
;
* Background the mount, so that the stat of the
* mountpoint is done in a background process.
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=%04lx", xopts
, MNTINFO_DEV
,
(u_long
) stb
.st_dev
& 0xffff);
sprintf(zopts
, "%s,%s=%08lx", xopts
, MNTINFO_DEV
,
* Yet another gratuitously incompatible change in HP-UX
mnt
->mnt_time
= clocktime();
* Needed this way since mnt may contain a pointer
* to a local variable in this stack frame.
#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 */
static int aix3_mkvp(p
, gfstype
, flags
, object
, stub
, host
, info
, info_size
, args
)
struct vmount
*vp
= (struct vmount
*) p
;
bzero((voidp
) vp
, sizeof(*vp
));
* Fill in standard fields
vp
->vmt_revision
= VMT_REVISION
;
vp
->vmt_gfstype
= gfstype
;
#define VMT_ROUNDUP(len) (4 * ((len + 3) / 4))
#define VMT_ASSIGN(vp, idx, data, size) \
vp->vmt_data[idx].vmt_off = p - (char *) vp; \
vp->vmt_data[idx].vmt_size = size; \
* Fill in all variable length data
VMT_ASSIGN(vp
, VMT_OBJECT
, object
, strlen(object
) + 1);
VMT_ASSIGN(vp
, VMT_STUB
, stub
, strlen(stub
) + 1);
VMT_ASSIGN(vp
, VMT_HOST
, host
, strlen(host
) + 1);
VMT_ASSIGN(vp
, VMT_HOSTNAME
, host
, strlen(host
) + 1);
VMT_ASSIGN(vp
, VMT_INFO
, info
, info_size
);
VMT_ASSIGN(vp
, VMT_ARGS
, args
, strlen(args
) + 1);
return vp
->vmt_length
= p
- (char *) vp
;
* Map from conventional mount arguments
* to AIX 3-style arguments.
aix3_mount(fsname
, dir
, flags
, type
, data
, args
)
dlog("aix3_mount: fsname %s, dir %s, type %d", fsname
, dir
, type
);
/* aix3_mkvp(p, gfstype, flags, object, stub, host, info, info_size, args) */
char *host
= strdup(fsname
);
char *rfs
= strchr(host
, ':');
size
= aix3_mkvp(buf
, type
, flags
, rfs
, dir
, host
, data
, sizeof(struct nfs_args
), args
);
/* Need to open block device and extract log device info from sblk. */
/*dlog("aix3_mkvp: flags %#x, size %d, args %s", flags, size, args);*/
return vmount(buf
, size
);