blob: fff02d31249635d47b92ca9da62d806be1db6146 [file] [log] [blame]
Erik Andersene49d5ec2000-02-08 19:58:47 +00001/* vi: set sw=4 ts=4: */
Eric Andersen1c43d0c1999-11-18 07:58:07 +00002/*
3 * nfsmount.c -- Linux NFS mount
4 * Copyright (C) 1993 Rick Sladkey <jrs@world.std.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * Wed Feb 8 12:51:48 1995, biro@yggdrasil.com (Ross Biro): allow all port
17 * numbers to be specified on the command line.
18 *
19 * Fri, 8 Mar 1996 18:01:39, Swen Thuemmler <swen@uni-paderborn.de>:
20 * Omit the call to connect() for Linux version 1.3.11 or later.
21 *
22 * Wed Oct 1 23:55:28 1997: Dick Streefland <dick_streefland@tasking.com>
23 * Implemented the "bg", "fg" and "retry" mount options for NFS.
24 *
25 * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org>
26 * - added Native Language Support
27 *
Eric Andersenda1d1e72000-07-10 23:39:44 +000028 * Modified by Olaf Kirch and Trond Myklebust for new NFS code,
29 * plus NFSv3 stuff.
Eric Andersen1c43d0c1999-11-18 07:58:07 +000030 */
31
32/*
33 * nfsmount.c,v 1.1.1.1 1993/11/18 08:40:51 jrs Exp
34 */
35
Eric Andersen3570a342000-09-25 21:45:58 +000036#include "busybox.h"
Eric Andersene7413a92000-07-14 06:19:41 +000037#undef FALSE
38#undef TRUE
Eric Andersen1c43d0c1999-11-18 07:58:07 +000039#include <unistd.h>
40#include <stdio.h>
41#include <string.h>
42#include <errno.h>
43#include <netdb.h>
44#include <rpc/rpc.h>
45#include <rpc/pmap_prot.h>
46#include <rpc/pmap_clnt.h>
47#include <sys/socket.h>
Glenn L McGrath3f5bcbf2001-02-16 10:33:30 +000048#include <time.h>
49//#include <sys/time.h>
Eric Andersen1c43d0c1999-11-18 07:58:07 +000050#include <sys/utsname.h>
Eric Andersen1c43d0c1999-11-18 07:58:07 +000051#include <netinet/in.h>
52#include <arpa/inet.h>
53
54#include "nfsmount.h"
Eric Andersenda1d1e72000-07-10 23:39:44 +000055#include <linux/nfs.h> /* For the kernels nfs stuff */
Eric Andersen1c43d0c1999-11-18 07:58:07 +000056
Glenn L McGrathc52a97d2000-12-09 23:59:04 +000057#ifndef NFS_FHSIZE
Mark Whitley59ab0252001-01-23 22:30:04 +000058static const int NFS_FHSIZE = 32;
Glenn L McGrathc52a97d2000-12-09 23:59:04 +000059#endif
60#ifndef NFS_PORT
Mark Whitley59ab0252001-01-23 22:30:04 +000061static const int NFS_PORT = 2049;
Glenn L McGrathc52a97d2000-12-09 23:59:04 +000062#endif
Eric Andersen1c43d0c1999-11-18 07:58:07 +000063
Eric Andersenda1d1e72000-07-10 23:39:44 +000064/* Disable the nls stuff */
65# undef bindtextdomain
66# define bindtextdomain(Domain, Directory) /* empty */
67# undef textdomain
68# define textdomain(Domain) /* empty */
69# define _(Text) (Text)
70# define N_(Text) (Text)
71
Mark Whitley59ab0252001-01-23 22:30:04 +000072static const int MS_MGC_VAL = 0xc0ed0000; /* Magic number indicatng "new" flags */
73static const int MS_RDONLY = 1; /* Mount read-only */
74static const int MS_NOSUID = 2; /* Ignore suid and sgid bits */
75static const int MS_NODEV = 4; /* Disallow access to device special files */
76static const int MS_NOEXEC = 8; /* Disallow program execution */
77static const int MS_SYNCHRONOUS = 16; /* Writes are synced at once */
78static const int MS_REMOUNT = 32; /* Alter flags of a mounted FS */
79static const int MS_MANDLOCK = 64; /* Allow mandatory locks on an FS */
80static const int S_QUOTA = 128; /* Quota initialized for file/directory/symlink */
81static const int S_APPEND = 256; /* Append-only file */
82static const int S_IMMUTABLE = 512; /* Immutable file */
83static const int MS_NOATIME = 1024; /* Do not update access times. */
84static const int MS_NODIRATIME = 2048; /* Do not update directory access times */
Eric Andersenda1d1e72000-07-10 23:39:44 +000085
86
87/*
88 * We want to be able to compile mount on old kernels in such a way
89 * that the binary will work well on more recent kernels.
90 * Thus, if necessary we teach nfsmount.c the structure of new fields
91 * that will come later.
92 *
93 * Moreover, the new kernel includes conflict with glibc includes
94 * so it is easiest to ignore the kernel altogether (at compile time).
95 */
96
Mark Whitley85260672001-01-30 18:53:42 +000097/* NOTE: Do not make this into a 'static const int' because the pre-processor
98 * needs to test this value in some #if statements. */
99#define NFS_MOUNT_VERSION 4
Eric Andersenda1d1e72000-07-10 23:39:44 +0000100
101struct nfs2_fh {
102 char data[32];
103};
104struct nfs3_fh {
105 unsigned short size;
106 unsigned char data[64];
107};
108
109struct nfs_mount_data {
110 int version; /* 1 */
111 int fd; /* 1 */
112 struct nfs2_fh old_root; /* 1 */
113 int flags; /* 1 */
114 int rsize; /* 1 */
115 int wsize; /* 1 */
116 int timeo; /* 1 */
117 int retrans; /* 1 */
118 int acregmin; /* 1 */
119 int acregmax; /* 1 */
120 int acdirmin; /* 1 */
121 int acdirmax; /* 1 */
122 struct sockaddr_in addr; /* 1 */
123 char hostname[256]; /* 1 */
124 int namlen; /* 2 */
125 unsigned int bsize; /* 3 */
126 struct nfs3_fh root; /* 4 */
127};
128
129/* bits in the flags field */
130
Mark Whitley59ab0252001-01-23 22:30:04 +0000131static const int NFS_MOUNT_SOFT = 0x0001; /* 1 */
132static const int NFS_MOUNT_INTR = 0x0002; /* 1 */
133static const int NFS_MOUNT_SECURE = 0x0004; /* 1 */
134static const int NFS_MOUNT_POSIX = 0x0008; /* 1 */
135static const int NFS_MOUNT_NOCTO = 0x0010; /* 1 */
136static const int NFS_MOUNT_NOAC = 0x0020; /* 1 */
137static const int NFS_MOUNT_TCP = 0x0040; /* 2 */
138static const int NFS_MOUNT_VER3 = 0x0080; /* 3 */
139static const int NFS_MOUNT_KERBEROS = 0x0100; /* 3 */
140static const int NFS_MOUNT_NONLM = 0x0200; /* 3 */
Eric Andersenda1d1e72000-07-10 23:39:44 +0000141
142
143#define UTIL_LINUX_VERSION "2.10m"
144#define util_linux_version "util-linux-2.10m"
145
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000146#define HAVE_inet_aton
Eric Andersenda1d1e72000-07-10 23:39:44 +0000147#define HAVE_scsi_h
148#define HAVE_blkpg_h
149#define HAVE_kd_h
150#define HAVE_termcap
151#define HAVE_locale_h
152#define HAVE_libintl_h
153#define ENABLE_NLS
154#define HAVE_langinfo_h
155#define HAVE_progname
156#define HAVE_openpty
157#define HAVE_nanosleep
158#define HAVE_personality
159#define HAVE_tm_gmtoff
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000160
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000161static char *nfs_strerror(int stat);
162
163#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
Eric Andersenda1d1e72000-07-10 23:39:44 +0000164#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000165
Mark Whitley59ab0252001-01-23 22:30:04 +0000166static const int EX_FAIL = 32; /* mount failure */
167static const int EX_BG = 256; /* retry in background (internal only) */
Eric Andersenda1d1e72000-07-10 23:39:44 +0000168
169
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000170/*
Eric Andersenda1d1e72000-07-10 23:39:44 +0000171 * nfs_mount_version according to the sources seen at compile time.
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000172 */
Mark Whitley59ab0252001-01-23 22:30:04 +0000173static int nfs_mount_version;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000174
175/*
176 * Unfortunately, the kernel prints annoying console messages
177 * in case of an unexpected nfs mount version (instead of
178 * just returning some error). Therefore we'll have to try
179 * and figure out what version the kernel expects.
180 *
181 * Variables:
182 * KERNEL_NFS_MOUNT_VERSION: kernel sources at compile time
183 * NFS_MOUNT_VERSION: these nfsmount sources at compile time
184 * nfs_mount_version: version this source and running kernel can handle
185 */
Eric Andersenda1d1e72000-07-10 23:39:44 +0000186static void
Mark Whitley065c7e72001-02-01 19:51:13 +0000187find_kernel_nfs_mount_version(void)
188{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000189 static int kernel_version = 0;
190
191 if (kernel_version)
192 return;
193
Mark Whitley59ab0252001-01-23 22:30:04 +0000194 nfs_mount_version = NFS_MOUNT_VERSION; /* default */
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000195
Mark Whitley59ab0252001-01-23 22:30:04 +0000196 kernel_version = get_kernel_revision();
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000197 if (kernel_version) {
Mark Whitley065c7e72001-02-01 19:51:13 +0000198 if (kernel_version < MAKE_VERSION(2,1,32))
199 nfs_mount_version = 1;
200 else if (kernel_version < MAKE_VERSION(2,2,18) ||
201 (kernel_version >= MAKE_VERSION(2,3,0) &&
202 kernel_version < MAKE_VERSION(2,3,99)))
203 nfs_mount_version = 3;
204 else
205 nfs_mount_version = 4; /* since 2.3.99pre4 */
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000206 }
207 if (nfs_mount_version > NFS_MOUNT_VERSION)
Mark Whitley065c7e72001-02-01 19:51:13 +0000208 nfs_mount_version = NFS_MOUNT_VERSION;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000209}
210
Eric Andersenda1d1e72000-07-10 23:39:44 +0000211static struct pmap *
212get_mountport(struct sockaddr_in *server_addr,
213 long unsigned prog,
214 long unsigned version,
215 long unsigned proto,
216 long unsigned port)
217{
218struct pmaplist *pmap;
219static struct pmap p = {0, 0, 0, 0};
220
221server_addr->sin_port = PMAPPORT;
222pmap = pmap_getmaps(server_addr);
223
224if (version > MAX_NFSPROT)
225 version = MAX_NFSPROT;
226if (!prog)
227 prog = MOUNTPROG;
228p.pm_prog = prog;
229p.pm_vers = version;
230p.pm_prot = proto;
231p.pm_port = port;
232
233while (pmap) {
234 if (pmap->pml_map.pm_prog != prog)
235 goto next;
236 if (!version && p.pm_vers > pmap->pml_map.pm_vers)
237 goto next;
238 if (version > 2 && pmap->pml_map.pm_vers != version)
239 goto next;
240 if (version && version <= 2 && pmap->pml_map.pm_vers > 2)
241 goto next;
242 if (pmap->pml_map.pm_vers > MAX_NFSPROT ||
243 (proto && p.pm_prot && pmap->pml_map.pm_prot != proto) ||
244 (port && pmap->pml_map.pm_port != port))
245 goto next;
246 memcpy(&p, &pmap->pml_map, sizeof(p));
247next:
248 pmap = pmap->pml_next;
249}
250if (!p.pm_vers)
251 p.pm_vers = MOUNTVERS;
252if (!p.pm_port)
253 p.pm_port = MOUNTPORT;
254if (!p.pm_prot)
255 p.pm_prot = IPPROTO_TCP;
256return &p;
257}
258
259int nfsmount(const char *spec, const char *node, int *flags,
260 char **extra_opts, char **mount_opts, int running_bg)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000261{
262 static char *prev_bg_host;
263 char hostdir[1024];
264 CLIENT *mclient;
265 char *hostname;
266 char *dirname;
267 char *old_opts;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000268 char *mounthost=NULL;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000269 char new_opts[1024];
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000270 struct timeval total_timeout;
271 enum clnt_stat clnt_stat;
272 static struct nfs_mount_data data;
273 char *opt, *opteq;
274 int val;
275 struct hostent *hp;
276 struct sockaddr_in server_addr;
277 struct sockaddr_in mount_server_addr;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000278 struct pmap* pm_mnt;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000279 int msock, fsock;
280 struct timeval retry_timeout;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000281 union {
282 struct fhstatus nfsv2;
283 struct mountres3 nfsv3;
284 } status;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000285 struct stat statbuf;
286 char *s;
287 int port;
288 int mountport;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000289 int proto;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000290 int bg;
291 int soft;
292 int intr;
293 int posix;
294 int nocto;
295 int noac;
296 int nolock;
297 int retry;
298 int tcp;
299 int mountprog;
300 int mountvers;
301 int nfsprog;
302 int nfsvers;
303 int retval;
304 time_t t;
305 time_t prevt;
306 time_t timeout;
307
308 find_kernel_nfs_mount_version();
309
310 retval = EX_FAIL;
311 msock = fsock = -1;
312 mclient = NULL;
313 if (strlen(spec) >= sizeof(hostdir)) {
Matt Kraaidd19c692001-01-31 19:00:21 +0000314 error_msg("excessively long host:dir argument");
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000315 goto fail;
316 }
317 strcpy(hostdir, spec);
318 if ((s = strchr(hostdir, ':'))) {
319 hostname = hostdir;
320 dirname = s + 1;
321 *s = '\0';
322 /* Ignore all but first hostname in replicated mounts
323 until they can be fully supported. (mack@sgi.com) */
324 if ((s = strchr(hostdir, ','))) {
325 *s = '\0';
Matt Kraaidd19c692001-01-31 19:00:21 +0000326 error_msg("warning: multiple hostnames not supported");
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000327 }
328 } else {
Matt Kraaidd19c692001-01-31 19:00:21 +0000329 error_msg("directory to mount not in host:dir format");
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000330 goto fail;
331 }
332
333 server_addr.sin_family = AF_INET;
334#ifdef HAVE_inet_aton
335 if (!inet_aton(hostname, &server_addr.sin_addr))
336#endif
337 {
338 if ((hp = gethostbyname(hostname)) == NULL) {
Matt Kraaidd19c692001-01-31 19:00:21 +0000339 error_msg("can't get address for %s", hostname);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000340 goto fail;
341 } else {
342 if (hp->h_length > sizeof(struct in_addr)) {
Matt Kraaidd19c692001-01-31 19:00:21 +0000343 error_msg("got bad hp->h_length");
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000344 hp->h_length = sizeof(struct in_addr);
345 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000346 memcpy(&server_addr.sin_addr,
347 hp->h_addr, hp->h_length);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000348 }
349 }
350
Eric Andersenda1d1e72000-07-10 23:39:44 +0000351 memcpy (&mount_server_addr, &server_addr, sizeof (mount_server_addr));
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000352
353 /* add IP address to mtab options for use when unmounting */
354
355 s = inet_ntoa(server_addr.sin_addr);
356 old_opts = *extra_opts;
357 if (!old_opts)
358 old_opts = "";
359 if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) {
Matt Kraaidd19c692001-01-31 19:00:21 +0000360 error_msg("excessively long option argument");
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000361 goto fail;
362 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000363 sprintf(new_opts, "%s%saddr=%s",
364 old_opts, *old_opts ? "," : "", s);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000365 *extra_opts = xstrdup(new_opts);
366
367 /* Set default options.
368 * rsize/wsize (and bsize, for ver >= 3) are left 0 in order to
369 * let the kernel decide.
370 * timeo is filled in after we know whether it'll be TCP or UDP. */
371 memset(&data, 0, sizeof(data));
Eric Andersenda1d1e72000-07-10 23:39:44 +0000372 data.retrans = 3;
373 data.acregmin = 3;
374 data.acregmax = 60;
375 data.acdirmin = 30;
376 data.acdirmax = 60;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000377#if NFS_MOUNT_VERSION >= 2
Eric Andersenda1d1e72000-07-10 23:39:44 +0000378 data.namlen = NAME_MAX;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000379#endif
380
381 bg = 0;
382 soft = 0;
383 intr = 0;
384 posix = 0;
385 nocto = 0;
386 nolock = 0;
387 noac = 0;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000388 retry = 10000; /* 10000 minutes ~ 1 week */
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000389 tcp = 0;
390
391 mountprog = MOUNTPROG;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000392 mountvers = 0;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000393 port = 0;
394 mountport = 0;
395 nfsprog = NFS_PROGRAM;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000396 nfsvers = 0;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000397
398 /* parse options */
399
400 for (opt = strtok(old_opts, ","); opt; opt = strtok(NULL, ",")) {
401 if ((opteq = strchr(opt, '='))) {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000402 val = atoi(opteq + 1);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000403 *opteq = '\0';
404 if (!strcmp(opt, "rsize"))
405 data.rsize = val;
406 else if (!strcmp(opt, "wsize"))
407 data.wsize = val;
408 else if (!strcmp(opt, "timeo"))
409 data.timeo = val;
410 else if (!strcmp(opt, "retrans"))
411 data.retrans = val;
412 else if (!strcmp(opt, "acregmin"))
413 data.acregmin = val;
414 else if (!strcmp(opt, "acregmax"))
415 data.acregmax = val;
416 else if (!strcmp(opt, "acdirmin"))
417 data.acdirmin = val;
418 else if (!strcmp(opt, "acdirmax"))
419 data.acdirmax = val;
420 else if (!strcmp(opt, "actimeo")) {
421 data.acregmin = val;
422 data.acregmax = val;
423 data.acdirmin = val;
424 data.acdirmax = val;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000425 }
426 else if (!strcmp(opt, "retry"))
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000427 retry = val;
428 else if (!strcmp(opt, "port"))
429 port = val;
430 else if (!strcmp(opt, "mountport"))
Eric Andersenda1d1e72000-07-10 23:39:44 +0000431 mountport = val;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000432 else if (!strcmp(opt, "mounthost"))
Eric Andersenda1d1e72000-07-10 23:39:44 +0000433 mounthost=xstrndup(opteq+1,
434 strcspn(opteq+1," \t\n\r,"));
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000435 else if (!strcmp(opt, "mountprog"))
436 mountprog = val;
437 else if (!strcmp(opt, "mountvers"))
438 mountvers = val;
439 else if (!strcmp(opt, "nfsprog"))
440 nfsprog = val;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000441 else if (!strcmp(opt, "nfsvers") ||
442 !strcmp(opt, "vers"))
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000443 nfsvers = val;
444 else if (!strcmp(opt, "proto")) {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000445 if (!strncmp(opteq+1, "tcp", 3))
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000446 tcp = 1;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000447 else if (!strncmp(opteq+1, "udp", 3))
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000448 tcp = 0;
449 else
450 printf(_("Warning: Unrecognized proto= option.\n"));
451 } else if (!strcmp(opt, "namlen")) {
452#if NFS_MOUNT_VERSION >= 2
453 if (nfs_mount_version >= 2)
454 data.namlen = val;
455 else
456#endif
Eric Andersenda1d1e72000-07-10 23:39:44 +0000457 printf(_("Warning: Option namlen is not supported.\n"));
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000458 } else if (!strcmp(opt, "addr"))
Eric Andersenda1d1e72000-07-10 23:39:44 +0000459 /* ignore */;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000460 else {
461 printf(_("unknown nfs mount parameter: "
Eric Andersenda1d1e72000-07-10 23:39:44 +0000462 "%s=%d\n"), opt, val);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000463 goto fail;
464 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000465 }
466 else {
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000467 val = 1;
468 if (!strncmp(opt, "no", 2)) {
469 val = 0;
470 opt += 2;
471 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000472 if (!strcmp(opt, "bg"))
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000473 bg = val;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000474 else if (!strcmp(opt, "fg"))
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000475 bg = !val;
476 else if (!strcmp(opt, "soft"))
477 soft = val;
478 else if (!strcmp(opt, "hard"))
479 soft = !val;
480 else if (!strcmp(opt, "intr"))
481 intr = val;
482 else if (!strcmp(opt, "posix"))
483 posix = val;
484 else if (!strcmp(opt, "cto"))
485 nocto = !val;
486 else if (!strcmp(opt, "ac"))
487 noac = !val;
488 else if (!strcmp(opt, "tcp"))
489 tcp = val;
490 else if (!strcmp(opt, "udp"))
491 tcp = !val;
492 else if (!strcmp(opt, "lock")) {
493 if (nfs_mount_version >= 3)
494 nolock = !val;
495 else
Eric Andersenda1d1e72000-07-10 23:39:44 +0000496 printf(_("Warning: option nolock is not supported.\n"));
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000497 } else {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000498 printf(_("unknown nfs mount option: "
499 "%s%s\n"), val ? "" : "no", opt);
500 goto fail;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000501 }
502 }
503 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000504 proto = (tcp) ? IPPROTO_TCP : IPPROTO_UDP;
505
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000506 data.flags = (soft ? NFS_MOUNT_SOFT : 0)
507 | (intr ? NFS_MOUNT_INTR : 0)
508 | (posix ? NFS_MOUNT_POSIX : 0)
509 | (nocto ? NFS_MOUNT_NOCTO : 0)
510 | (noac ? NFS_MOUNT_NOAC : 0);
511#if NFS_MOUNT_VERSION >= 2
512 if (nfs_mount_version >= 2)
513 data.flags |= (tcp ? NFS_MOUNT_TCP : 0);
514#endif
515#if NFS_MOUNT_VERSION >= 3
516 if (nfs_mount_version >= 3)
517 data.flags |= (nolock ? NFS_MOUNT_NONLM : 0);
518#endif
Eric Andersenda1d1e72000-07-10 23:39:44 +0000519 if (nfsvers > MAX_NFSPROT) {
Matt Kraaidd19c692001-01-31 19:00:21 +0000520 error_msg("NFSv%d not supported!", nfsvers);
Eric Andersenda1d1e72000-07-10 23:39:44 +0000521 return 0;
522 }
523 if (mountvers > MAX_NFSPROT) {
Matt Kraaidd19c692001-01-31 19:00:21 +0000524 error_msg("NFSv%d not supported!", nfsvers);
Eric Andersenda1d1e72000-07-10 23:39:44 +0000525 return 0;
526 }
527 if (nfsvers && !mountvers)
528 mountvers = (nfsvers < 3) ? 1 : nfsvers;
529 if (nfsvers && nfsvers < mountvers) {
530 mountvers = nfsvers;
531 }
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000532
533 /* Adjust options if none specified */
534 if (!data.timeo)
535 data.timeo = tcp ? 70 : 7;
536
537#ifdef NFS_MOUNT_DEBUG
538 printf("rsize = %d, wsize = %d, timeo = %d, retrans = %d\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000539 data.rsize, data.wsize, data.timeo, data.retrans);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000540 printf("acreg (min, max) = (%d, %d), acdir (min, max) = (%d, %d)\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000541 data.acregmin, data.acregmax, data.acdirmin, data.acdirmax);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000542 printf("port = %d, bg = %d, retry = %d, flags = %.8x\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000543 port, bg, retry, data.flags);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000544 printf("mountprog = %d, mountvers = %d, nfsprog = %d, nfsvers = %d\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000545 mountprog, mountvers, nfsprog, nfsvers);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000546 printf("soft = %d, intr = %d, posix = %d, nocto = %d, noac = %d\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000547 (data.flags & NFS_MOUNT_SOFT) != 0,
548 (data.flags & NFS_MOUNT_INTR) != 0,
549 (data.flags & NFS_MOUNT_POSIX) != 0,
550 (data.flags & NFS_MOUNT_NOCTO) != 0,
551 (data.flags & NFS_MOUNT_NOAC) != 0);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000552#if NFS_MOUNT_VERSION >= 2
Eric Andersenda1d1e72000-07-10 23:39:44 +0000553 printf("tcp = %d\n",
554 (data.flags & NFS_MOUNT_TCP) != 0);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000555#endif
556#endif
557
558 data.version = nfs_mount_version;
559 *mount_opts = (char *) &data;
560
561 if (*flags & MS_REMOUNT)
562 return 0;
563
564 /*
565 * If the previous mount operation on the same host was
566 * backgrounded, and the "bg" for this mount is also set,
567 * give up immediately, to avoid the initial timeout.
568 */
569 if (bg && !running_bg &&
Eric Andersenda1d1e72000-07-10 23:39:44 +0000570 prev_bg_host && strcmp(hostname, prev_bg_host) == 0) {
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000571 if (retry > 0)
572 retval = EX_BG;
573 return retval;
574 }
575
576 /* create mount deamon client */
577 /* See if the nfs host = mount host. */
578 if (mounthost) {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000579 if (mounthost[0] >= '0' && mounthost[0] <= '9') {
580 mount_server_addr.sin_family = AF_INET;
581 mount_server_addr.sin_addr.s_addr = inet_addr(hostname);
582 } else {
583 if ((hp = gethostbyname(mounthost)) == NULL) {
Matt Kraaidd19c692001-01-31 19:00:21 +0000584 error_msg("can't get address for %s", hostname);
Eric Andersenda1d1e72000-07-10 23:39:44 +0000585 goto fail;
586 } else {
587 if (hp->h_length > sizeof(struct in_addr)) {
Matt Kraaidd19c692001-01-31 19:00:21 +0000588 error_msg("got bad hp->h_length?");
Eric Andersenda1d1e72000-07-10 23:39:44 +0000589 hp->h_length = sizeof(struct in_addr);
590 }
591 mount_server_addr.sin_family = AF_INET;
592 memcpy(&mount_server_addr.sin_addr,
593 hp->h_addr, hp->h_length);
594 }
595 }
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000596 }
597
598 /*
599 * The following loop implements the mount retries. On the first
600 * call, "running_bg" is 0. When the mount times out, and the
601 * "bg" option is set, the exit status EX_BG will be returned.
602 * For a backgrounded mount, there will be a second call by the
603 * child process with "running_bg" set to 1.
604 *
605 * The case where the mount point is not present and the "bg"
606 * option is set, is treated as a timeout. This is done to
607 * support nested mounts.
608 *
609 * The "retry" count specified by the user is the number of
610 * minutes to retry before giving up.
611 *
612 * Only the first error message will be displayed.
613 */
614 retry_timeout.tv_sec = 3;
615 retry_timeout.tv_usec = 0;
616 total_timeout.tv_sec = 20;
617 total_timeout.tv_usec = 0;
618 timeout = time(NULL) + 60 * retry;
619 prevt = 0;
620 t = 30;
621 val = 1;
622 for (;;) {
623 if (bg && stat(node, &statbuf) == -1) {
624 if (running_bg) {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000625 sleep(val); /* 1, 2, 4, 8, 16, 30, ... */
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000626 val *= 2;
627 if (val > 30)
628 val = 30;
629 }
630 } else {
631 /* be careful not to use too many CPU cycles */
632 if (t - prevt < 30)
633 sleep(30);
634
Eric Andersenda1d1e72000-07-10 23:39:44 +0000635 pm_mnt = get_mountport(&mount_server_addr,
636 mountprog,
637 mountvers,
638 proto,
639 mountport);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000640
Eric Andersenda1d1e72000-07-10 23:39:44 +0000641 /* contact the mount daemon via TCP */
642 mount_server_addr.sin_port = htons(pm_mnt->pm_port);
643 msock = RPC_ANYSOCK;
644
645 switch (pm_mnt->pm_prot) {
646 case IPPROTO_UDP:
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000647 mclient = clntudp_create(&mount_server_addr,
Eric Andersenda1d1e72000-07-10 23:39:44 +0000648 pm_mnt->pm_prog,
649 pm_mnt->pm_vers,
650 retry_timeout,
651 &msock);
652 if (mclient)
653 break;
654 mount_server_addr.sin_port = htons(pm_mnt->pm_port);
655 msock = RPC_ANYSOCK;
656 case IPPROTO_TCP:
657 mclient = clnttcp_create(&mount_server_addr,
658 pm_mnt->pm_prog,
659 pm_mnt->pm_vers,
660 &msock, 0, 0);
661 break;
662 default:
663 mclient = 0;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000664 }
665 if (mclient) {
666 /* try to mount hostname:dirname */
667 mclient->cl_auth = authunix_create_default();
Eric Andersenda1d1e72000-07-10 23:39:44 +0000668
669 /* make pointers in xdr_mountres3 NULL so
670 * that xdr_array allocates memory for us
671 */
672 memset(&status, 0, sizeof(status));
673
674 if (pm_mnt->pm_vers == 3)
675 clnt_stat = clnt_call(mclient, MOUNTPROC3_MNT,
676 (xdrproc_t) xdr_dirpath,
677 (caddr_t) &dirname,
678 (xdrproc_t) xdr_mountres3,
679 (caddr_t) &status,
680 total_timeout);
681 else
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000682 clnt_stat = clnt_call(mclient, MOUNTPROC_MNT,
Eric Andersenda1d1e72000-07-10 23:39:44 +0000683 (xdrproc_t) xdr_dirpath,
684 (caddr_t) &dirname,
685 (xdrproc_t) xdr_fhstatus,
686 (caddr_t) &status,
687 total_timeout);
688
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000689 if (clnt_stat == RPC_SUCCESS)
690 break; /* we're done */
691 if (errno != ECONNREFUSED) {
692 clnt_perror(mclient, "mount");
693 goto fail; /* don't retry */
694 }
695 if (!running_bg && prevt == 0)
696 clnt_perror(mclient, "mount");
697 auth_destroy(mclient->cl_auth);
698 clnt_destroy(mclient);
699 mclient = 0;
700 close(msock);
701 } else {
702 if (!running_bg && prevt == 0)
703 clnt_pcreateerror("mount");
704 }
705 prevt = t;
706 }
707 if (!bg)
Eric Andersenda1d1e72000-07-10 23:39:44 +0000708 goto fail;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000709 if (!running_bg) {
710 prev_bg_host = xstrdup(hostname);
711 if (retry > 0)
712 retval = EX_BG;
713 goto fail;
714 }
715 t = time(NULL);
716 if (t >= timeout)
717 goto fail;
718 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000719 nfsvers = (pm_mnt->pm_vers < 2) ? 2 : pm_mnt->pm_vers;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000720
Eric Andersenda1d1e72000-07-10 23:39:44 +0000721 if (nfsvers == 2) {
722 if (status.nfsv2.fhs_status != 0) {
Matt Kraaidd19c692001-01-31 19:00:21 +0000723 error_msg("%s:%s failed, reason given by server: %s",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000724 hostname, dirname,
725 nfs_strerror(status.nfsv2.fhs_status));
726 goto fail;
727 }
728 memcpy(data.root.data,
729 (char *) status.nfsv2.fhstatus_u.fhs_fhandle,
730 NFS_FHSIZE);
731#if NFS_MOUNT_VERSION >= 4
732 data.root.size = NFS_FHSIZE;
733 memcpy(data.old_root.data,
734 (char *) status.nfsv2.fhstatus_u.fhs_fhandle,
735 NFS_FHSIZE);
736#endif
737 } else {
738#if NFS_MOUNT_VERSION >= 4
739 fhandle3 *fhandle;
740 if (status.nfsv3.fhs_status != 0) {
Matt Kraaidd19c692001-01-31 19:00:21 +0000741 error_msg("%s:%s failed, reason given by server: %s",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000742 hostname, dirname,
743 nfs_strerror(status.nfsv3.fhs_status));
744 goto fail;
745 }
746 fhandle = &status.nfsv3.mountres3_u.mountinfo.fhandle;
747 memset(data.old_root.data, 0, NFS_FHSIZE);
748 memset(&data.root, 0, sizeof(data.root));
749 data.root.size = fhandle->fhandle3_len;
750 memcpy(data.root.data,
751 (char *) fhandle->fhandle3_val,
752 fhandle->fhandle3_len);
753
754 data.flags |= NFS_MOUNT_VER3;
755#endif
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000756 }
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000757
758 /* create nfs socket for kernel */
759
760 if (tcp) {
761 if (nfs_mount_version < 3) {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000762 printf(_("NFS over TCP is not supported.\n"));
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000763 goto fail;
764 }
765 fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
766 } else
767 fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
768 if (fsock < 0) {
769 perror(_("nfs socket"));
770 goto fail;
771 }
772 if (bindresvport(fsock, 0) < 0) {
773 perror(_("nfs bindresvport"));
774 goto fail;
775 }
776 if (port == 0) {
777 server_addr.sin_port = PMAPPORT;
778 port = pmap_getport(&server_addr, nfsprog, nfsvers,
Eric Andersenda1d1e72000-07-10 23:39:44 +0000779 tcp ? IPPROTO_TCP : IPPROTO_UDP);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000780 if (port == 0)
781 port = NFS_PORT;
782#ifdef NFS_MOUNT_DEBUG
783 else
784 printf(_("used portmapper to find NFS port\n"));
785#endif
786 }
787#ifdef NFS_MOUNT_DEBUG
788 printf(_("using port %d for nfs deamon\n"), port);
789#endif
790 server_addr.sin_port = htons(port);
Eric Andersenda1d1e72000-07-10 23:39:44 +0000791 /*
792 * connect() the socket for kernels 1.3.10 and below only,
793 * to avoid problems with multihomed hosts.
794 * --Swen
795 */
Eric Andersenef936da2000-10-30 17:22:04 +0000796 if (get_kernel_revision() <= 66314
Eric Andersenda1d1e72000-07-10 23:39:44 +0000797 && connect(fsock, (struct sockaddr *) &server_addr,
798 sizeof (server_addr)) < 0) {
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000799 perror(_("nfs connect"));
800 goto fail;
801 }
802
803 /* prepare data structure for kernel */
804
805 data.fd = fsock;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000806 memcpy((char *) &data.addr, (char *) &server_addr, sizeof(data.addr));
807 strncpy(data.hostname, hostname, sizeof(data.hostname));
808
809 /* clean up */
810
811 auth_destroy(mclient->cl_auth);
812 clnt_destroy(mclient);
813 close(msock);
814 return 0;
815
816 /* abort */
817
Eric Andersenda1d1e72000-07-10 23:39:44 +0000818fail:
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000819 if (msock != -1) {
820 if (mclient) {
821 auth_destroy(mclient->cl_auth);
822 clnt_destroy(mclient);
823 }
824 close(msock);
825 }
826 if (fsock != -1)
827 close(fsock);
828 return retval;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000829}
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000830
831/*
832 * We need to translate between nfs status return values and
833 * the local errno values which may not be the same.
834 *
835 * Andreas Schwab <schwab@LS5.informatik.uni-dortmund.de>: change errno:
836 * "after #include <errno.h> the symbol errno is reserved for any use,
837 * it cannot even be used as a struct tag or field name".
838 */
839
840#ifndef EDQUOT
841#define EDQUOT ENOSPC
842#endif
843
844static struct {
845 enum nfs_stat stat;
846 int errnum;
847} nfs_errtbl[] = {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000848 { NFS_OK, 0 },
849 { NFSERR_PERM, EPERM },
850 { NFSERR_NOENT, ENOENT },
851 { NFSERR_IO, EIO },
852 { NFSERR_NXIO, ENXIO },
853 { NFSERR_ACCES, EACCES },
854 { NFSERR_EXIST, EEXIST },
855 { NFSERR_NODEV, ENODEV },
856 { NFSERR_NOTDIR, ENOTDIR },
857 { NFSERR_ISDIR, EISDIR },
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000858#ifdef NFSERR_INVAL
Eric Andersenda1d1e72000-07-10 23:39:44 +0000859 { NFSERR_INVAL, EINVAL }, /* that Sun forgot */
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000860#endif
Eric Andersenda1d1e72000-07-10 23:39:44 +0000861 { NFSERR_FBIG, EFBIG },
862 { NFSERR_NOSPC, ENOSPC },
863 { NFSERR_ROFS, EROFS },
864 { NFSERR_NAMETOOLONG, ENAMETOOLONG },
865 { NFSERR_NOTEMPTY, ENOTEMPTY },
866 { NFSERR_DQUOT, EDQUOT },
867 { NFSERR_STALE, ESTALE },
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000868#ifdef EWFLUSH
Eric Andersenda1d1e72000-07-10 23:39:44 +0000869 { NFSERR_WFLUSH, EWFLUSH },
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000870#endif
Eric Andersenda1d1e72000-07-10 23:39:44 +0000871 /* Throw in some NFSv3 values for even more fun (HP returns these) */
872 { 71, EREMOTE },
873
874 { -1, EIO }
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000875};
876
877static char *nfs_strerror(int stat)
878{
879 int i;
880 static char buf[256];
881
882 for (i = 0; nfs_errtbl[i].stat != -1; i++) {
883 if (nfs_errtbl[i].stat == stat)
884 return strerror(nfs_errtbl[i].errnum);
885 }
886 sprintf(buf, _("unknown nfs status return value: %d"), stat);
887 return buf;
888}
889
Eric Andersenda1d1e72000-07-10 23:39:44 +0000890bool_t
891xdr_fhandle (XDR *xdrs, fhandle objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000892{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000893 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000894
Eric Andersenda1d1e72000-07-10 23:39:44 +0000895 if (!xdr_opaque (xdrs, objp, FHSIZE))
896 return FALSE;
897 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000898}
899
Eric Andersenda1d1e72000-07-10 23:39:44 +0000900bool_t
901xdr_fhstatus (XDR *xdrs, fhstatus *objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000902{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000903 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000904
Eric Andersenda1d1e72000-07-10 23:39:44 +0000905 if (!xdr_u_int (xdrs, &objp->fhs_status))
906 return FALSE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000907 switch (objp->fhs_status) {
908 case 0:
Eric Andersenda1d1e72000-07-10 23:39:44 +0000909 if (!xdr_fhandle (xdrs, objp->fhstatus_u.fhs_fhandle))
910 return FALSE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000911 break;
912 default:
913 break;
914 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000915 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000916}
917
Eric Andersenda1d1e72000-07-10 23:39:44 +0000918bool_t
919xdr_dirpath (XDR *xdrs, dirpath *objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000920{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000921 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000922
Eric Andersenda1d1e72000-07-10 23:39:44 +0000923 if (!xdr_string (xdrs, objp, MNTPATHLEN))
924 return FALSE;
925 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000926}
927
Eric Andersenda1d1e72000-07-10 23:39:44 +0000928bool_t
929xdr_fhandle3 (XDR *xdrs, fhandle3 *objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000930{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000931 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000932
Eric Andersenda1d1e72000-07-10 23:39:44 +0000933 if (!xdr_bytes (xdrs, (char **)&objp->fhandle3_val, (u_int *) &objp->fhandle3_len, FHSIZE3))
934 return FALSE;
935 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000936}
937
Eric Andersenda1d1e72000-07-10 23:39:44 +0000938bool_t
939xdr_mountres3_ok (XDR *xdrs, mountres3_ok *objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000940{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000941 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000942
Eric Andersenda1d1e72000-07-10 23:39:44 +0000943 if (!xdr_fhandle3 (xdrs, &objp->fhandle))
944 return FALSE;
945 if (!xdr_array (xdrs, (char **)&objp->auth_flavours.auth_flavours_val, (u_int *) &objp->auth_flavours.auth_flavours_len, ~0,
946 sizeof (int), (xdrproc_t) xdr_int))
947 return FALSE;
948 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000949}
950
Eric Andersenda1d1e72000-07-10 23:39:44 +0000951bool_t
952xdr_mountstat3 (XDR *xdrs, mountstat3 *objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000953{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000954 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000955
Eric Andersenda1d1e72000-07-10 23:39:44 +0000956 if (!xdr_enum (xdrs, (enum_t *) objp))
957 return FALSE;
958 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000959}
960
Eric Andersenda1d1e72000-07-10 23:39:44 +0000961bool_t
962xdr_mountres3 (XDR *xdrs, mountres3 *objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000963{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000964 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000965
Eric Andersenda1d1e72000-07-10 23:39:44 +0000966 if (!xdr_mountstat3 (xdrs, &objp->fhs_status))
967 return FALSE;
968 switch (objp->fhs_status) {
969 case MNT_OK:
970 if (!xdr_mountres3_ok (xdrs, &objp->mountres3_u.mountinfo))
971 return FALSE;
972 break;
973 default:
974 break;
Erik Andersene49d5ec2000-02-08 19:58:47 +0000975 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000976 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000977}
978