diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-10 18:28:23 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-10 18:28:23 +0000 |
commit | 2244a21a8e11736516caf6b239ae108768f9390d (patch) | |
tree | 8d2fc4bc56992d0630f00e9f2e5e742a44742d3b | |
parent | 5983914c1b4e6440ad3bb603862a29a75d3fad3d (diff) | |
download | busybox-w32-2244a21a8e11736516caf6b239ae108768f9390d.tar.gz busybox-w32-2244a21a8e11736516caf6b239ae108768f9390d.tar.bz2 busybox-w32-2244a21a8e11736516caf6b239ae108768f9390d.zip |
nfsmount: style fix
-rw-r--r-- | util-linux/nfsmount.c | 207 |
1 files changed, 103 insertions, 104 deletions
diff --git a/util-linux/nfsmount.c b/util-linux/nfsmount.c index 2941b4ddc..92b10a232 100644 --- a/util-linux/nfsmount.c +++ b/util-linux/nfsmount.c | |||
@@ -192,45 +192,45 @@ get_mountport(struct sockaddr_in *server_addr, | |||
192 | long unsigned proto, | 192 | long unsigned proto, |
193 | long unsigned port) | 193 | long unsigned port) |
194 | { | 194 | { |
195 | struct pmaplist *pmap; | 195 | struct pmaplist *pmap; |
196 | static struct pmap p = {0, 0, 0, 0}; | 196 | static struct pmap p = {0, 0, 0, 0}; |
197 | 197 | ||
198 | server_addr->sin_port = PMAPPORT; | 198 | server_addr->sin_port = PMAPPORT; |
199 | pmap = pmap_getmaps(server_addr); | 199 | pmap = pmap_getmaps(server_addr); |
200 | 200 | ||
201 | if (version > MAX_NFSPROT) | 201 | if (version > MAX_NFSPROT) |
202 | version = MAX_NFSPROT; | 202 | version = MAX_NFSPROT; |
203 | if (!prog) | 203 | if (!prog) |
204 | prog = MOUNTPROG; | 204 | prog = MOUNTPROG; |
205 | p.pm_prog = prog; | 205 | p.pm_prog = prog; |
206 | p.pm_vers = version; | 206 | p.pm_vers = version; |
207 | p.pm_prot = proto; | 207 | p.pm_prot = proto; |
208 | p.pm_port = port; | 208 | p.pm_port = port; |
209 | 209 | ||
210 | while (pmap) { | 210 | while (pmap) { |
211 | if (pmap->pml_map.pm_prog != prog) | 211 | if (pmap->pml_map.pm_prog != prog) |
212 | goto next; | 212 | goto next; |
213 | if (!version && p.pm_vers > pmap->pml_map.pm_vers) | 213 | if (!version && p.pm_vers > pmap->pml_map.pm_vers) |
214 | goto next; | 214 | goto next; |
215 | if (version > 2 && pmap->pml_map.pm_vers != version) | 215 | if (version > 2 && pmap->pml_map.pm_vers != version) |
216 | goto next; | 216 | goto next; |
217 | if (version && version <= 2 && pmap->pml_map.pm_vers > 2) | 217 | if (version && version <= 2 && pmap->pml_map.pm_vers > 2) |
218 | goto next; | 218 | goto next; |
219 | if (pmap->pml_map.pm_vers > MAX_NFSPROT || | 219 | if (pmap->pml_map.pm_vers > MAX_NFSPROT || |
220 | (proto && p.pm_prot && pmap->pml_map.pm_prot != proto) || | 220 | (proto && p.pm_prot && pmap->pml_map.pm_prot != proto) || |
221 | (port && pmap->pml_map.pm_port != port)) | 221 | (port && pmap->pml_map.pm_port != port)) |
222 | goto next; | 222 | goto next; |
223 | memcpy(&p, &pmap->pml_map, sizeof(p)); | 223 | memcpy(&p, &pmap->pml_map, sizeof(p)); |
224 | next: | 224 | next: |
225 | pmap = pmap->pml_next; | 225 | pmap = pmap->pml_next; |
226 | } | 226 | } |
227 | if (!p.pm_vers) | 227 | if (!p.pm_vers) |
228 | p.pm_vers = MOUNTVERS; | 228 | p.pm_vers = MOUNTVERS; |
229 | if (!p.pm_port) | 229 | if (!p.pm_port) |
230 | p.pm_port = MOUNTPORT; | 230 | p.pm_port = MOUNTPORT; |
231 | if (!p.pm_prot) | 231 | if (!p.pm_prot) |
232 | p.pm_prot = IPPROTO_TCP; | 232 | p.pm_prot = IPPROTO_TCP; |
233 | return &p; | 233 | return &p; |
234 | } | 234 | } |
235 | 235 | ||
236 | int nfsmount(const char *spec, const char *node, int *flags, | 236 | int nfsmount(const char *spec, const char *node, int *flags, |
@@ -242,7 +242,7 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
242 | char *hostname; | 242 | char *hostname; |
243 | char *pathname; | 243 | char *pathname; |
244 | char *old_opts; | 244 | char *old_opts; |
245 | char *mounthost=NULL; | 245 | char *mounthost = NULL; |
246 | char new_opts[1024]; | 246 | char new_opts[1024]; |
247 | struct timeval total_timeout; | 247 | struct timeval total_timeout; |
248 | enum clnt_stat clnt_stat; | 248 | enum clnt_stat clnt_stat; |
@@ -321,11 +321,11 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
321 | hp->h_length = sizeof(struct in_addr); | 321 | hp->h_length = sizeof(struct in_addr); |
322 | } | 322 | } |
323 | memcpy(&server_addr.sin_addr, | 323 | memcpy(&server_addr.sin_addr, |
324 | hp->h_addr, hp->h_length); | 324 | hp->h_addr, hp->h_length); |
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | memcpy (&mount_server_addr, &server_addr, sizeof (mount_server_addr)); | 328 | memcpy(&mount_server_addr, &server_addr, sizeof (mount_server_addr)); |
329 | 329 | ||
330 | /* add IP address to mtab options for use when unmounting */ | 330 | /* add IP address to mtab options for use when unmounting */ |
331 | 331 | ||
@@ -403,9 +403,9 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
403 | else if (!strcmp(opt, "port")) | 403 | else if (!strcmp(opt, "port")) |
404 | port = val; | 404 | port = val; |
405 | else if (!strcmp(opt, "mountport")) | 405 | else if (!strcmp(opt, "mountport")) |
406 | mountport = val; | 406 | mountport = val; |
407 | else if (!strcmp(opt, "mounthost")) | 407 | else if (!strcmp(opt, "mounthost")) |
408 | mounthost=xstrndup(opteq+1, | 408 | mounthost = xstrndup(opteq+1, |
409 | strcspn(opteq+1," \t\n\r,")); | 409 | strcspn(opteq+1," \t\n\r,")); |
410 | else if (!strcmp(opt, "mountprog")) | 410 | else if (!strcmp(opt, "mountprog")) |
411 | mountprog = val; | 411 | mountprog = val; |
@@ -536,23 +536,23 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
536 | /* create mount daemon client */ | 536 | /* create mount daemon client */ |
537 | /* See if the nfs host = mount host. */ | 537 | /* See if the nfs host = mount host. */ |
538 | if (mounthost) { | 538 | if (mounthost) { |
539 | if (mounthost[0] >= '0' && mounthost[0] <= '9') { | 539 | if (mounthost[0] >= '0' && mounthost[0] <= '9') { |
540 | mount_server_addr.sin_family = AF_INET; | 540 | mount_server_addr.sin_family = AF_INET; |
541 | mount_server_addr.sin_addr.s_addr = inet_addr(hostname); | 541 | mount_server_addr.sin_addr.s_addr = inet_addr(hostname); |
542 | } else { | 542 | } else { |
543 | if ((hp = gethostbyname(mounthost)) == NULL) { | 543 | if ((hp = gethostbyname(mounthost)) == NULL) { |
544 | bb_herror_msg("%s", mounthost); | 544 | bb_herror_msg("%s", mounthost); |
545 | goto fail; | 545 | goto fail; |
546 | } else { | 546 | } else { |
547 | if (hp->h_length > sizeof(struct in_addr)) { | 547 | if (hp->h_length > sizeof(struct in_addr)) { |
548 | bb_error_msg("got bad hp->h_length?"); | 548 | bb_error_msg("got bad hp->h_length?"); |
549 | hp->h_length = sizeof(struct in_addr); | 549 | hp->h_length = sizeof(struct in_addr); |
550 | } | 550 | } |
551 | mount_server_addr.sin_family = AF_INET; | 551 | mount_server_addr.sin_family = AF_INET; |
552 | memcpy(&mount_server_addr.sin_addr, | 552 | memcpy(&mount_server_addr.sin_addr, |
553 | hp->h_addr, hp->h_length); | 553 | hp->h_addr, hp->h_length); |
554 | } | 554 | } |
555 | } | 555 | } |
556 | } | 556 | } |
557 | 557 | ||
558 | /* | 558 | /* |
@@ -593,10 +593,10 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
593 | sleep(30); | 593 | sleep(30); |
594 | 594 | ||
595 | pm_mnt = get_mountport(&mount_server_addr, | 595 | pm_mnt = get_mountport(&mount_server_addr, |
596 | mountprog, | 596 | mountprog, |
597 | mountvers, | 597 | mountvers, |
598 | proto, | 598 | proto, |
599 | mountport); | 599 | mountport); |
600 | 600 | ||
601 | /* contact the mount daemon via TCP */ | 601 | /* contact the mount daemon via TCP */ |
602 | mount_server_addr.sin_port = htons(pm_mnt->pm_port); | 602 | mount_server_addr.sin_port = htons(pm_mnt->pm_port); |
@@ -609,18 +609,18 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
609 | pm_mnt->pm_vers, | 609 | pm_mnt->pm_vers, |
610 | retry_timeout, | 610 | retry_timeout, |
611 | &msock); | 611 | &msock); |
612 | if (mclient) | 612 | if (mclient) |
613 | break; | 613 | break; |
614 | mount_server_addr.sin_port = htons(pm_mnt->pm_port); | 614 | mount_server_addr.sin_port = htons(pm_mnt->pm_port); |
615 | msock = RPC_ANYSOCK; | 615 | msock = RPC_ANYSOCK; |
616 | case IPPROTO_TCP: | 616 | case IPPROTO_TCP: |
617 | mclient = clnttcp_create(&mount_server_addr, | 617 | mclient = clnttcp_create(&mount_server_addr, |
618 | pm_mnt->pm_prog, | 618 | pm_mnt->pm_prog, |
619 | pm_mnt->pm_vers, | 619 | pm_mnt->pm_vers, |
620 | &msock, 0, 0); | 620 | &msock, 0, 0); |
621 | break; | 621 | break; |
622 | default: | 622 | default: |
623 | mclient = 0; | 623 | mclient = 0; |
624 | } | 624 | } |
625 | if (mclient) { | 625 | if (mclient) { |
626 | /* try to mount hostname:pathname */ | 626 | /* try to mount hostname:pathname */ |
@@ -637,7 +637,7 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
637 | (caddr_t) &pathname, | 637 | (caddr_t) &pathname, |
638 | (xdrproc_t) xdr_mountres3, | 638 | (xdrproc_t) xdr_mountres3, |
639 | (caddr_t) &status, | 639 | (caddr_t) &status, |
640 | total_timeout); | 640 | total_timeout); |
641 | else | 641 | else |
642 | clnt_stat = clnt_call(mclient, MOUNTPROC_MNT, | 642 | clnt_stat = clnt_call(mclient, MOUNTPROC_MNT, |
643 | (xdrproc_t) xdr_dirpath, | 643 | (xdrproc_t) xdr_dirpath, |
@@ -665,7 +665,7 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
665 | prevt = t; | 665 | prevt = t; |
666 | } | 666 | } |
667 | if (!bg) | 667 | if (!bg) |
668 | goto fail; | 668 | goto fail; |
669 | if (!running_bg) { | 669 | if (!running_bg) { |
670 | prev_bg_host = xstrdup(hostname); | 670 | prev_bg_host = xstrdup(hostname); |
671 | if (retry > 0) | 671 | if (retry > 0) |
@@ -686,12 +686,12 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
686 | goto fail; | 686 | goto fail; |
687 | } | 687 | } |
688 | memcpy(data.root.data, | 688 | memcpy(data.root.data, |
689 | (char *) status.nfsv2.fhstatus_u.fhs_fhandle, | 689 | (char *) status.nfsv2.fhstatus_u.fhs_fhandle, |
690 | NFS_FHSIZE); | 690 | NFS_FHSIZE); |
691 | data.root.size = NFS_FHSIZE; | 691 | data.root.size = NFS_FHSIZE; |
692 | memcpy(data.old_root.data, | 692 | memcpy(data.old_root.data, |
693 | (char *) status.nfsv2.fhstatus_u.fhs_fhandle, | 693 | (char *) status.nfsv2.fhstatus_u.fhs_fhandle, |
694 | NFS_FHSIZE); | 694 | NFS_FHSIZE); |
695 | } else { | 695 | } else { |
696 | fhandle3 *my_fhandle; | 696 | fhandle3 *my_fhandle; |
697 | if (status.nfsv3.fhs_status != 0) { | 697 | if (status.nfsv3.fhs_status != 0) { |
@@ -705,8 +705,8 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
705 | memset(&data.root, 0, sizeof(data.root)); | 705 | memset(&data.root, 0, sizeof(data.root)); |
706 | data.root.size = my_fhandle->fhandle3_len; | 706 | data.root.size = my_fhandle->fhandle3_len; |
707 | memcpy(data.root.data, | 707 | memcpy(data.root.data, |
708 | (char *) my_fhandle->fhandle3_val, | 708 | (char *) my_fhandle->fhandle3_val, |
709 | my_fhandle->fhandle3_len); | 709 | my_fhandle->fhandle3_len); |
710 | 710 | ||
711 | data.flags |= NFS_MOUNT_VER3; | 711 | data.flags |= NFS_MOUNT_VER3; |
712 | } | 712 | } |
@@ -751,7 +751,7 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
751 | */ | 751 | */ |
752 | if (get_linux_version_code() <= KERNEL_VERSION(2,3,10) | 752 | if (get_linux_version_code() <= KERNEL_VERSION(2,3,10) |
753 | && connect(fsock, (struct sockaddr *) &server_addr, | 753 | && connect(fsock, (struct sockaddr *) &server_addr, |
754 | sizeof (server_addr)) < 0) { | 754 | sizeof (server_addr)) < 0) { |
755 | perror("nfs connect"); | 755 | perror("nfs connect"); |
756 | goto fail; | 756 | goto fail; |
757 | } | 757 | } |
@@ -826,20 +826,20 @@ static char *nfs_strerror(int status) | |||
826 | return buf; | 826 | return buf; |
827 | } | 827 | } |
828 | 828 | ||
829 | static bool_t xdr_fhandle (XDR *xdrs, fhandle objp) | 829 | static bool_t xdr_fhandle(XDR *xdrs, fhandle objp) |
830 | { | 830 | { |
831 | if (!xdr_opaque (xdrs, objp, FHSIZE)) | 831 | if (!xdr_opaque(xdrs, objp, FHSIZE)) |
832 | return FALSE; | 832 | return FALSE; |
833 | return TRUE; | 833 | return TRUE; |
834 | } | 834 | } |
835 | 835 | ||
836 | bool_t xdr_fhstatus (XDR *xdrs, fhstatus *objp) | 836 | bool_t xdr_fhstatus(XDR *xdrs, fhstatus *objp) |
837 | { | 837 | { |
838 | if (!xdr_u_int (xdrs, &objp->fhs_status)) | 838 | if (!xdr_u_int(xdrs, &objp->fhs_status)) |
839 | return FALSE; | 839 | return FALSE; |
840 | switch (objp->fhs_status) { | 840 | switch (objp->fhs_status) { |
841 | case 0: | 841 | case 0: |
842 | if (!xdr_fhandle (xdrs, objp->fhstatus_u.fhs_fhandle)) | 842 | if (!xdr_fhandle(xdrs, objp->fhstatus_u.fhs_fhandle)) |
843 | return FALSE; | 843 | return FALSE; |
844 | break; | 844 | break; |
845 | default: | 845 | default: |
@@ -848,44 +848,44 @@ bool_t xdr_fhstatus (XDR *xdrs, fhstatus *objp) | |||
848 | return TRUE; | 848 | return TRUE; |
849 | } | 849 | } |
850 | 850 | ||
851 | bool_t xdr_dirpath (XDR *xdrs, dirpath *objp) | 851 | bool_t xdr_dirpath(XDR *xdrs, dirpath *objp) |
852 | { | 852 | { |
853 | if (!xdr_string (xdrs, objp, MNTPATHLEN)) | 853 | if (!xdr_string(xdrs, objp, MNTPATHLEN)) |
854 | return FALSE; | 854 | return FALSE; |
855 | return TRUE; | 855 | return TRUE; |
856 | } | 856 | } |
857 | 857 | ||
858 | bool_t xdr_fhandle3 (XDR *xdrs, fhandle3 *objp) | 858 | bool_t xdr_fhandle3(XDR *xdrs, fhandle3 *objp) |
859 | { | 859 | { |
860 | if (!xdr_bytes (xdrs, (char **)&objp->fhandle3_val, (unsigned int *) &objp->fhandle3_len, FHSIZE3)) | 860 | if (!xdr_bytes(xdrs, (char **)&objp->fhandle3_val, (unsigned int *) &objp->fhandle3_len, FHSIZE3)) |
861 | return FALSE; | 861 | return FALSE; |
862 | return TRUE; | 862 | return TRUE; |
863 | } | 863 | } |
864 | 864 | ||
865 | bool_t xdr_mountres3_ok (XDR *xdrs, mountres3_ok *objp) | 865 | bool_t xdr_mountres3_ok(XDR *xdrs, mountres3_ok *objp) |
866 | { | 866 | { |
867 | if (!xdr_fhandle3 (xdrs, &objp->fhandle)) | 867 | if (!xdr_fhandle3(xdrs, &objp->fhandle)) |
868 | return FALSE; | 868 | return FALSE; |
869 | if (!xdr_array (xdrs, &(objp->auth_flavours.auth_flavours_val), &(objp->auth_flavours.auth_flavours_len), ~0, | 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)) | 870 | sizeof (int), (xdrproc_t) xdr_int)) |
871 | return FALSE; | 871 | return FALSE; |
872 | return TRUE; | 872 | return TRUE; |
873 | } | 873 | } |
874 | 874 | ||
875 | bool_t xdr_mountstat3 (XDR *xdrs, mountstat3 *objp) | 875 | bool_t xdr_mountstat3(XDR *xdrs, mountstat3 *objp) |
876 | { | 876 | { |
877 | if (!xdr_enum (xdrs, (enum_t *) objp)) | 877 | if (!xdr_enum(xdrs, (enum_t *) objp)) |
878 | return FALSE; | 878 | return FALSE; |
879 | return TRUE; | 879 | return TRUE; |
880 | } | 880 | } |
881 | 881 | ||
882 | bool_t xdr_mountres3 (XDR *xdrs, mountres3 *objp) | 882 | bool_t xdr_mountres3(XDR *xdrs, mountres3 *objp) |
883 | { | 883 | { |
884 | if (!xdr_mountstat3 (xdrs, &objp->fhs_status)) | 884 | if (!xdr_mountstat3(xdrs, &objp->fhs_status)) |
885 | return FALSE; | 885 | return FALSE; |
886 | switch (objp->fhs_status) { | 886 | switch (objp->fhs_status) { |
887 | case MNT_OK: | 887 | case MNT_OK: |
888 | if (!xdr_mountres3_ok (xdrs, &objp->mountres3_u.mountinfo)) | 888 | if (!xdr_mountres3_ok(xdrs, &objp->mountres3_u.mountinfo)) |
889 | return FALSE; | 889 | return FALSE; |
890 | break; | 890 | break; |
891 | default: | 891 | default: |
@@ -893,4 +893,3 @@ bool_t xdr_mountres3 (XDR *xdrs, mountres3 *objp) | |||
893 | } | 893 | } |
894 | return TRUE; | 894 | return TRUE; |
895 | } | 895 | } |
896 | |||