aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-12-16 02:06:56 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-12-16 02:06:56 +0100
commitcc428147c17a57d62d89b998debc1f4bd094ad56 (patch)
tree5a30d6c78c84ab27c2400197ebbb1d140b85494f
parentb7a0e13d1ca0d613477f6e95221f47797ed1c0f9 (diff)
downloadbusybox-w32-cc428147c17a57d62d89b998debc1f4bd094ad56.tar.gz
busybox-w32-cc428147c17a57d62d89b998debc1f4bd094ad56.tar.bz2
busybox-w32-cc428147c17a57d62d89b998debc1f4bd094ad56.zip
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>
-rw-r--r--util-linux/mount.c67
1 files changed, 36 insertions, 31 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 9d87f766c..52ced7acd 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -66,9 +66,16 @@
66#include <sys/utsname.h> 66#include <sys/utsname.h>
67#undef TRUE 67#undef TRUE
68#undef FALSE 68#undef FALSE
69#include <rpc/rpc.h> 69#if ENABLE_FEATURE_MOUNT_NFS
70#include <rpc/pmap_prot.h> 70/* This is just a warning of a common mistake. Possibly this should be a
71#include <rpc/pmap_clnt.h> 71 * uclibc faq entry rather than in busybox... */
72# if defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_RPC__)
73# error "You need to build uClibc with UCLIBC_HAS_RPC for NFS support"
74# endif
75# include <rpc/rpc.h>
76# include <rpc/pmap_prot.h>
77# include <rpc/pmap_clnt.h>
78#endif
72 79
73 80
74#if defined(__dietlibc__) 81#if defined(__dietlibc__)
@@ -544,12 +551,6 @@ static int mount_it_now(struct mntent *mp, long vfsflags, char *filteropts)
544 * plus NFSv3 stuff. 551 * plus NFSv3 stuff.
545 */ 552 */
546 553
547/* This is just a warning of a common mistake. Possibly this should be a
548 * uclibc faq entry rather than in busybox... */
549#if defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_RPC__)
550#error "You need to build uClibc with UCLIBC_HAS_RPC for NFS support."
551#endif
552
553#define MOUNTPORT 635 554#define MOUNTPORT 635
554#define MNTPATHLEN 1024 555#define MNTPATHLEN 1024
555#define MNTNAMLEN 255 556#define MNTNAMLEN 255
@@ -740,28 +741,27 @@ enum {
740 * "after #include <errno.h> the symbol errno is reserved for any use, 741 * "after #include <errno.h> the symbol errno is reserved for any use,
741 * it cannot even be used as a struct tag or field name". 742 * it cannot even be used as a struct tag or field name".
742 */ 743 */
743
744#ifndef EDQUOT 744#ifndef EDQUOT
745#define EDQUOT ENOSPC 745# define EDQUOT ENOSPC
746#endif 746#endif
747
748/* Convert each NFSERR_BLAH into EBLAH */ 747/* Convert each NFSERR_BLAH into EBLAH */
749static const struct { 748static const uint8_t nfs_err_stat[] = {
750 short stat; 749 1, 2, 5, 6, 13, 17,
751 short errnum; 750 19, 20, 21, 22, 27, 28,
752} nfs_errtbl[] = { 751 30, 63, 66, 69, 70, 71
753 {0,0}, {1,EPERM}, {2,ENOENT}, {5,EIO}, {6,ENXIO}, {13,EACCES}, {17,EEXIST}, 752};
754 {19,ENODEV}, {20,ENOTDIR}, {21,EISDIR}, {22,EINVAL}, {27,EFBIG}, 753static const uint8_t nfs_err_errnum[] = {
755 {28,ENOSPC}, {30,EROFS}, {63,ENAMETOOLONG}, {66,ENOTEMPTY}, {69,EDQUOT}, 754 EPERM , ENOENT , EIO , ENXIO , EACCES, EEXIST,
756 {70,ESTALE}, {71,EREMOTE}, {-1,EIO} 755 ENODEV, ENOTDIR , EISDIR , EINVAL, EFBIG , ENOSPC,
756 EROFS , ENAMETOOLONG, ENOTEMPTY, EDQUOT, ESTALE, EREMOTE
757}; 757};
758static char *nfs_strerror(int status) 758static char *nfs_strerror(int status)
759{ 759{
760 int i; 760 int i;
761 761
762 for (i = 0; nfs_errtbl[i].stat != -1; i++) { 762 for (i = 0; i < ARRAY_SIZE(nfs_err_stat); i++) {
763 if (nfs_errtbl[i].stat == status) 763 if (nfs_err_stat[i] == status)
764 return strerror(nfs_errtbl[i].errnum); 764 return strerror(nfs_err_errnum[i]);
765 } 765 }
766 return xasprintf("unknown nfs status return value: %d", status); 766 return xasprintf("unknown nfs status return value: %d", status);
767} 767}
@@ -797,8 +797,12 @@ static bool_t xdr_dirpath(XDR *xdrs, dirpath *objp)
797 797
798static bool_t xdr_fhandle3(XDR *xdrs, fhandle3 *objp) 798static bool_t xdr_fhandle3(XDR *xdrs, fhandle3 *objp)
799{ 799{
800 if (!xdr_bytes(xdrs, (char **)&objp->fhandle3_val, (unsigned int *) &objp->fhandle3_len, FHSIZE3)) 800 if (!xdr_bytes(xdrs, (char **)&objp->fhandle3_val,
801 (unsigned int *) &objp->fhandle3_len,
802 FHSIZE3)
803 ) {
801 return FALSE; 804 return FALSE;
805 }
802 return TRUE; 806 return TRUE;
803} 807}
804 808
@@ -806,9 +810,14 @@ static bool_t xdr_mountres3_ok(XDR *xdrs, mountres3_ok *objp)
806{ 810{
807 if (!xdr_fhandle3(xdrs, &objp->fhandle)) 811 if (!xdr_fhandle3(xdrs, &objp->fhandle))
808 return FALSE; 812 return FALSE;
809 if (!xdr_array(xdrs, &(objp->auth_flavours.auth_flavours_val), &(objp->auth_flavours.auth_flavours_len), ~0, 813 if (!xdr_array(xdrs, &(objp->auth_flavours.auth_flavours_val),
810 sizeof(int), (xdrproc_t) xdr_int)) 814 &(objp->auth_flavours.auth_flavours_len),
815 ~0,
816 sizeof(int),
817 (xdrproc_t) xdr_int)
818 ) {
811 return FALSE; 819 return FALSE;
820 }
812 return TRUE; 821 return TRUE;
813} 822}
814 823
@@ -859,11 +868,7 @@ find_kernel_nfs_mount_version(void)
859 868
860 kernel_version = get_linux_version_code(); 869 kernel_version = get_linux_version_code();
861 if (kernel_version) { 870 if (kernel_version) {
862 if (kernel_version < KERNEL_VERSION(2,1,32)) 871 if (kernel_version < KERNEL_VERSION(2,2,18))
863 nfs_mount_version = 1;
864 else if (kernel_version < KERNEL_VERSION(2,2,18) ||
865 (kernel_version >= KERNEL_VERSION(2,3,0) &&
866 kernel_version < KERNEL_VERSION(2,3,99)))
867 nfs_mount_version = 3; 872 nfs_mount_version = 3;
868 /* else v4 since 2.3.99pre4 */ 873 /* else v4 since 2.3.99pre4 */
869 } 874 }