Move NFS mount code from util-linux to nfs-utils
Subsystems (2)
PATCH 1/1 Move NFS mount code from util-linux to nfs-utils
AG
Signature · 2 lines
May the source be with you. http://www.cis.ksu.edu/~gud
Adds the support functions needed for mount and umount. This functionality will someday be available in the form of shared mount library.
---
support/include/conn.h +41 -0
@@ -0,0 +1,41 @@ +/* +* conn.h -- Connection routines for NFS mount / umount code. +* +* 2006-06-06 Amit Gud <[email protected]> +* - Moved code snippets here from util-linux/mount +*/ + +#ifndef _CONN_H +#define _CONN_H + +#ifdef HAVE_RPCSVC_NFS_PROT_H +#include <rpcsvc/nfs_prot.h> +#else +#include <linux/nfs.h> +#define nfsstat nfs_stat +#endif + +#include <rpc/pmap_prot.h> + +#define MNT_SENDBUFSIZE ((u_int)2048) +#define MNT_RECVBUFSIZE ((u_int)1024) + +typedef struct { +char **hostname; +struct sockaddr_in saddr; +struct pmap pmap; +}clnt_addr_t ; + +/* RPC call timeout values */ +static const struct timeval TIMEOUT = {20 ,0 }; +static const struct timeval RETRY_TIMEOUT = {3 ,0 }; + +int clnt_ping (struct sockaddr_in *,const u_long ,const u_long ,const u_int ); +u_long nfsvers_to_mnt (const u_long ); +u_long mntvers_to_nfs (const u_long ); +int get_socket (struct sockaddr_in *,u_int ,int ); +CLIENT *mnt_openclnt (clnt_addr_t *,int *); +void mnt_closeclnt (CLIENT *,int ); + +#endif /* _CONN_H */ +
support/include/fstab.h +24 -0
@@ -0,0 +1,24 @@ +#ifndef _NFS_FSTAB_H +#define _NFS_FSTAB_H + +#include "nfs_mntent.h" + +int mtab_is_writable (void ); +int mtab_does_not_exist (void ); + +struct mntentchn { +struct mntentchn *nxt, *prev; +nfs_mntent_t m; +}; + +struct mntentchn *mtab_head (void ); +struct mntentchn *getmntoptfile (const char *file); +struct mntentchn *getmntdirbackward (const char *dir,struct mntentchn *mc); +struct mntentchn *getmntdevbackward (const char *dev,struct mntentchn *mc); + +void lock_mtab (void ); +void unlock_mtab (void ); +void update_mtab (const char *special,nfs_mntent_t *with); + +#endif /* _NFS_FSTAB_H */ +
support/include/Makefile.am +5 -0
@@ -3,9 +3,13 @@ SUBDIRS = nfs rpcsvc sys noinst_HEADERS = \ + conn.h \ exportfs.h \ + fstab.h \ ha-callout.h \ misc.h \ + nfs_mntent.h \ + nfs_paths.h \ nfslib.h \ rpcdispatch.h \ rpcmisc.h \
@@ -15,6 +19,7 @@ noinst_HEADERS = \ xio.h \ xlog.h \ xmalloc.h \ + xcommon.h \ ypupdate.h MAINTAINERCLEANFILES = Makefile.in
support/include/nfs_mntent.h +34 -0
@@ -0,0 +1,34 @@ +/* +* 2006-06-08 Amit Gud <[email protected]> +* - Moved code snippets here from util-linux/mount/my_mntent.h +*/ + +#ifndef _NFS_MNTENT_H +#define _NFS_MNTENT_H + +typedef struct nfs_mntent_s { +const char *mnt_fsname; +const char *mnt_dir; +const char *mnt_type; +const char *mnt_opts; +int mnt_freq; +int mnt_passno; +}nfs_mntent_t ; + +#define ERR_MAX 5 + +typedef struct mntFILEstruct { +FILE *mntent_fp; +char *mntent_file; +int mntent_lineno; +int mntent_errs; +int mntent_softerrs; +}mntFILE ; + +mntFILE *nfs_setmntent (const char *file,char *mode); +void nfs_endmntent (mntFILE *mfp); +int nfs_addmntent (mntFILE *mfp,nfs_mntent_t *mnt); +struct nfs_mntent *my_getmntent (mntFILE *mfp); +nfs_mntent_t *nfs_getmntent (mntFILE *mfp); + +#endif /* _NFS_MNTENT_H */
support/include/nfs_paths.h +16 -0
@@ -0,0 +1,16 @@ +#ifndef _NFS_PATHS_H +#define _NFS_PATHS_H + +#include <paths.h> +#define _PATH_FSTAB "/etc/fstab" +#ifdef _PATH_MOUNTED +#define MOUNTED_LOCK _PATH_MOUNTED "~" +#define MOUNTED_TEMP _PATH_MOUNTED ".tmp" +#else +#define MOUNTED_LOCK "/etc/mtab~" +#define MOUNTED_TEMP "/etc/mtab.tmp" +#endif +#define LOCK_TIMEOUT 10 + +#endif /* _NFS_PATHS_H */ +
support/include/nls.h +27 -0
@@ -0,0 +1,27 @@ +/* +* 2006-06-08 Amit Gud <[email protected]> +* - Copied to nfs-utils/support/include from util-linux/mount +*/ + +#ifndef LOCALEDIR +#define LOCALEDIR "/usr/share/locale" +#endif + +#ifdef ENABLE_NLS +# include <libintl.h> +# define _ (Text) gettext (Text) +# ifdef gettext_noop +# define N_ (String) gettext_noop (String) +# else +# define N_ (String) (String) +# endif +#else +# undef bindtextdomain +# define bindtextdomain (Domain, Directory)/* empty */ +# undef textdomain +# define textdomain (Domain)/* empty */ +# define _ (Text) (Text) +# define N_ (Text) (Text) +#endif + +
support/include/xcommon.h +48 -0
48 lines not on this page · raw message
support/include/xmalloc.h +1 -16
@@ -1,16 +1 @@ -/* -* xmalloc Module for memory allocation. Drop in your -* debugging malloc module if you feel like it. -* -* Copyright (C) 1995 Olaf Kirch <[email protected]> -*/ - -#ifndef XMALLOC_H -#define XMALLOC_H - -void *xmalloc (size_t size); -void *xrealloc (void *ptr,size_t size); -char *xstrdup (const char *s); -void xfree (void *ptr); - -#endif /* XMALLOC_H */ +#include "xcommon.h"
support/nfs/conn.c +212 -0
212 lines not on this page · raw message
support/nfs/fstab.c +486 -0
486 lines not on this page · raw message
support/nfs/Makefile.am +2 -2
@@ -2,9 +2,9 @@ noinst_LIBRARIES = libnfs.a libnfs_a_SOURCES = exports.c rmtab.c xio.c rpcmisc.c rpcdispatch.c \ - xlog.c xmalloc.c wildmat.c nfssvc.c nfsclient.c \ + xlog.c xcommon.c wildmat.c nfssvc.c nfsclient.c \ nfsexport.c getfh.c nfsctl.c lockdsvc.c \ - svc_socket.c cacheio.c closeall.c + svc_socket.c cacheio.c closeall.c conn.c fstab.c nfs_mntent.c MAINTAINERCLEANFILES = Makefile.in
support/nfs/nfs_mntent.c +226 -0
226 lines not on this page · raw message
support/nfs/xcommon.c +185 -0
185 lines not on this page · raw message
support/nfs/xmalloc.c +0 -50
50 lines not on this page · raw message
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Quoted 10 lines · On Thursday June 8, [email protected] wrote:
AG
Signature · 6 lines
May the source be with you. http://www.cis.ksu.edu/~gud Adds the support functions needed for mount and umount. This functionality will someday be available in the form of shared mount library.
Is it really big enough to deserve a shared library? I suspect not.
Quoted 6 lines
diff -uprN
nfs-utils-1.0.8/support/include/nfs_paths.hnfs-utils-1.0.8-ag/support/include/nfs_paths.hsupport/include/nfs_paths.h +2
-0@@ -0,0 +1,16 @@ +#ifndef _NFS_PATHS_H +#define _NFS_PATHS_H
support/include/nfs_paths.h line 12
Quoted 10 lines
support/include/nfs_paths.h +10
-0+ +#include <paths.h> +#define _PATH_FSTAB "/etc/fstab" +#ifdef _PATH_MOUNTED +#define MOUNTED_LOCK _PATH_MOUNTED "~" +#define MOUNTED_TEMP _PATH_MOUNTED ".tmp" +#else +#define MOUNTED_LOCK "/etc/mtab~" +#define MOUNTED_TEMP "/etc/mtab.tmp" +#endif
How about:
#ifndef _PATH_MOUNTED
#define _PATH_MOUNTED "/etc/fstab"
#endif
#define MOUNTED_LOCK _PATH_MOUNTED "~"
#define MOUNTED_TEMP _PATH_MOUNTED ".tmp"
Looks cleaner to me.
Thanks.
I'll look forward to the next version.
NeilBrown
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs