mount: dont include NFS headers if not needed; drop support for Linux <2.2.0

function                                             old     new   delta
nfs_err_stat                                           -      18     +18
nfs_err_errnum                                         -      18     +18
nfs_strerror                                          56      50      -6
nfsmount                                            3567    3541     -26
nfs_errtbl                                            80       -     -80
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 0/2 up/down: 36/-112)           Total: -76 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2009-12-16 02:06:56 +01:00
parent b7a0e13d1c
commit cc428147c1

View File

@ -66,9 +66,16 @@
#include <sys/utsname.h> #include <sys/utsname.h>
#undef TRUE #undef TRUE
#undef FALSE #undef FALSE
#include <rpc/rpc.h> #if ENABLE_FEATURE_MOUNT_NFS
#include <rpc/pmap_prot.h> /* This is just a warning of a common mistake. Possibly this should be a
#include <rpc/pmap_clnt.h> * uclibc faq entry rather than in busybox... */
# if defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_RPC__)
# error "You need to build uClibc with UCLIBC_HAS_RPC for NFS support"
# endif
# include <rpc/rpc.h>
# include <rpc/pmap_prot.h>
# include <rpc/pmap_clnt.h>
#endif
#if defined(__dietlibc__) #if defined(__dietlibc__)
@ -544,12 +551,6 @@ static int mount_it_now(struct mntent *mp, long vfsflags, char *filteropts)
* plus NFSv3 stuff. * plus NFSv3 stuff.
*/ */
/* This is just a warning of a common mistake. Possibly this should be a
* uclibc faq entry rather than in busybox... */
#if defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_RPC__)
#error "You need to build uClibc with UCLIBC_HAS_RPC for NFS support."
#endif
#define MOUNTPORT 635 #define MOUNTPORT 635
#define MNTPATHLEN 1024 #define MNTPATHLEN 1024
#define MNTNAMLEN 255 #define MNTNAMLEN 255
@ -740,28 +741,27 @@ enum {
* "after #include <errno.h> the symbol errno is reserved for any use, * "after #include <errno.h> the symbol errno is reserved for any use,
* it cannot even be used as a struct tag or field name". * it cannot even be used as a struct tag or field name".
*/ */
#ifndef EDQUOT #ifndef EDQUOT
#define EDQUOT ENOSPC # define EDQUOT ENOSPC
#endif #endif
/* Convert each NFSERR_BLAH into EBLAH */ /* Convert each NFSERR_BLAH into EBLAH */
static const struct { static const uint8_t nfs_err_stat[] = {
short stat; 1, 2, 5, 6, 13, 17,
short errnum; 19, 20, 21, 22, 27, 28,
} nfs_errtbl[] = { 30, 63, 66, 69, 70, 71
{0,0}, {1,EPERM}, {2,ENOENT}, {5,EIO}, {6,ENXIO}, {13,EACCES}, {17,EEXIST}, };
{19,ENODEV}, {20,ENOTDIR}, {21,EISDIR}, {22,EINVAL}, {27,EFBIG}, static const uint8_t nfs_err_errnum[] = {
{28,ENOSPC}, {30,EROFS}, {63,ENAMETOOLONG}, {66,ENOTEMPTY}, {69,EDQUOT}, EPERM , ENOENT , EIO , ENXIO , EACCES, EEXIST,
{70,ESTALE}, {71,EREMOTE}, {-1,EIO} ENODEV, ENOTDIR , EISDIR , EINVAL, EFBIG , ENOSPC,
EROFS , ENAMETOOLONG, ENOTEMPTY, EDQUOT, ESTALE, EREMOTE
}; };
static char *nfs_strerror(int status) static char *nfs_strerror(int status)
{ {
int i; int i;
for (i = 0; nfs_errtbl[i].stat != -1; i++) { for (i = 0; i < ARRAY_SIZE(nfs_err_stat); i++) {
if (nfs_errtbl[i].stat == status) if (nfs_err_stat[i] == status)
return strerror(nfs_errtbl[i].errnum); return strerror(nfs_err_errnum[i]);
} }
return xasprintf("unknown nfs status return value: %d", status); return xasprintf("unknown nfs status return value: %d", status);
} }
@ -797,8 +797,12 @@ static bool_t xdr_dirpath(XDR *xdrs, dirpath *objp)
static bool_t xdr_fhandle3(XDR *xdrs, fhandle3 *objp) static bool_t xdr_fhandle3(XDR *xdrs, fhandle3 *objp)
{ {
if (!xdr_bytes(xdrs, (char **)&objp->fhandle3_val, (unsigned int *) &objp->fhandle3_len, FHSIZE3)) if (!xdr_bytes(xdrs, (char **)&objp->fhandle3_val,
(unsigned int *) &objp->fhandle3_len,
FHSIZE3)
) {
return FALSE; return FALSE;
}
return TRUE; return TRUE;
} }
@ -806,9 +810,14 @@ static bool_t xdr_mountres3_ok(XDR *xdrs, mountres3_ok *objp)
{ {
if (!xdr_fhandle3(xdrs, &objp->fhandle)) if (!xdr_fhandle3(xdrs, &objp->fhandle))
return FALSE; return FALSE;
if (!xdr_array(xdrs, &(objp->auth_flavours.auth_flavours_val), &(objp->auth_flavours.auth_flavours_len), ~0, if (!xdr_array(xdrs, &(objp->auth_flavours.auth_flavours_val),
sizeof(int), (xdrproc_t) xdr_int)) &(objp->auth_flavours.auth_flavours_len),
~0,
sizeof(int),
(xdrproc_t) xdr_int)
) {
return FALSE; return FALSE;
}
return TRUE; return TRUE;
} }
@ -859,11 +868,7 @@ find_kernel_nfs_mount_version(void)
kernel_version = get_linux_version_code(); kernel_version = get_linux_version_code();
if (kernel_version) { if (kernel_version) {
if (kernel_version < KERNEL_VERSION(2,1,32)) if (kernel_version < KERNEL_VERSION(2,2,18))
nfs_mount_version = 1;
else if (kernel_version < KERNEL_VERSION(2,2,18) ||
(kernel_version >= KERNEL_VERSION(2,3,0) &&
kernel_version < KERNEL_VERSION(2,3,99)))
nfs_mount_version = 3; nfs_mount_version = 3;
/* else v4 since 2.3.99pre4 */ /* else v4 since 2.3.99pre4 */
} }