From: Erez Zadok Date: Wed, 19 Oct 2005 23:54:35 +0000 (+0000) Subject: * doc/am-utils.texi (opts Option): document new pcfs options X-Git-Tag: am-utils-6_2a2~33 X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=118e368daf3af74a71347f82180f431be916eac5;p=am-utils-6.1.git * 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. --- diff --git a/ChangeLog b/ChangeLog index 9084624..7cf7c72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2005-10-19 Erez Zadok + + * 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 * libamu/mount_fs.c (print_nfs_args): print nfs_args->addr diff --git a/Makefile.am b/Makefile.am index ce9a393..09c0639 100644 --- a/Makefile.am +++ b/Makefile.am @@ -60,6 +60,7 @@ EXTRA_DIST_M4 = \ 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 \ diff --git a/NEWS b/NEWS index f3107a6..5197109 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ *** 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) diff --git a/amd/ops_pcfs.c b/amd/ops_pcfs.c index c89446d..b26d315 100644 --- a/amd/ops_pcfs.c +++ b/amd/ops_pcfs.c @@ -107,6 +107,12 @@ mount_pcfs(char *mntdir, char *fs_name, char *opts, int on_autofs) 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. @@ -129,6 +135,8 @@ mount_pcfs(char *mntdir, char *fs_name, char *opts, int on_autofs) 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; @@ -136,18 +144,46 @@ mount_pcfs(char *mntdir, char *fs_name, char *opts, int on_autofs) #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 diff --git a/configure.in b/configure.in index 0064c9e..1f0ff17 100644 --- a/configure.in +++ b/configure.in @@ -55,7 +55,7 @@ AH_BOTTOM([ 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 ***) @@ -1059,6 +1059,7 @@ AMU_CHECK_MNTTAB_OPTS( \ grpid \ ignore \ intr \ + longname \ maxgroups \ multi \ noac \ @@ -1067,6 +1068,7 @@ AMU_CHECK_MNTTAB_OPTS( \ nocto \ nosub \ nosuid \ + nowin95 \ pgthresh \ port \ posix \ @@ -1079,6 +1081,7 @@ AMU_CHECK_MNTTAB_OPTS( \ ro \ rsize \ rw \ + shortname \ soft \ spongy \ suid \ @@ -1198,6 +1201,17 @@ AMU_CHECK_MNT2_CDFS_OPTS(\ ) 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 ********* diff --git a/doc/am-utils.texi b/doc/am-utils.texi index 9f390e5..6c379ca 100644 --- a/doc/am-utils.texi +++ b/doc/am-utils.texi @@ -1126,7 +1126,7 @@ should be printed out. Below is an sample of such a map script: @example #!/bin/sh -# execuatable map example +# executable map example case "$1" in "/defaults" ) echo "/defaults type:=nfs;rfs:=filer" @@ -2087,6 +2087,13 @@ UID 0, and GID 0. Useful for CD-ROMs formatted as ISO-9660. @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 @@ -2106,6 +2113,13 @@ Set ID of filesystem. 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. @@ -2120,6 +2134,20 @@ Allow keyboard interrupts on hard mounts. @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. @@ -2201,6 +2229,10 @@ Don't allow set-uid or set-gid executables on this filesystem. 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 @@ -2277,6 +2309,10 @@ NFS/UDP through a gateway or a slow link. @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. @@ -2306,6 +2342,13 @@ support TCP/IP mounts. @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). @@ -2368,7 +2411,7 @@ The number of times to retry the mount system call. @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 @@ -4510,7 +4553,7 @@ attempting to unmount an existing mount point, or even just to 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 diff --git a/include/am_compat.h b/include/am_compat.h index a430e16..9901cda 100644 --- a/include/am_compat.h +++ b/include/am_compat.h @@ -180,6 +180,19 @@ # 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. */ @@ -271,6 +284,19 @@ # 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) diff --git a/include/am_utils.h b/include/am_utils.h index 43a8bcd..a64048a 100644 --- a/include/am_utils.h +++ b/include/am_utils.h @@ -293,6 +293,7 @@ extern int compute_mount_flags(mntent_t *); 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); diff --git a/include/mount_headers1.h b/include/mount_headers1.h index c5c490e..1c07272 100644 --- a/include/mount_headers1.h +++ b/include/mount_headers1.h @@ -192,6 +192,16 @@ # include #endif /* HAVE_ISOFS_CD9660_CD9660_MOUNT_H */ +#ifdef HAVE_SYS_FS_PC_FS_H +# include +#endif /* HAVE_SYS_FS_PC_FS_H */ +#ifdef HAVE_MSDOSFS_MSDOSFSMOUNT_H +# include +#endif /* HAVE_MSDOSFS_MSDOSFSMOUNT_H */ +#ifdef HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H +# include +#endif /* HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H */ + #ifdef HAVE_RPC_RPC_H # include #endif /* HAVE_RPC_RPC_H */ diff --git a/libamu/mtab.c b/libamu/mtab.c index 620fc6b..a5def0a 100644 --- a/libamu/mtab.c +++ b/libamu/mtab.c @@ -117,7 +117,7 @@ haseq(char *instr) /* * 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) @@ -176,3 +176,39 @@ hasmntval(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; +} diff --git a/m4/macros/check_mnt2_pcfs_opt.m4 b/m4/macros/check_mnt2_pcfs_opt.m4 new file mode 100644 index 0000000..d1c3043 --- /dev/null +++ b/m4/macros/check_mnt2_pcfs_opt.m4 @@ -0,0 +1,92 @@ +dnl ###################################################################### +dnl Find PCFS-specific mount(2) options (hex numbers) +dnl Usage: AMU_CHECK_MNT2_PCFS_OPT() +dnl Check if there is an entry for MS_ or M_ in sys/mntent.h or +dnl mntent.h, then define MNT2_PCFS_OPT_ 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 +# This test was off for now, because of the conflicts with other systems. +# but I turned it back on by faking the inclusion of 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 ====================================================================== diff --git a/m4/macros/header_templates.m4 b/m4/macros/header_templates.m4 index 30fe0f0..5fed9bd 100644 --- a/m4/macros/header_templates.m4 +++ b/m4/macros/header_templates.m4 @@ -406,6 +406,16 @@ AH_TEMPLATE([MNTTAB_OPT_MAXGROUPS], 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]) @@ -700,6 +710,15 @@ AH_TEMPLATE([MNT2_CDFS_OPT_NOVERSION], 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 *" ?])