]> git.pld-linux.org Git - packages/util-linux.git/blob - util-linux-2.12-06-redhat-nfs-mount.dif
- init var
[packages/util-linux.git] / util-linux-2.12-06-redhat-nfs-mount.dif
1
2
3 Changes from redhat srpm.
4
5 ---
6
7  util-linux-2.12-bfields/mount/mount.c     |    2 
8  util-linux-2.12-bfields/mount/nfs4mount.c |   20 +++++++++
9  util-linux-2.12-bfields/mount/nfsmount.c  |   61 +++++++++++++++++++++++++-----
10  3 files changed, 72 insertions(+), 11 deletions(-)
11
12 diff -puN mount/mount.c~redhat-nfs-mount mount/mount.c
13 --- util-linux-2.12/mount/mount.c~redhat-nfs-mount      2004-12-13 12:34:18.000000000 -0500
14 +++ util-linux-2.12-bfields/mount/mount.c       2004-12-13 12:34:18.000000000 -0500
15 @@ -829,6 +829,7 @@ retry_nfs:
16      mnt_err = nfs4mount(spec, node, &flags, &extra_opts, &mount_opts, bg);
17      if (mnt_err)
18        return mnt_err;
19 +       goto nosigblock;
20  #else
21      die (EX_SOFTWARE, _("mount: this version was compiled "
22                       "without support for the type `nfs4'"));
23 @@ -836,6 +837,7 @@ retry_nfs:
24    }
25  
26    block_signals (SIG_BLOCK);
27 +nosigblock:
28  
29    if (!fake)
30      mnt5_res = guess_fstype_and_mount (spec, node, &types, flags & ~MS_NOSYS,
31 diff -puN mount/nfs4mount.c~redhat-nfs-mount mount/nfs4mount.c
32 --- util-linux-2.12/mount/nfs4mount.c~redhat-nfs-mount  2004-12-13 12:34:18.000000000 -0500
33 +++ util-linux-2.12-bfields/mount/nfs4mount.c   2004-12-13 12:34:18.000000000 -0500
34 @@ -37,6 +37,12 @@
35  #include <netinet/in.h>
36  #include <arpa/inet.h>
37  #include <rpc/auth.h>
38 +#ifdef HAVE_rpcsvc_nfs_prot_h
39 +#include <rpcsvc/nfs_prot.h>
40 +#else
41 +#include <linux/nfs.h>
42 +#define nfsstat nfs_stat
43 +#endif
44  
45  #include "sundries.h"
46  
47 @@ -49,6 +55,9 @@
48  #define NFS_PORT 2049
49  #endif
50  
51 +extern int clnt_ping(struct sockaddr_in *, const u_long, const u_long, const u_int);
52 +extern void rpc_strerror(void);
53 +
54  struct {
55         char    *flavour;
56         int     fnum;
57 @@ -225,7 +234,7 @@ int nfs4mount(const char *spec, const ch
58  
59         bg = 0;
60         soft = 0;
61 -       intr = 0;
62 +       intr = NFS4_MOUNT_INTR;
63         nocto = 0;
64         noac = 0;
65         retry = 10000;          /* 10000 minutes ~ 1 week */
66 @@ -374,10 +383,19 @@ int nfs4mount(const char *spec, const ch
67  
68         data.version = NFS4_MOUNT_VERSION;
69  
70 +       clnt_ping(&server_addr, NFS_PROGRAM, 4, data.proto);
71 +       if (rpc_createerr.cf_stat) {
72 +               fprintf(stderr, "mount to NFS server '%s' failed.\n", data.hostname.data);
73 +               goto fail;
74 +       }
75 +
76         *mount_opts = (char *) &data;
77         /* clean up */
78         return 0;
79  
80  fail:
81 +       if (verbose) {
82 +               rpc_strerror();
83 +       }
84         return retval;
85  }
86 diff -puN mount/nfsmount.c~redhat-nfs-mount mount/nfsmount.c
87 --- util-linux-2.12/mount/nfsmount.c~redhat-nfs-mount   2004-12-13 12:34:18.000000000 -0500
88 +++ util-linux-2.12-bfields/mount/nfsmount.c    2004-12-13 12:34:18.000000000 -0500
89 @@ -111,6 +111,25 @@ static const struct timeval RETRY_TIMEOU
90  
91  static int nfs_call_umount(clnt_addr_t *mnt_server, dirpath *argp);
92  
93 +int clnt_ping(struct sockaddr_in *, const u_long, const u_long, const u_int);
94 +
95 +/* Convert RPC errors into strings */
96 +void rpc_strerror(void)
97 +{
98 +       int cf_stat = rpc_createerr.cf_stat;
99 +       int cf_errno = rpc_createerr.cf_error.re_errno;
100 +       char *ptr, *estr = clnt_sperrno(cf_stat);
101 +
102 +       if (estr) {
103 +               if ((ptr = index(estr, ':')))
104 +                       estr = ++ptr;
105 +
106 +               fprintf(stderr, "RPC Error: %d (%s )\n", cf_stat, estr);
107 +               if (cf_stat == RPC_SYSTEMERROR)
108 +                       fprintf(stderr, "System Error: %d (%s)\n", cf_errno, strerror(cf_errno));
109 +       }
110 +}
111 +
112  /* Define the order in which to probe for UDP/TCP services */
113  static const u_int *
114  proto_probelist(const int use_tcp)
115 @@ -252,14 +271,15 @@ nfs_gethostbyname(const char *hostname, 
116   * we're requesting, we open and RPC client, and fire off a NULL
117   * RPC call.
118   */
119 -static int
120 +int
121  clnt_ping(struct sockaddr_in *saddr, const u_long prog, const u_long vers,
122           const u_int prot)
123  {
124 -       CLIENT *clnt;
125 +       CLIENT *clnt=NULL;
126         int sock, stat;
127         static char clnt_res;
128  
129 +       rpc_createerr.cf_stat = stat = 0;
130         sock = RPC_ANYSOCK;
131         switch(prot) {
132         case IPPROTO_UDP:
133 @@ -285,6 +305,7 @@ clnt_ping(struct sockaddr_in *saddr, con
134         close(sock);
135         if (stat != RPC_PROGVERSMISMATCH)
136                 return 1;
137 +
138   out_bad:
139         return 0;
140  }
141 @@ -308,9 +329,9 @@ probe_port(clnt_addr_t *server,
142                 *p_prot;
143         const u_short port = (u_short) pmap->pm_port;
144         u_short p_port;
145 -
146         p_prot = prot ? &prot : protos;
147         p_vers = vers ? &vers : versions;
148 +       rpc_createerr.cf_stat = 0;
149         for (;;) {
150                 saddr->sin_port = htons(PMAPPORT);
151                 p_port = pmap_getport(saddr, prog, *p_vers, *p_prot);
152 @@ -338,6 +359,7 @@ probe_port(clnt_addr_t *server,
153                 pmap->pm_prot = *p_prot;
154         if (!port)
155                 pmap->pm_port = p_port;
156 +       rpc_createerr.cf_stat = 0;
157         return 1;
158  }
159  
160 @@ -394,6 +416,8 @@ probe_bothports(clnt_addr_t *mnt_server,
161                                 return 1;
162                         memcpy(mnt_pmap, &save_mnt, sizeof(*mnt_pmap));
163                 }
164 +               if (rpc_createerr.cf_stat != RPC_PROGNOTREGISTERED)
165 +                       break;
166                 memcpy(nfs_pmap, &save_nfs, sizeof(*nfs_pmap));
167         }
168   out_bad:
169 @@ -477,11 +501,23 @@ nfs_call_mount(clnt_addr_t *mnt_server, 
170         enum clnt_stat stat;
171         int msock;
172  
173 -
174         if (!probe_bothports(mnt_server, nfs_server)) {
175 -               if (report_errs)
176 -                       fprintf(stderr,_("mount: failed to probe ports on NFS server %s\n"),
177 +               if (report_errs) {
178 +                       fprintf(stderr, "mount to NFS server '%s' failed",
179                                 *nfs_server->hostname);
180 +                       if (rpc_createerr.cf_stat != RPC_PROGNOTREGISTERED) {
181 +                               fprintf(stderr, ": server is down.\n");
182 +                       } else  if (nfs_server->pmap.pm_prot) {
183 +                               fprintf(stderr, ": possible invalid protocol.\n");
184 +                       } else if (nfs_server->pmap.pm_port) {
185 +                               fprintf(stderr, ": possible invalid port.\n");
186 +                       } else {
187 +                               fprintf(stderr, ".\n");
188 +                       }
189 +                       if (verbose) {
190 +                               rpc_strerror();
191 +                       }
192 +               }
193                 goto out_bad;
194         }
195  
196 @@ -743,15 +779,19 @@ parse_options(char *old_opts, struct nfs
197  static inline int
198  nfsmnt_check_compat(const struct pmap *nfs_pmap, const struct pmap *mnt_pmap)
199  {
200 -       if (nfs_pmap->pm_vers > MAX_NFSPROT) {
201 +       if (nfs_pmap->pm_vers &&
202 +               (nfs_pmap->pm_vers > MAX_NFSPROT || nfs_pmap->pm_vers < 2)) {
203                 if (nfs_pmap->pm_vers == 4)
204 -                       fprintf(stderr, _("'vers=4' is not supported.  Use '-t nfs4' instead.\n"));
205 +                       fprintf(stderr, _("'vers=4' is not supported.  "
206 +                               "Use '-t nfs4' instead.\n"));
207                 else
208 -                       fprintf(stderr, _("NFSv%ld not supported!\n"), nfs_pmap->pm_vers);
209 +                       fprintf(stderr, _("NFS version %ld is not supported.\n"),
210 +                               nfs_pmap->pm_vers);
211                 goto out_bad;
212         }
213         if (mnt_pmap->pm_vers > MAX_MNTPROT) {
214 -               fprintf(stderr, _("NFS mount v%ld not supported!\n"), mnt_pmap->pm_vers);
215 +               fprintf(stderr, _("NFS mount version %ld s not supported.\n"),
216 +                       mnt_pmap->pm_vers);
217                 goto out_bad;
218         }
219         return 1;
220 @@ -1144,6 +1184,7 @@ nfs_call_umount(clnt_addr_t *mnt_server,
221                 res = nfs2_umount(argp, clnt);
222                 break;
223         default:
224 +               break;
225         }
226         mnt_closeclnt(clnt, msock);
227         if (res == RPC_SUCCESS)
228 _
This page took 0.042511 seconds and 3 git commands to generate.