longname, nowin95, shortname, uid=N, gid=N, mask=N, and dirmask=N.
* amd/ops_pcfs.c (mount_pcfs): process new pcfs options longname,
nowin95, shortname, uid=N, gid=N, mask=N, and dirmask=N.
* include/am_compat.h: provide compatibility mnttab string names,
if needed, for pcfs mount options longname, nowin95, shortname,
uid=N, gid=N, mask=N, and dirmask=N.
* include/am_utils.h: extern for hasmntstr().
* libamu/mtab.c (hasmntstr): new function to return the string
value following a mount option, up to the next comma-delimited
options.
* configure.in: check for mnttab and pcfs options longname,
nowin95, and shortname.
* Makefile.am (EXTRA_DIST_M4): distribute new macro
check_mnt2_pcfs_opt.m4.
* m4/macros/check_mnt2_pcfs_opt.m4: new macro to check for pcfs
mnttab and mount options.
+2005-10-19 Erez Zadok <ezk@cs.sunysb.edu>
+
+ * doc/am-utils.texi (opts Option): document new pcfs options
+ longname, nowin95, shortname, uid=N, gid=N, mask=N, and dirmask=N.
+
+ * amd/ops_pcfs.c (mount_pcfs): process new pcfs options longname,
+ nowin95, shortname, uid=N, gid=N, mask=N, and dirmask=N.
+
+ * include/am_compat.h: provide compatibility mnttab string names,
+ if needed, for pcfs mount options longname, nowin95, shortname,
+ uid=N, gid=N, mask=N, and dirmask=N.
+
+ * include/am_utils.h: extern for hasmntstr().
+
+ * libamu/mtab.c (hasmntstr): new function to return the string
+ value following a mount option, up to the next comma-delimited
+ options.
+
+ * configure.in: check for mnttab and pcfs options longname,
+ nowin95, and shortname.
+
+ * Makefile.am (EXTRA_DIST_M4): distribute new macro
+ check_mnt2_pcfs_opt.m4.
+
+ * m4/macros/check_mnt2_pcfs_opt.m4: new macro to check for pcfs
+ mnttab and mount options.
+
2005-10-18 Erez Zadok <ezk@cs.sunysb.edu>
* libamu/mount_fs.c (print_nfs_args): print nfs_args->addr
m4/macros/check_mnt2_cdfs_opt.m4 \
m4/macros/check_mnt2_gen_opt.m4 \
m4/macros/check_mnt2_nfs_opt.m4 \
+ m4/macros/check_mnt2_pcfs_opt.m4 \
m4/macros/check_mnttab_file_name.m4 \
m4/macros/check_mnttab_location.m4 \
m4/macros/check_mnttab_opt.m4 \
*** Notes specific to am-utils version 6.2a2
+Support new mount options for type:=pcfs mounts: longname, nowin95,
+shortname, uid=N, gid=N, mask=N, and dirmask=N.
+
- Bugs fixed:
* correctly print nfs_args->addr info (sin_family/port/addr)
pcfs_args_t pcfs_args;
mntent_t mnt;
int flags;
+#if defined(HAVE_PCFS_ARGS_T_MASK) || defined(HAVE_PCFS_ARGS_T_DIRMASK)
+ int mask;
+#endif /* defined(HAVE_PCFS_ARGS_T_MASK) || defined(HAVE_PCFS_ARGS_T_DIRMASK) */
+#if defined(HAVE_PCFS_ARGS_T_UID) || defined(HAVE_PCFS_ARGS_T_UID)
+ char *str;
+#endif /* defined(HAVE_PCFS_ARGS_T_UID) || defined(HAVE_PCFS_ARGS_T_UID) */
/*
* Figure out the name of the file system type.
if (on_autofs)
flags |= autofs_compute_mount_flags(&mnt);
#endif /* HAVE_FS_AUTOFS */
+ if (amuDebug(D_TRACE))
+ plog(XLOG_DEBUG, "mount_pcfs: flags=0x%x", (u_int) flags);
#ifdef HAVE_PCFS_ARGS_T_FSPEC
pcfs_args.fspec = fs_name;
#ifdef HAVE_PCFS_ARGS_T_MASK
pcfs_args.mask = 0777; /* this may be the msdos file modes */
+ if ((mask = hasmntval(&mnt, MNTTAB_OPT_MASK)) > 0)
+ pcfs_args.mask = mask;
+ if (amuDebug(D_TRACE))
+ plog(XLOG_DEBUG, "mount_pcfs: mask=%o (octal)", (u_int) pcfs_args.mask);
#endif /* HAVE_PCFS_ARGS_T_MASK */
#ifdef HAVE_PCFS_ARGS_T_DIRMASK
pcfs_args.dirmask = 0777; /* this may be the msdos dir modes */
+ if ((mask = hasmntval(&mnt, MNTTAB_OPT_DIRMASK)) > 0)
+ pcfs_args.dirmask = mask;
+ if (amuDebug(D_TRACE))
+ plog(XLOG_DEBUG, "mount_pcfs: dirmask=%o (octal)", (u_int) pcfs_args.dirmask);
#endif /* HAVE_PCFS_ARGS_T_DIRMASK */
#ifdef HAVE_PCFS_ARGS_T_UID
- pcfs_args.uid = 0; /* root */
+ pcfs_args.uid = 0; /* default to root */
+ if ((str = hasmntstr(&mnt, MNTTAB_OPT_UID)) != NULL) {
+ struct passwd *pw;
+ if ((pw = getpwnam(str)) != NULL)
+ pcfs_args.uid = pw->pw_uid;
+ else /* maybe used passed a UID number, not user name */
+ pcfs_args.uid = atoi(str); /* atoi returns '0' if it failed */
+ XFREE(str);
+ }
+ if (amuDebug(D_TRACE))
+ plog(XLOG_DEBUG, "mount_pcfs: uid=%d", (int) pcfs_args.uid);
#endif /* HAVE_PCFS_ARGS_T_UID */
#ifdef HAVE_PCFS_ARGS_T_GID
- pcfs_args.gid = 0; /* wheel */
+ pcfs_args.gid = 0; /* default to wheel/root group */
+ if ((str = hasmntstr(&mnt, MNTTAB_OPT_GID)) != NULL) {
+ struct group *gr;
+ if ((gr = getgrnam(str)) != NULL)
+ pcfs_args.gid = gr->gr_gid;
+ else /* maybe used passed a GID number, not group name */
+ pcfs_args.gid = atoi(str); /* atoi returns '0' if it failed */
+ XFREE(str);
+ }
+ if (amuDebug(D_TRACE))
+ plog(XLOG_DEBUG, "mount_pcfs: gid=%d", (int) pcfs_args.gid);
#endif /* HAVE_PCFS_ARGS_T_GID */
#ifdef HAVE_PCFS_ARGS_T_SECONDSWEST
dnl
dnl AC_CONFIG_AUX_DIR(m4)
AC_PREREQ(2.52)
-AC_REVISION($Revision: 1.121 $)
+AC_REVISION($Revision: 1.122 $)
AC_COPYRIGHT([Copyright (c) 1997-2005 Erez Zadok])
dnl find out system type
AC_MSG_NOTICE(*** SYSTEM TYPES ***)
grpid \
ignore \
intr \
+ longname \
maxgroups \
multi \
noac \
nocto \
nosub \
nosuid \
+ nowin95 \
pgthresh \
port \
posix \
ro \
rsize \
rw \
+ shortname \
soft \
spongy \
suid \
)
dnl ======================================================================
+dnl ######################################################################
+dnl PCFS-specific mount(2) options (hex numbers) like M_*
+AC_MSG_NOTICE(*** PCFS-SPECIFIC MOUNT(2) OPTIONS ***)
+dnl if found, defines MNT2_PCFS_OPT_*
+AMU_CHECK_MNT2_PCFS_OPTS(\
+ longname \
+ nowin95 \
+ shortname \
+ )
+dnl ======================================================================
+
dnl *********
AMU_SAVE_STATE
dnl *********
@example
#!/bin/sh
-# execuatable map example
+# executable map example
case "$1" in
"/defaults" )
echo "/defaults type:=nfs;rfs:=filer"
@cindex Mount flags; dev
Allow local special devices on this filesystem.
+@item dirmask=@var{n}
+@cindex Mount flags; dirmask
+For PCFS mounts, specify the maximum file permissions for directories
+in the file system. See the @samp{mask} option's description for more
+details. The mask value of @var{n} can be specified in decimal,
+octal, or hexadecimal.
+
@item dumbtimr
@cindex Mount flags; dumbtimr
Turn off the dynamic retransmit timeout estimator. This may be useful
Enable generations in ISO-9660 file systems. Generations allow you to
see all versions of a given file.
+@item gid=@var{n}
+@cindex Mount flags; gid
+For PCFS mounts, set the group of the files in the file system to
+@var{n} (which can either be a group name or a GID number). The
+default group is the group of the directory on which the file system
+is being mounted.
+
@item grpid
@cindex Mount flags; grpid
Use BSD directory group-id semantics.
@cindex Mount flags; lock
Use the NFS locking protocol (default)
+@item longname
+@cindex Mount Flags; longname
+For PCFS mounts, force Win95 long names.
+
+@item mask=@var{n}
+@cindex Mount flags; mask
+For PCFS mounts, specify the maximum file permissions for files in the
+file system. For example, a mask of 755 specifies that, by default,
+the owner should have read, write, and execute permissions for files,
+but others should only have read and execute permissions. Only the
+nine low-order bits of mask are used. The default mask is taken from
+the directory on which the file system is being mounted. The mask
+value of @var{n} can be specified in decimal, octal, or hexadecimal.
+
@item multi
@cindex Mount flags; multi
Perform multi-component lookup on files.
Strip the extension @samp{;#} from the version string of files recorded
on an ISO-9660 CD-ROM.
+@item nowin95
+@cindex Mount Flags; nowin95
+For PCFS mounts, completely ignore Win95 entries.
+
@item optionstr
@cindex Mount flags; optionstr
Under Solaris 8, provide the kernel a string of options to parse and
@cindex Mount flags; rw
Allow reads and writes on this filesystem.
+@item shortname
+@cindex Mount Flags; longname
+For PCFS mounts, force old DOS short names only.
+
@item soft
@cindex Mount flags; soft
Give up after @dfn{retrans} retransmissions.
@cindex Mount flags; timeo
The NFS timeout, in tenth-seconds, before a request is retransmitted.
+@item uid=@var{n}
+@cindex Mount flags; uid
+For PCFS mounts, set the owner of the files in the file system to
+@var{n} (which can either be a user name or a UID number). The
+default owner is the owner of the directory on which the file system
+is being mounted.
+
@item vers=@var{n}
@cindex Mount flags; vers
Use NFS protocol version number @var{n} (can be 2 or 3).
@item softlookup
@cindex Mount flags; softlookup
-Configures amd's behavior with respect to already-mounted shares from
+Configures @i{Amd}'s behavior with respect to already-mounted shares from
NFS fileservers that are unreachable. If softlookup is specified,
trying to access such a share will result in an error (EIO, which is
changed from the ENOENT 6.0 used to return). If it is not specified, a
EBUSY. At that point, @i{Amd} can do little to recover that hung
point (in fact, the OS cannot automatically recover either). For that
reason, some OSs support special kinds of forced unmounts, which must
-be used very carefully: they will force an ummount immediately (or
+be used very carefully: they will force an unmount immediately (or
lazily on Linux), which could result in application data loss.
However, that may be the only way to recover the entire host (without
rebooting). Once a hung mount point is forced out, @i{Amd} can then
# define MNTTAB_OPT_EXTATT "extatt"
#endif /* defined(MNT2_CDFS_OPT_EXTATT) && !defined(MNTTAB_OPT_EXTATT) */
+/*
+ * Complete MNTTAB_OPT_* options based on MNT2_PCFS_OPT_* mount options.
+ */
+#if defined(MNT2_PCFS_OPT_LONGNAME) && !defined(MNTTAB_OPT_LONGNAME)
+# define MNTTAB_OPT_LONGNAME "longnames"
+#endif /* defined(MNT2_PCFS_OPT_LONGNAME) && !defined(MNTTAB_OPT_LONGNAME) */
+#if defined(MNT2_PCFS_OPT_NOWIN95) && !defined(MNTTAB_OPT_NOWIN95)
+# define MNTTAB_OPT_NOWIN95 "nowin95"
+#endif /* defined(MNT2_PCFS_OPT_NOWIN95) && !defined(MNTTAB_OPT_NOWIN95) */
+#if defined(MNT2_PCFS_OPT_SHORTNAME) && !defined(MNTTAB_OPT_SHORTNAME)
+# define MNTTAB_OPT_SHORTNAME "shortnames"
+#endif /* defined(MNT2_PCFS_OPT_SHORTNAME) && !defined(MNTTAB_OPT_SHORTNAME) */
+
/*
* Complete MNTTAB_OPT_* options based on MNT2_GEN_OPT_* mount options.
*/
# define MNTTAB_OPT_WSIZE "wsize"
#endif /* not MNTTAB_OPT_WSIZE */
+/* next four are useful for pcfs mounts */
+#ifndef MNTTAB_OPT_UID
+# define MNTTAB_OPT_UID "uid"
+#endif /* not MNTTAB_OPT_UID */
+#ifndef MNTTAB_OPT_GID
+# define MNTTAB_OPT_GID "gid"
+#endif /* not MNTTAB_OPT_GID */
+#ifndef MNTTAB_OPT_MASK
+# define MNTTAB_OPT_MASK "mask"
+#endif /* not MNTTAB_OPT_MASK */
+#ifndef MNTTAB_OPT_DIRMASK
+# define MNTTAB_OPT_DIRMASK "dirmask"
+#endif /* not MNTTAB_OPT_DIRMASK */
/*
* Incomplete filesystem definitions (sunos4, irix6, solaris2)
extern u_long get_amd_program_number(void);
extern int getcreds(struct svc_req *, uid_t *, gid_t *, SVCXPRT *);
extern int hasmntval(mntent_t *, char *);
+extern char *hasmntstr(mntent_t *, char *);
extern char *hasmnteq(mntent_t *, char *);
extern char *haseq(char *);
extern int is_network_member(const char *net);
# include <isofs/cd9660/cd9660_mount.h>
#endif /* HAVE_ISOFS_CD9660_CD9660_MOUNT_H */
+#ifdef HAVE_SYS_FS_PC_FS_H
+# include <sys/fs/pc_fs.h>
+#endif /* HAVE_SYS_FS_PC_FS_H */
+#ifdef HAVE_MSDOSFS_MSDOSFSMOUNT_H
+# include <msdosfs/msdosfsmount.h>
+#endif /* HAVE_MSDOSFS_MSDOSFSMOUNT_H */
+#ifdef HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H
+# include <fs/msdosfs/msdosfsmount.h>
+#endif /* HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H */
+
#ifdef HAVE_RPC_RPC_H
# include <rpc/rpc.h>
#endif /* HAVE_RPC_RPC_H */
/*
* Utility routine which returns a pointer to whatever
* follows an = in a mount option. Returns null if option
- * doesn't exist or doesn't have an '='. Won't fall for opt,foo=.
+ * doesn't exist or doesn't have an '='. Won't fail for opt,foo=.
*/
char *
hasmnteq(mntent_t *mnt, char *opt)
}
return 0;
}
+
+
+/*
+ * Utility routine which returns the string value of
+ * an option in the mount options (such as proto=udp).
+ * Returns NULL if the option is not specified.
+ * Returns malloc'ed string (caller must free!)
+ */
+char *
+hasmntstr(mntent_t *mnt, char *opt)
+{
+ char *str = amu_hasmntopt(mnt, opt);
+
+ if (str) { /* The option was there */
+
+ char *eq = hasmnteq(mnt, opt);
+
+ if (eq) { /* and had an = after it */
+
+ char *endptr = strchr(eq, ',');
+
+ /* if saw no comma, return strdup'd string */
+ if (!endptr)
+ return strdup(eq);
+ else {
+ /* else we need to copy only the chars needed */
+ int len = endptr - eq;
+ char *buf = xmalloc(len + 1);
+ strncpy(buf, eq, len);
+ buf[len] = '\0';
+ return buf;
+ }
+ }
+ }
+ return NULL;
+}
--- /dev/null
+dnl ######################################################################
+dnl Find PCFS-specific mount(2) options (hex numbers)
+dnl Usage: AMU_CHECK_MNT2_PCFS_OPT(<fs>)
+dnl Check if there is an entry for MS_<fs> or M_<fs> in sys/mntent.h or
+dnl mntent.h, then define MNT2_PCFS_OPT_<fs> to the hex number.
+AC_DEFUN([AMU_CHECK_MNT2_PCFS_OPT],
+[
+# what name to give to the fs
+ac_fs_name=$1
+# store variable name of fs
+ac_upcase_fs_name=`echo $ac_fs_name | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ac_safe=MNT2_PCFS_OPT_$ac_upcase_fs_name
+# check for cache and set it if needed
+AMU_CACHE_CHECK_DYNAMIC(for PCFS-specific mount(2) option $ac_fs_name,
+ac_cv_mnt2_pcfs_opt_$ac_fs_name,
+[
+# undefine by default
+eval "ac_cv_mnt2_pcfs_opt_$ac_fs_name=notfound"
+value=notfound
+
+# first, try MS_* (most systems). Must be the first test!
+if test "$value" = notfound
+then
+AMU_EXPAND_CPP_HEX(
+AMU_MOUNT_HEADERS
+, MS_$ac_upcase_fs_name)
+fi
+
+# if failed, try MNT_* (bsd44 systems)
+if test "$value" = notfound
+then
+AMU_EXPAND_CPP_HEX(
+AMU_MOUNT_HEADERS
+, MNT_$ac_upcase_fs_name)
+fi
+
+# if failed, try MS_* as an integer (linux systems)
+if test "$value" = notfound
+then
+AMU_EXPAND_CPP_INT(
+AMU_MOUNT_HEADERS
+, MS_$ac_upcase_fs_name)
+fi
+
+# If failed try M_* (must be last test since svr4 systems define M_DATA etc.
+# in <sys/stream.h>
+# This test was off for now, because of the conflicts with other systems.
+# but I turned it back on by faking the inclusion of <sys/stream.h> already.
+if test "$value" = notfound
+then
+AMU_EXPAND_CPP_HEX(
+#ifndef _sys_stream_h
+# define _sys_stream_h
+#endif /* not _sys_stream_h */
+#ifndef _SYS_STREAM_H
+# define _SYS_STREAM_H
+#endif /* not _SYS_STREAM_H */
+AMU_MOUNT_HEADERS
+, M_$ac_upcase_fs_name)
+fi
+
+# if failed, try MSDOSFSMNT_* as a hex (bsd44 systems)
+if test "$value" = notfound
+then
+AMU_EXPAND_CPP_HEX(
+AMU_MOUNT_HEADERS
+, MSDOSFSMNT_$ac_upcase_fs_name)
+fi
+
+# set cache variable to value
+eval "ac_cv_mnt2_pcfs_opt_$ac_fs_name=$value"
+])
+# outside cache check, if ok, define macro
+ac_tmp=`eval echo '$''{ac_cv_mnt2_pcfs_opt_'$ac_fs_name'}'`
+if test "${ac_tmp}" != notfound
+then
+ AC_DEFINE_UNQUOTED($ac_safe, $ac_tmp)
+fi
+])
+dnl ======================================================================
+
+dnl ######################################################################
+dnl run AMU_CHECK_MNT2_PCFS_OPT on each argument given
+dnl Usage: AMU_CHECK_MNT2_PCFS_OPTS(arg arg arg ...)
+AC_DEFUN([AMU_CHECK_MNT2_PCFS_OPTS],
+[
+for ac_tmp_arg in $1
+do
+AMU_CHECK_MNT2_PCFS_OPT($ac_tmp_arg)
+done
+])
+dnl ======================================================================
AH_TEMPLATE([MNTTAB_OPT_PROPLIST],
[Mount Table option string: support property lists (ACLs)])
+AH_TEMPLATE([MNTTAB_OPT_LONGNAME],
+[Force Win95 long names])
+
+AH_TEMPLATE([MNTTAB_OPT_NOWIN95],
+[Completely ignore Win95 entries])
+
+AH_TEMPLATE([MNTTAB_OPT_SHORTNAME],
+[Force old DOS short names only])
+
+
AH_TEMPLATE([MNT2_GEN_OPT_ASYNC],
[asynchronous filesystem access])
AH_TEMPLATE([MNT2_CDFS_OPT_RRIP],
[Use Rock Ridge Interchange Protocol (RRIP) extensions])
+AH_TEMPLATE([MNT2_PCFS_OPT_LONGNAME],
+[Force Win95 long names])
+
+AH_TEMPLATE([MNT2_PCFS_OPT_NOWIN95],
+[Completely ignore Win95 entries])
+
+AH_TEMPLATE([MNT2_PCFS_OPT_SHORTNAME],
+[Force old DOS short names only])
+
AH_TEMPLATE([HAVE_MNTENT_T_MNT_TIME_STRING],
[does mntent_t have mnt_time field and is of type "char *" ?])