diff options
-rw-r--r-- | util-linux/Config.in | 3 | ||||
-rw-r--r-- | util-linux/mount.c | 17 | ||||
-rw-r--r-- | util-linux/nfsmount.c | 408 |
3 files changed, 260 insertions, 168 deletions
diff --git a/util-linux/Config.in b/util-linux/Config.in index aacf55775..2da37db53 100644 --- a/util-linux/Config.in +++ b/util-linux/Config.in | |||
@@ -378,9 +378,10 @@ config CONFIG_FEATURE_MOUNT_CIFS | |||
378 | depends on CONFIG_MOUNT | 378 | depends on CONFIG_MOUNT |
379 | help | 379 | help |
380 | Enable support for samba mounts. | 380 | Enable support for samba mounts. |
381 | |||
381 | config CONFIG_FEATURE_MOUNT_FLAGS | 382 | config CONFIG_FEATURE_MOUNT_FLAGS |
382 | depends on CONFIG_MOUNT | 383 | depends on CONFIG_MOUNT |
383 | bool "Support lots of -o flags in mount." | 384 | bool "Support lots of -o flags in mount" |
384 | default y | 385 | default y |
385 | help | 386 | help |
386 | Without this, mount only supports ro/rw/remount. With this, it | 387 | Without this, mount only supports ro/rw/remount. With this, it |
diff --git a/util-linux/mount.c b/util-linux/mount.c index e76c7db99..b1d9e287d 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -92,9 +92,9 @@ struct { | |||
92 | static void append_mount_options(char **oldopts, char *newopts) | 92 | static void append_mount_options(char **oldopts, char *newopts) |
93 | { | 93 | { |
94 | if(*oldopts && **oldopts) { | 94 | if(*oldopts && **oldopts) { |
95 | char *temp=xasprintf("%s,%s",*oldopts,newopts); | 95 | char *temp = xasprintf("%s,%s",*oldopts,newopts); |
96 | free(*oldopts); | 96 | free(*oldopts); |
97 | *oldopts=temp; | 97 | *oldopts = temp; |
98 | } else { | 98 | } else { |
99 | if (ENABLE_FEATURE_CLEAN_UP) free(*oldopts); | 99 | if (ENABLE_FEATURE_CLEAN_UP) free(*oldopts); |
100 | *oldopts = xstrdup(newopts); | 100 | *oldopts = xstrdup(newopts); |
@@ -346,13 +346,14 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
346 | default: | 346 | default: |
347 | bb_error_msg( errno == EPERM || errno == EACCES | 347 | bb_error_msg( errno == EPERM || errno == EACCES |
348 | ? bb_msg_perm_denied_are_you_root | 348 | ? bb_msg_perm_denied_are_you_root |
349 | : "Couldn't setup loop device"); | 349 | : "cannot setup loop device"); |
350 | return errno; | 350 | return errno; |
351 | } | 351 | } |
352 | 352 | ||
353 | // Autodetect bind mounts | 353 | // Autodetect bind mounts |
354 | 354 | ||
355 | } else if (S_ISDIR(st.st_mode) && !mp->mnt_type) vfsflags |= MS_BIND; | 355 | } else if (S_ISDIR(st.st_mode) && !mp->mnt_type) |
356 | vfsflags |= MS_BIND; | ||
356 | } | 357 | } |
357 | 358 | ||
358 | /* If we know the fstype (or don't need to), jump straight | 359 | /* If we know the fstype (or don't need to), jump straight |
@@ -399,7 +400,7 @@ report_error: | |||
399 | 400 | ||
400 | if (rc && errno == EBUSY && ignore_busy) rc = 0; | 401 | if (rc && errno == EBUSY && ignore_busy) rc = 0; |
401 | if (rc < 0) | 402 | if (rc < 0) |
402 | bb_perror_msg("Mounting %s on %s failed", mp->mnt_fsname, mp->mnt_dir); | 403 | bb_perror_msg("mounting %s on %s failed", mp->mnt_fsname, mp->mnt_dir); |
403 | 404 | ||
404 | return rc; | 405 | return rc; |
405 | } | 406 | } |
@@ -466,7 +467,7 @@ int mount_main(int argc, char **argv) | |||
466 | if (!all) { | 467 | if (!all) { |
467 | FILE *mountTable = setmntent(bb_path_mtab_file, "r"); | 468 | FILE *mountTable = setmntent(bb_path_mtab_file, "r"); |
468 | 469 | ||
469 | if(!mountTable) bb_error_msg_and_die("No %s",bb_path_mtab_file); | 470 | if(!mountTable) bb_error_msg_and_die("no %s",bb_path_mtab_file); |
470 | 471 | ||
471 | while (getmntent_r(mountTable,mtpair,bb_common_bufsiz1, | 472 | while (getmntent_r(mountTable,mtpair,bb_common_bufsiz1, |
472 | sizeof(bb_common_bufsiz1))) | 473 | sizeof(bb_common_bufsiz1))) |
@@ -514,7 +515,7 @@ int mount_main(int argc, char **argv) | |||
514 | else fstabname="/etc/fstab"; | 515 | else fstabname="/etc/fstab"; |
515 | 516 | ||
516 | if (!(fstab=setmntent(fstabname,"r"))) | 517 | if (!(fstab=setmntent(fstabname,"r"))) |
517 | bb_perror_msg_and_die("Cannot read %s",fstabname); | 518 | bb_perror_msg_and_die("cannot read %s",fstabname); |
518 | 519 | ||
519 | // Loop through entries until we find what we're looking for. | 520 | // Loop through entries until we find what we're looking for. |
520 | 521 | ||
@@ -535,7 +536,7 @@ int mount_main(int argc, char **argv) | |||
535 | // If we didn't find anything, complain. | 536 | // If we didn't find anything, complain. |
536 | 537 | ||
537 | if (!mtnext->mnt_fsname) | 538 | if (!mtnext->mnt_fsname) |
538 | bb_error_msg_and_die("Can't find %s in %s", | 539 | bb_error_msg_and_die("can't find %s in %s", |
539 | argv[optind], fstabname); | 540 | argv[optind], fstabname); |
540 | 541 | ||
541 | // Mount the last thing we found. | 542 | // Mount the last thing we found. |
diff --git a/util-linux/nfsmount.c b/util-linux/nfsmount.c index 92b10a232..43c3b663d 100644 --- a/util-linux/nfsmount.c +++ b/util-linux/nfsmount.c | |||
@@ -21,10 +21,6 @@ | |||
21 | * plus NFSv3 stuff. | 21 | * plus NFSv3 stuff. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | ||
25 | * nfsmount.c,v 1.1.1.1 1993/11/18 08:40:51 jrs Exp | ||
26 | */ | ||
27 | |||
28 | #include "busybox.h" | 24 | #include "busybox.h" |
29 | #include <sys/utsname.h> | 25 | #include <sys/utsname.h> |
30 | #undef TRUE | 26 | #undef TRUE |
@@ -32,7 +28,6 @@ | |||
32 | #include <rpc/rpc.h> | 28 | #include <rpc/rpc.h> |
33 | #include <rpc/pmap_prot.h> | 29 | #include <rpc/pmap_prot.h> |
34 | #include <rpc/pmap_clnt.h> | 30 | #include <rpc/pmap_clnt.h> |
35 | #include "nfsmount.h" | ||
36 | 31 | ||
37 | /* This is just a warning of a common mistake. Possibly this should be a | 32 | /* This is just a warning of a common mistake. Possibly this should be a |
38 | * uclibc faq entry rather than in busybox... */ | 33 | * uclibc faq entry rather than in busybox... */ |
@@ -40,8 +35,128 @@ | |||
40 | #error "You need to build uClibc with UCLIBC_HAS_RPC for NFS support." | 35 | #error "You need to build uClibc with UCLIBC_HAS_RPC for NFS support." |
41 | #endif | 36 | #endif |
42 | 37 | ||
38 | /* former nfsmount.h */ | ||
39 | |||
40 | #define MOUNTPORT 635 | ||
41 | #define MNTPATHLEN 1024 | ||
42 | #define MNTNAMLEN 255 | ||
43 | #define FHSIZE 32 | ||
44 | #define FHSIZE3 64 | ||
45 | |||
46 | typedef char fhandle[FHSIZE]; | ||
47 | |||
48 | typedef struct { | ||
49 | unsigned int fhandle3_len; | ||
50 | char *fhandle3_val; | ||
51 | } fhandle3; | ||
52 | |||
53 | enum mountstat3 { | ||
54 | MNT_OK = 0, | ||
55 | MNT3ERR_PERM = 1, | ||
56 | MNT3ERR_NOENT = 2, | ||
57 | MNT3ERR_IO = 5, | ||
58 | MNT3ERR_ACCES = 13, | ||
59 | MNT3ERR_NOTDIR = 20, | ||
60 | MNT3ERR_INVAL = 22, | ||
61 | MNT3ERR_NAMETOOLONG = 63, | ||
62 | MNT3ERR_NOTSUPP = 10004, | ||
63 | MNT3ERR_SERVERFAULT = 10006, | ||
64 | }; | ||
65 | typedef enum mountstat3 mountstat3; | ||
66 | |||
67 | struct fhstatus { | ||
68 | unsigned int fhs_status; | ||
69 | union { | ||
70 | fhandle fhs_fhandle; | ||
71 | } fhstatus_u; | ||
72 | }; | ||
73 | typedef struct fhstatus fhstatus; | ||
74 | |||
75 | struct mountres3_ok { | ||
76 | fhandle3 fhandle; | ||
77 | struct { | ||
78 | unsigned int auth_flavours_len; | ||
79 | char *auth_flavours_val; | ||
80 | } auth_flavours; | ||
81 | }; | ||
82 | typedef struct mountres3_ok mountres3_ok; | ||
43 | 83 | ||
84 | struct mountres3 { | ||
85 | mountstat3 fhs_status; | ||
86 | union { | ||
87 | mountres3_ok mountinfo; | ||
88 | } mountres3_u; | ||
89 | }; | ||
90 | typedef struct mountres3 mountres3; | ||
91 | |||
92 | typedef char *dirpath; | ||
93 | |||
94 | typedef char *name; | ||
95 | |||
96 | typedef struct mountbody *mountlist; | ||
97 | |||
98 | struct mountbody { | ||
99 | name ml_hostname; | ||
100 | dirpath ml_directory; | ||
101 | mountlist ml_next; | ||
102 | }; | ||
103 | typedef struct mountbody mountbody; | ||
44 | 104 | ||
105 | typedef struct groupnode *groups; | ||
106 | |||
107 | struct groupnode { | ||
108 | name gr_name; | ||
109 | groups gr_next; | ||
110 | }; | ||
111 | typedef struct groupnode groupnode; | ||
112 | |||
113 | typedef struct exportnode *exports; | ||
114 | |||
115 | struct exportnode { | ||
116 | dirpath ex_dir; | ||
117 | groups ex_groups; | ||
118 | exports ex_next; | ||
119 | }; | ||
120 | typedef struct exportnode exportnode; | ||
121 | |||
122 | struct ppathcnf { | ||
123 | int pc_link_max; | ||
124 | short pc_max_canon; | ||
125 | short pc_max_input; | ||
126 | short pc_name_max; | ||
127 | short pc_path_max; | ||
128 | short pc_pipe_buf; | ||
129 | u_char pc_vdisable; | ||
130 | char pc_xxx; | ||
131 | short pc_mask[2]; | ||
132 | }; | ||
133 | typedef struct ppathcnf ppathcnf; | ||
134 | |||
135 | #define MOUNTPROG 100005 | ||
136 | #define MOUNTVERS 1 | ||
137 | |||
138 | #define MOUNTPROC_NULL 0 | ||
139 | #define MOUNTPROC_MNT 1 | ||
140 | #define MOUNTPROC_DUMP 2 | ||
141 | #define MOUNTPROC_UMNT 3 | ||
142 | #define MOUNTPROC_UMNTALL 4 | ||
143 | #define MOUNTPROC_EXPORT 5 | ||
144 | #define MOUNTPROC_EXPORTALL 6 | ||
145 | |||
146 | #define MOUNTVERS_POSIX 2 | ||
147 | |||
148 | #define MOUNTPROC_PATHCONF 7 | ||
149 | |||
150 | #define MOUNT_V3 3 | ||
151 | |||
152 | #define MOUNTPROC3_NULL 0 | ||
153 | #define MOUNTPROC3_MNT 1 | ||
154 | #define MOUNTPROC3_DUMP 2 | ||
155 | #define MOUNTPROC3_UMNT 3 | ||
156 | #define MOUNTPROC3_UMNTALL 4 | ||
157 | #define MOUNTPROC3_EXPORT 5 | ||
158 | |||
159 | /* former nfsmount.h ends */ | ||
45 | 160 | ||
46 | enum { | 161 | enum { |
47 | #ifndef NFS_FHSIZE | 162 | #ifndef NFS_FHSIZE |
@@ -52,12 +167,6 @@ enum { | |||
52 | #endif | 167 | #endif |
53 | }; | 168 | }; |
54 | 169 | ||
55 | /* Disable the nls stuff */ | ||
56 | //# undef bindtextdomain | ||
57 | //# define bindtextdomain(Domain, Directory) /* empty */ | ||
58 | //# undef textdomain | ||
59 | //# define textdomain(Domain) /* empty */ | ||
60 | |||
61 | //enum { | 170 | //enum { |
62 | // S_QUOTA = 128, /* Quota initialized for file/directory/symlink */ | 171 | // S_QUOTA = 128, /* Quota initialized for file/directory/symlink */ |
63 | //}; | 172 | //}; |
@@ -115,26 +224,114 @@ enum { | |||
115 | NFS_MOUNT_NONLM = 0x0200 /* 3 */ | 224 | NFS_MOUNT_NONLM = 0x0200 /* 3 */ |
116 | }; | 225 | }; |
117 | 226 | ||
227 | #define HAVE_inet_aton | ||
118 | 228 | ||
119 | #define UTIL_LINUX_VERSION "2.10m" | 229 | /* |
120 | #define util_linux_version "util-linux-2.10m" | 230 | * We need to translate between nfs status return values and |
231 | * the local errno values which may not be the same. | ||
232 | * | ||
233 | * Andreas Schwab <schwab@LS5.informatik.uni-dortmund.de>: change errno: | ||
234 | * "after #include <errno.h> the symbol errno is reserved for any use, | ||
235 | * it cannot even be used as a struct tag or field name". | ||
236 | */ | ||
237 | |||
238 | #ifndef EDQUOT | ||
239 | #define EDQUOT ENOSPC | ||
240 | #endif | ||
241 | |||
242 | // Convert each NFSERR_BLAH into EBLAH | ||
243 | |||
244 | static const struct { | ||
245 | int stat; | ||
246 | int errnum; | ||
247 | } nfs_errtbl[] = { | ||
248 | {0,0}, {1,EPERM}, {2,ENOENT}, {5,EIO}, {6,ENXIO}, {13,EACCES}, {17,EEXIST}, | ||
249 | {19,ENODEV}, {20,ENOTDIR}, {21,EISDIR}, {22,EINVAL}, {27,EFBIG}, | ||
250 | {28,ENOSPC}, {30,EROFS}, {63,ENAMETOOLONG}, {66,ENOTEMPTY}, {69,EDQUOT}, | ||
251 | {70,ESTALE}, {71,EREMOTE}, {-1,EIO} | ||
252 | }; | ||
253 | |||
254 | static char *nfs_strerror(int status) | ||
255 | { | ||
256 | int i; | ||
257 | static char buf[256]; | ||
258 | |||
259 | for (i = 0; nfs_errtbl[i].stat != -1; i++) { | ||
260 | if (nfs_errtbl[i].stat == status) | ||
261 | return strerror(nfs_errtbl[i].errnum); | ||
262 | } | ||
263 | sprintf(buf, "unknown nfs status return value: %d", status); | ||
264 | return buf; | ||
265 | } | ||
266 | |||
267 | static bool_t xdr_fhandle(XDR *xdrs, fhandle objp) | ||
268 | { | ||
269 | if (!xdr_opaque(xdrs, objp, FHSIZE)) | ||
270 | return FALSE; | ||
271 | return TRUE; | ||
272 | } | ||
273 | |||
274 | static bool_t xdr_fhstatus(XDR *xdrs, fhstatus *objp) | ||
275 | { | ||
276 | if (!xdr_u_int(xdrs, &objp->fhs_status)) | ||
277 | return FALSE; | ||
278 | switch (objp->fhs_status) { | ||
279 | case 0: | ||
280 | if (!xdr_fhandle(xdrs, objp->fhstatus_u.fhs_fhandle)) | ||
281 | return FALSE; | ||
282 | break; | ||
283 | default: | ||
284 | break; | ||
285 | } | ||
286 | return TRUE; | ||
287 | } | ||
288 | |||
289 | static bool_t xdr_dirpath(XDR *xdrs, dirpath *objp) | ||
290 | { | ||
291 | if (!xdr_string(xdrs, objp, MNTPATHLEN)) | ||
292 | return FALSE; | ||
293 | return TRUE; | ||
294 | } | ||
295 | |||
296 | static bool_t xdr_fhandle3(XDR *xdrs, fhandle3 *objp) | ||
297 | { | ||
298 | if (!xdr_bytes(xdrs, (char **)&objp->fhandle3_val, (unsigned int *) &objp->fhandle3_len, FHSIZE3)) | ||
299 | return FALSE; | ||
300 | return TRUE; | ||
301 | } | ||
302 | |||
303 | static bool_t xdr_mountres3_ok(XDR *xdrs, mountres3_ok *objp) | ||
304 | { | ||
305 | if (!xdr_fhandle3(xdrs, &objp->fhandle)) | ||
306 | return FALSE; | ||
307 | if (!xdr_array(xdrs, &(objp->auth_flavours.auth_flavours_val), &(objp->auth_flavours.auth_flavours_len), ~0, | ||
308 | sizeof (int), (xdrproc_t) xdr_int)) | ||
309 | return FALSE; | ||
310 | return TRUE; | ||
311 | } | ||
312 | |||
313 | static bool_t xdr_mountstat3(XDR *xdrs, mountstat3 *objp) | ||
314 | { | ||
315 | if (!xdr_enum(xdrs, (enum_t *) objp)) | ||
316 | return FALSE; | ||
317 | return TRUE; | ||
318 | } | ||
319 | |||
320 | static bool_t xdr_mountres3(XDR *xdrs, mountres3 *objp) | ||
321 | { | ||
322 | if (!xdr_mountstat3(xdrs, &objp->fhs_status)) | ||
323 | return FALSE; | ||
324 | switch (objp->fhs_status) { | ||
325 | case MNT_OK: | ||
326 | if (!xdr_mountres3_ok(xdrs, &objp->mountres3_u.mountinfo)) | ||
327 | return FALSE; | ||
328 | break; | ||
329 | default: | ||
330 | break; | ||
331 | } | ||
332 | return TRUE; | ||
333 | } | ||
121 | 334 | ||
122 | #define HAVE_inet_aton | ||
123 | #define HAVE_scsi_h | ||
124 | #define HAVE_blkpg_h | ||
125 | #define HAVE_kd_h | ||
126 | #define HAVE_termcap | ||
127 | #define HAVE_locale_h | ||
128 | #define HAVE_libintl_h | ||
129 | #define ENABLE_NLS | ||
130 | #define HAVE_langinfo_h | ||
131 | #define HAVE_progname | ||
132 | #define HAVE_openpty | ||
133 | #define HAVE_nanosleep | ||
134 | #define HAVE_personality | ||
135 | #define HAVE_tm_gmtoff | ||
136 | |||
137 | static char *nfs_strerror(int status); | ||
138 | 335 | ||
139 | #define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2) | 336 | #define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2) |
140 | 337 | ||
@@ -187,10 +384,10 @@ find_kernel_nfs_mount_version(void) | |||
187 | 384 | ||
188 | static struct pmap * | 385 | static struct pmap * |
189 | get_mountport(struct sockaddr_in *server_addr, | 386 | get_mountport(struct sockaddr_in *server_addr, |
190 | long unsigned prog, | 387 | long unsigned prog, |
191 | long unsigned version, | 388 | long unsigned version, |
192 | long unsigned proto, | 389 | long unsigned proto, |
193 | long unsigned port) | 390 | long unsigned port) |
194 | { | 391 | { |
195 | struct pmaplist *pmap; | 392 | struct pmaplist *pmap; |
196 | static struct pmap p = {0, 0, 0, 0}; | 393 | static struct pmap p = {0, 0, 0, 0}; |
@@ -422,16 +619,16 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
422 | else if (!strncmp(opteq+1, "udp", 3)) | 619 | else if (!strncmp(opteq+1, "udp", 3)) |
423 | tcp = 0; | 620 | tcp = 0; |
424 | else | 621 | else |
425 | printf("Warning: Unrecognized proto= option.\n"); | 622 | bb_error_msg("warning: unrecognized proto= option"); |
426 | } else if (!strcmp(opt, "namlen")) { | 623 | } else if (!strcmp(opt, "namlen")) { |
427 | if (nfs_mount_version >= 2) | 624 | if (nfs_mount_version >= 2) |
428 | data.namlen = val; | 625 | data.namlen = val; |
429 | else | 626 | else |
430 | printf("Warning: Option namlen is not supported.\n"); | 627 | bb_error_msg("warning: option namlen is not supported\n"); |
431 | } else if (!strcmp(opt, "addr")) | 628 | } else if (!strcmp(opt, "addr")) |
432 | /* ignore */; | 629 | /* ignore */; |
433 | else { | 630 | else { |
434 | printf("unknown nfs mount parameter: %s=%d\n", opt, val); | 631 | bb_error_msg("unknown nfs mount parameter: %s=%d", opt, val); |
435 | goto fail; | 632 | goto fail; |
436 | } | 633 | } |
437 | } | 634 | } |
@@ -465,9 +662,9 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
465 | if (nfs_mount_version >= 3) | 662 | if (nfs_mount_version >= 3) |
466 | nolock = !val; | 663 | nolock = !val; |
467 | else | 664 | else |
468 | printf("Warning: option nolock is not supported.\n"); | 665 | bb_error_msg("warning: option nolock is not supported"); |
469 | } else { | 666 | } else { |
470 | printf("unknown nfs mount option: %s%s\n", val ? "" : "no", opt); | 667 | bb_error_msg("unknown nfs mount option: %s%s", val ? "" : "no", opt); |
471 | goto fail; | 668 | goto fail; |
472 | } | 669 | } |
473 | } | 670 | } |
@@ -626,20 +823,20 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
626 | /* try to mount hostname:pathname */ | 823 | /* try to mount hostname:pathname */ |
627 | mclient->cl_auth = authunix_create_default(); | 824 | mclient->cl_auth = authunix_create_default(); |
628 | 825 | ||
629 | /* make pointers in xdr_mountres3 NULL so | 826 | /* make pointers in xdr_mountres3 NULL so |
630 | * that xdr_array allocates memory for us | 827 | * that xdr_array allocates memory for us |
631 | */ | 828 | */ |
632 | memset(&status, 0, sizeof(status)); | 829 | memset(&status, 0, sizeof(status)); |
633 | 830 | ||
634 | if (pm_mnt->pm_vers == 3) | 831 | if (pm_mnt->pm_vers == 3) |
635 | clnt_stat = clnt_call(mclient, MOUNTPROC3_MNT, | 832 | clnt_stat = clnt_call(mclient, MOUNTPROC3_MNT, |
636 | (xdrproc_t) xdr_dirpath, | 833 | (xdrproc_t) xdr_dirpath, |
637 | (caddr_t) &pathname, | 834 | (caddr_t) &pathname, |
638 | (xdrproc_t) xdr_mountres3, | 835 | (xdrproc_t) xdr_mountres3, |
639 | (caddr_t) &status, | 836 | (caddr_t) &status, |
640 | total_timeout); | 837 | total_timeout); |
641 | else | 838 | else |
642 | clnt_stat = clnt_call(mclient, MOUNTPROC_MNT, | 839 | clnt_stat = clnt_call(mclient, MOUNTPROC_MNT, |
643 | (xdrproc_t) xdr_dirpath, | 840 | (xdrproc_t) xdr_dirpath, |
644 | (caddr_t) &pathname, | 841 | (caddr_t) &pathname, |
645 | (xdrproc_t) xdr_fhstatus, | 842 | (xdrproc_t) xdr_fhstatus, |
@@ -715,7 +912,7 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
715 | 912 | ||
716 | if (tcp) { | 913 | if (tcp) { |
717 | if (nfs_mount_version < 3) { | 914 | if (nfs_mount_version < 3) { |
718 | printf("NFS over TCP is not supported.\n"); | 915 | bb_error_msg("NFS over TCP is not supported"); |
719 | goto fail; | 916 | goto fail; |
720 | } | 917 | } |
721 | fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); | 918 | fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); |
@@ -744,11 +941,11 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
744 | printf("using port %d for nfs daemon\n", port); | 941 | printf("using port %d for nfs daemon\n", port); |
745 | #endif | 942 | #endif |
746 | server_addr.sin_port = htons(port); | 943 | server_addr.sin_port = htons(port); |
747 | /* | 944 | /* |
748 | * connect() the socket for kernels 1.3.10 and below only, | 945 | * connect() the socket for kernels 1.3.10 and below only, |
749 | * to avoid problems with multihomed hosts. | 946 | * to avoid problems with multihomed hosts. |
750 | * --Swen | 947 | * --Swen |
751 | */ | 948 | */ |
752 | if (get_linux_version_code() <= KERNEL_VERSION(2,3,10) | 949 | if (get_linux_version_code() <= KERNEL_VERSION(2,3,10) |
753 | && connect(fsock, (struct sockaddr *) &server_addr, | 950 | && connect(fsock, (struct sockaddr *) &server_addr, |
754 | sizeof (server_addr)) < 0) { | 951 | sizeof (server_addr)) < 0) { |
@@ -786,110 +983,3 @@ fail: | |||
786 | close(fsock); | 983 | close(fsock); |
787 | return retval; | 984 | return retval; |
788 | } | 985 | } |
789 | |||
790 | /* | ||
791 | * We need to translate between nfs status return values and | ||
792 | * the local errno values which may not be the same. | ||
793 | * | ||
794 | * Andreas Schwab <schwab@LS5.informatik.uni-dortmund.de>: change errno: | ||
795 | * "after #include <errno.h> the symbol errno is reserved for any use, | ||
796 | * it cannot even be used as a struct tag or field name". | ||
797 | */ | ||
798 | |||
799 | #ifndef EDQUOT | ||
800 | #define EDQUOT ENOSPC | ||
801 | #endif | ||
802 | |||
803 | // Convert each NFSERR_BLAH into EBLAH | ||
804 | |||
805 | static const struct { | ||
806 | int stat; | ||
807 | int errnum; | ||
808 | } nfs_errtbl[] = { | ||
809 | {0,0}, {1,EPERM}, {2,ENOENT}, {5,EIO}, {6,ENXIO}, {13,EACCES}, {17,EEXIST}, | ||
810 | {19,ENODEV}, {20,ENOTDIR}, {21,EISDIR}, {22,EINVAL}, {27,EFBIG}, | ||
811 | {28,ENOSPC}, {30,EROFS}, {63,ENAMETOOLONG}, {66,ENOTEMPTY}, {69,EDQUOT}, | ||
812 | {70,ESTALE}, {71,EREMOTE}, {-1,EIO} | ||
813 | }; | ||
814 | |||
815 | |||
816 | static char *nfs_strerror(int status) | ||
817 | { | ||
818 | int i; | ||
819 | static char buf[256]; | ||
820 | |||
821 | for (i = 0; nfs_errtbl[i].stat != -1; i++) { | ||
822 | if (nfs_errtbl[i].stat == status) | ||
823 | return strerror(nfs_errtbl[i].errnum); | ||
824 | } | ||
825 | sprintf(buf, "unknown nfs status return value: %d", status); | ||
826 | return buf; | ||
827 | } | ||
828 | |||
829 | static bool_t xdr_fhandle(XDR *xdrs, fhandle objp) | ||
830 | { | ||
831 | if (!xdr_opaque(xdrs, objp, FHSIZE)) | ||
832 | return FALSE; | ||
833 | return TRUE; | ||
834 | } | ||
835 | |||
836 | bool_t xdr_fhstatus(XDR *xdrs, fhstatus *objp) | ||
837 | { | ||
838 | if (!xdr_u_int(xdrs, &objp->fhs_status)) | ||
839 | return FALSE; | ||
840 | switch (objp->fhs_status) { | ||
841 | case 0: | ||
842 | if (!xdr_fhandle(xdrs, objp->fhstatus_u.fhs_fhandle)) | ||
843 | return FALSE; | ||
844 | break; | ||
845 | default: | ||
846 | break; | ||
847 | } | ||
848 | return TRUE; | ||
849 | } | ||
850 | |||
851 | bool_t xdr_dirpath(XDR *xdrs, dirpath *objp) | ||
852 | { | ||
853 | if (!xdr_string(xdrs, objp, MNTPATHLEN)) | ||
854 | return FALSE; | ||
855 | return TRUE; | ||
856 | } | ||
857 | |||
858 | bool_t xdr_fhandle3(XDR *xdrs, fhandle3 *objp) | ||
859 | { | ||
860 | if (!xdr_bytes(xdrs, (char **)&objp->fhandle3_val, (unsigned int *) &objp->fhandle3_len, FHSIZE3)) | ||
861 | return FALSE; | ||
862 | return TRUE; | ||
863 | } | ||
864 | |||
865 | bool_t xdr_mountres3_ok(XDR *xdrs, mountres3_ok *objp) | ||
866 | { | ||
867 | if (!xdr_fhandle3(xdrs, &objp->fhandle)) | ||
868 | return FALSE; | ||
869 | if (!xdr_array(xdrs, &(objp->auth_flavours.auth_flavours_val), &(objp->auth_flavours.auth_flavours_len), ~0, | ||
870 | sizeof (int), (xdrproc_t) xdr_int)) | ||
871 | return FALSE; | ||
872 | return TRUE; | ||
873 | } | ||
874 | |||
875 | bool_t xdr_mountstat3(XDR *xdrs, mountstat3 *objp) | ||
876 | { | ||
877 | if (!xdr_enum(xdrs, (enum_t *) objp)) | ||
878 | return FALSE; | ||
879 | return TRUE; | ||
880 | } | ||
881 | |||
882 | bool_t xdr_mountres3(XDR *xdrs, mountres3 *objp) | ||
883 | { | ||
884 | if (!xdr_mountstat3(xdrs, &objp->fhs_status)) | ||
885 | return FALSE; | ||
886 | switch (objp->fhs_status) { | ||
887 | case MNT_OK: | ||
888 | if (!xdr_mountres3_ok(xdrs, &objp->mountres3_u.mountinfo)) | ||
889 | return FALSE; | ||
890 | break; | ||
891 | default: | ||
892 | break; | ||
893 | } | ||
894 | return TRUE; | ||
895 | } | ||