blob: b260a885f3faa2eb2dff475d6910701997423562 [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>
48#include <sys/time.h>
49#include <sys/utsname.h>
Eric Andersen1c43d0c1999-11-18 07:58:07 +000050#include <netinet/in.h>
51#include <arpa/inet.h>
52
53#include "nfsmount.h"
Eric Andersenda1d1e72000-07-10 23:39:44 +000054#include <linux/nfs.h> /* For the kernels nfs stuff */
Eric Andersen1c43d0c1999-11-18 07:58:07 +000055
Glenn L McGrathc52a97d2000-12-09 23:59:04 +000056#ifndef NFS_FHSIZE
Mark Whitley59ab0252001-01-23 22:30:04 +000057static const int NFS_FHSIZE = 32;
Glenn L McGrathc52a97d2000-12-09 23:59:04 +000058#endif
59#ifndef NFS_PORT
Mark Whitley59ab0252001-01-23 22:30:04 +000060static const int NFS_PORT = 2049;
Glenn L McGrathc52a97d2000-12-09 23:59:04 +000061#endif
Eric Andersen1c43d0c1999-11-18 07:58:07 +000062
Eric Andersenda1d1e72000-07-10 23:39:44 +000063/* Disable the nls stuff */
64# undef bindtextdomain
65# define bindtextdomain(Domain, Directory) /* empty */
66# undef textdomain
67# define textdomain(Domain) /* empty */
68# define _(Text) (Text)
69# define N_(Text) (Text)
70
Mark Whitley59ab0252001-01-23 22:30:04 +000071static const int MS_MGC_VAL = 0xc0ed0000; /* Magic number indicatng "new" flags */
72static const int MS_RDONLY = 1; /* Mount read-only */
73static const int MS_NOSUID = 2; /* Ignore suid and sgid bits */
74static const int MS_NODEV = 4; /* Disallow access to device special files */
75static const int MS_NOEXEC = 8; /* Disallow program execution */
76static const int MS_SYNCHRONOUS = 16; /* Writes are synced at once */
77static const int MS_REMOUNT = 32; /* Alter flags of a mounted FS */
78static const int MS_MANDLOCK = 64; /* Allow mandatory locks on an FS */
79static const int S_QUOTA = 128; /* Quota initialized for file/directory/symlink */
80static const int S_APPEND = 256; /* Append-only file */
81static const int S_IMMUTABLE = 512; /* Immutable file */
82static const int MS_NOATIME = 1024; /* Do not update access times. */
83static const int MS_NODIRATIME = 2048; /* Do not update directory access times */
Eric Andersenda1d1e72000-07-10 23:39:44 +000084
85
86/*
87 * We want to be able to compile mount on old kernels in such a way
88 * that the binary will work well on more recent kernels.
89 * Thus, if necessary we teach nfsmount.c the structure of new fields
90 * that will come later.
91 *
92 * Moreover, the new kernel includes conflict with glibc includes
93 * so it is easiest to ignore the kernel altogether (at compile time).
94 */
95
Mark Whitley85260672001-01-30 18:53:42 +000096/* NOTE: Do not make this into a 'static const int' because the pre-processor
97 * needs to test this value in some #if statements. */
98#define NFS_MOUNT_VERSION 4
Eric Andersenda1d1e72000-07-10 23:39:44 +000099
100struct nfs2_fh {
101 char data[32];
102};
103struct nfs3_fh {
104 unsigned short size;
105 unsigned char data[64];
106};
107
108struct nfs_mount_data {
109 int version; /* 1 */
110 int fd; /* 1 */
111 struct nfs2_fh old_root; /* 1 */
112 int flags; /* 1 */
113 int rsize; /* 1 */
114 int wsize; /* 1 */
115 int timeo; /* 1 */
116 int retrans; /* 1 */
117 int acregmin; /* 1 */
118 int acregmax; /* 1 */
119 int acdirmin; /* 1 */
120 int acdirmax; /* 1 */
121 struct sockaddr_in addr; /* 1 */
122 char hostname[256]; /* 1 */
123 int namlen; /* 2 */
124 unsigned int bsize; /* 3 */
125 struct nfs3_fh root; /* 4 */
126};
127
128/* bits in the flags field */
129
Mark Whitley59ab0252001-01-23 22:30:04 +0000130static const int NFS_MOUNT_SOFT = 0x0001; /* 1 */
131static const int NFS_MOUNT_INTR = 0x0002; /* 1 */
132static const int NFS_MOUNT_SECURE = 0x0004; /* 1 */
133static const int NFS_MOUNT_POSIX = 0x0008; /* 1 */
134static const int NFS_MOUNT_NOCTO = 0x0010; /* 1 */
135static const int NFS_MOUNT_NOAC = 0x0020; /* 1 */
136static const int NFS_MOUNT_TCP = 0x0040; /* 2 */
137static const int NFS_MOUNT_VER3 = 0x0080; /* 3 */
138static const int NFS_MOUNT_KERBEROS = 0x0100; /* 3 */
139static const int NFS_MOUNT_NONLM = 0x0200; /* 3 */
Eric Andersenda1d1e72000-07-10 23:39:44 +0000140
141
142#define UTIL_LINUX_VERSION "2.10m"
143#define util_linux_version "util-linux-2.10m"
144
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000145#define HAVE_inet_aton
Eric Andersenda1d1e72000-07-10 23:39:44 +0000146#define HAVE_scsi_h
147#define HAVE_blkpg_h
148#define HAVE_kd_h
149#define HAVE_termcap
150#define HAVE_locale_h
151#define HAVE_libintl_h
152#define ENABLE_NLS
153#define HAVE_langinfo_h
154#define HAVE_progname
155#define HAVE_openpty
156#define HAVE_nanosleep
157#define HAVE_personality
158#define HAVE_tm_gmtoff
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000159
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000160static char *nfs_strerror(int stat);
161
162#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
Eric Andersenda1d1e72000-07-10 23:39:44 +0000163#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000164
Mark Whitley59ab0252001-01-23 22:30:04 +0000165static const int EX_FAIL = 32; /* mount failure */
166static const int EX_BG = 256; /* retry in background (internal only) */
Eric Andersenda1d1e72000-07-10 23:39:44 +0000167
168
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000169/*
Eric Andersenda1d1e72000-07-10 23:39:44 +0000170 * nfs_mount_version according to the sources seen at compile time.
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000171 */
Mark Whitley59ab0252001-01-23 22:30:04 +0000172static int nfs_mount_version;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000173
174/*
175 * Unfortunately, the kernel prints annoying console messages
176 * in case of an unexpected nfs mount version (instead of
177 * just returning some error). Therefore we'll have to try
178 * and figure out what version the kernel expects.
179 *
180 * Variables:
181 * KERNEL_NFS_MOUNT_VERSION: kernel sources at compile time
182 * NFS_MOUNT_VERSION: these nfsmount sources at compile time
183 * nfs_mount_version: version this source and running kernel can handle
184 */
Eric Andersenda1d1e72000-07-10 23:39:44 +0000185static void
186find_kernel_nfs_mount_version(void) {
187 static int kernel_version = 0;
188
189 if (kernel_version)
190 return;
191
Mark Whitley59ab0252001-01-23 22:30:04 +0000192 nfs_mount_version = NFS_MOUNT_VERSION; /* default */
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000193
Mark Whitley59ab0252001-01-23 22:30:04 +0000194 kernel_version = get_kernel_revision();
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000195 if (kernel_version) {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000196 if (kernel_version < MAKE_VERSION(2,1,32))
197 nfs_mount_version = 1;
198 else if (kernel_version < MAKE_VERSION(2,3,99))
199 nfs_mount_version = 3;
200 else
201 nfs_mount_version = 4; /* since 2.3.99pre4 */
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000202 }
203 if (nfs_mount_version > NFS_MOUNT_VERSION)
Eric Andersenda1d1e72000-07-10 23:39:44 +0000204 nfs_mount_version = NFS_MOUNT_VERSION;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000205}
206
Eric Andersenda1d1e72000-07-10 23:39:44 +0000207static struct pmap *
208get_mountport(struct sockaddr_in *server_addr,
209 long unsigned prog,
210 long unsigned version,
211 long unsigned proto,
212 long unsigned port)
213{
214struct pmaplist *pmap;
215static struct pmap p = {0, 0, 0, 0};
216
217server_addr->sin_port = PMAPPORT;
218pmap = pmap_getmaps(server_addr);
219
220if (version > MAX_NFSPROT)
221 version = MAX_NFSPROT;
222if (!prog)
223 prog = MOUNTPROG;
224p.pm_prog = prog;
225p.pm_vers = version;
226p.pm_prot = proto;
227p.pm_port = port;
228
229while (pmap) {
230 if (pmap->pml_map.pm_prog != prog)
231 goto next;
232 if (!version && p.pm_vers > pmap->pml_map.pm_vers)
233 goto next;
234 if (version > 2 && pmap->pml_map.pm_vers != version)
235 goto next;
236 if (version && version <= 2 && pmap->pml_map.pm_vers > 2)
237 goto next;
238 if (pmap->pml_map.pm_vers > MAX_NFSPROT ||
239 (proto && p.pm_prot && pmap->pml_map.pm_prot != proto) ||
240 (port && pmap->pml_map.pm_port != port))
241 goto next;
242 memcpy(&p, &pmap->pml_map, sizeof(p));
243next:
244 pmap = pmap->pml_next;
245}
246if (!p.pm_vers)
247 p.pm_vers = MOUNTVERS;
248if (!p.pm_port)
249 p.pm_port = MOUNTPORT;
250if (!p.pm_prot)
251 p.pm_prot = IPPROTO_TCP;
252return &p;
253}
254
255int nfsmount(const char *spec, const char *node, int *flags,
256 char **extra_opts, char **mount_opts, int running_bg)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000257{
258 static char *prev_bg_host;
259 char hostdir[1024];
260 CLIENT *mclient;
261 char *hostname;
262 char *dirname;
263 char *old_opts;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000264 char *mounthost=NULL;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000265 char new_opts[1024];
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000266 struct timeval total_timeout;
267 enum clnt_stat clnt_stat;
268 static struct nfs_mount_data data;
269 char *opt, *opteq;
270 int val;
271 struct hostent *hp;
272 struct sockaddr_in server_addr;
273 struct sockaddr_in mount_server_addr;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000274 struct pmap* pm_mnt;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000275 int msock, fsock;
276 struct timeval retry_timeout;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000277 union {
278 struct fhstatus nfsv2;
279 struct mountres3 nfsv3;
280 } status;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000281 struct stat statbuf;
282 char *s;
283 int port;
284 int mountport;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000285 int proto;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000286 int bg;
287 int soft;
288 int intr;
289 int posix;
290 int nocto;
291 int noac;
292 int nolock;
293 int retry;
294 int tcp;
295 int mountprog;
296 int mountvers;
297 int nfsprog;
298 int nfsvers;
299 int retval;
300 time_t t;
301 time_t prevt;
302 time_t timeout;
303
304 find_kernel_nfs_mount_version();
305
306 retval = EX_FAIL;
307 msock = fsock = -1;
308 mclient = NULL;
309 if (strlen(spec) >= sizeof(hostdir)) {
Mark Whitleyf57c9442000-12-07 19:56:48 +0000310 error_msg("excessively long host:dir argument\n");
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000311 goto fail;
312 }
313 strcpy(hostdir, spec);
314 if ((s = strchr(hostdir, ':'))) {
315 hostname = hostdir;
316 dirname = s + 1;
317 *s = '\0';
318 /* Ignore all but first hostname in replicated mounts
319 until they can be fully supported. (mack@sgi.com) */
320 if ((s = strchr(hostdir, ','))) {
321 *s = '\0';
Mark Whitleyf57c9442000-12-07 19:56:48 +0000322 error_msg("warning: multiple hostnames not supported\n");
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000323 }
324 } else {
Mark Whitleyf57c9442000-12-07 19:56:48 +0000325 error_msg("directory to mount not in host:dir format\n");
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000326 goto fail;
327 }
328
329 server_addr.sin_family = AF_INET;
330#ifdef HAVE_inet_aton
331 if (!inet_aton(hostname, &server_addr.sin_addr))
332#endif
333 {
334 if ((hp = gethostbyname(hostname)) == NULL) {
Mark Whitleyf57c9442000-12-07 19:56:48 +0000335 error_msg("can't get address for %s\n", hostname);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000336 goto fail;
337 } else {
338 if (hp->h_length > sizeof(struct in_addr)) {
Mark Whitleyf57c9442000-12-07 19:56:48 +0000339 error_msg("got bad hp->h_length\n");
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000340 hp->h_length = sizeof(struct in_addr);
341 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000342 memcpy(&server_addr.sin_addr,
343 hp->h_addr, hp->h_length);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000344 }
345 }
346
Eric Andersenda1d1e72000-07-10 23:39:44 +0000347 memcpy (&mount_server_addr, &server_addr, sizeof (mount_server_addr));
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000348
349 /* add IP address to mtab options for use when unmounting */
350
351 s = inet_ntoa(server_addr.sin_addr);
352 old_opts = *extra_opts;
353 if (!old_opts)
354 old_opts = "";
355 if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) {
Mark Whitleyf57c9442000-12-07 19:56:48 +0000356 error_msg("excessively long option argument\n");
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000357 goto fail;
358 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000359 sprintf(new_opts, "%s%saddr=%s",
360 old_opts, *old_opts ? "," : "", s);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000361 *extra_opts = xstrdup(new_opts);
362
363 /* Set default options.
364 * rsize/wsize (and bsize, for ver >= 3) are left 0 in order to
365 * let the kernel decide.
366 * timeo is filled in after we know whether it'll be TCP or UDP. */
367 memset(&data, 0, sizeof(data));
Eric Andersenda1d1e72000-07-10 23:39:44 +0000368 data.retrans = 3;
369 data.acregmin = 3;
370 data.acregmax = 60;
371 data.acdirmin = 30;
372 data.acdirmax = 60;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000373#if NFS_MOUNT_VERSION >= 2
Eric Andersenda1d1e72000-07-10 23:39:44 +0000374 data.namlen = NAME_MAX;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000375#endif
376
377 bg = 0;
378 soft = 0;
379 intr = 0;
380 posix = 0;
381 nocto = 0;
382 nolock = 0;
383 noac = 0;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000384 retry = 10000; /* 10000 minutes ~ 1 week */
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000385 tcp = 0;
386
387 mountprog = MOUNTPROG;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000388 mountvers = 0;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000389 port = 0;
390 mountport = 0;
391 nfsprog = NFS_PROGRAM;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000392 nfsvers = 0;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000393
394 /* parse options */
395
396 for (opt = strtok(old_opts, ","); opt; opt = strtok(NULL, ",")) {
397 if ((opteq = strchr(opt, '='))) {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000398 val = atoi(opteq + 1);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000399 *opteq = '\0';
400 if (!strcmp(opt, "rsize"))
401 data.rsize = val;
402 else if (!strcmp(opt, "wsize"))
403 data.wsize = val;
404 else if (!strcmp(opt, "timeo"))
405 data.timeo = val;
406 else if (!strcmp(opt, "retrans"))
407 data.retrans = val;
408 else if (!strcmp(opt, "acregmin"))
409 data.acregmin = val;
410 else if (!strcmp(opt, "acregmax"))
411 data.acregmax = val;
412 else if (!strcmp(opt, "acdirmin"))
413 data.acdirmin = val;
414 else if (!strcmp(opt, "acdirmax"))
415 data.acdirmax = val;
416 else if (!strcmp(opt, "actimeo")) {
417 data.acregmin = val;
418 data.acregmax = val;
419 data.acdirmin = val;
420 data.acdirmax = val;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000421 }
422 else if (!strcmp(opt, "retry"))
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000423 retry = val;
424 else if (!strcmp(opt, "port"))
425 port = val;
426 else if (!strcmp(opt, "mountport"))
Eric Andersenda1d1e72000-07-10 23:39:44 +0000427 mountport = val;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000428 else if (!strcmp(opt, "mounthost"))
Eric Andersenda1d1e72000-07-10 23:39:44 +0000429 mounthost=xstrndup(opteq+1,
430 strcspn(opteq+1," \t\n\r,"));
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000431 else if (!strcmp(opt, "mountprog"))
432 mountprog = val;
433 else if (!strcmp(opt, "mountvers"))
434 mountvers = val;
435 else if (!strcmp(opt, "nfsprog"))
436 nfsprog = val;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000437 else if (!strcmp(opt, "nfsvers") ||
438 !strcmp(opt, "vers"))
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000439 nfsvers = val;
440 else if (!strcmp(opt, "proto")) {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000441 if (!strncmp(opteq+1, "tcp", 3))
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000442 tcp = 1;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000443 else if (!strncmp(opteq+1, "udp", 3))
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000444 tcp = 0;
445 else
446 printf(_("Warning: Unrecognized proto= option.\n"));
447 } else if (!strcmp(opt, "namlen")) {
448#if NFS_MOUNT_VERSION >= 2
449 if (nfs_mount_version >= 2)
450 data.namlen = val;
451 else
452#endif
Eric Andersenda1d1e72000-07-10 23:39:44 +0000453 printf(_("Warning: Option namlen is not supported.\n"));
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000454 } else if (!strcmp(opt, "addr"))
Eric Andersenda1d1e72000-07-10 23:39:44 +0000455 /* ignore */;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000456 else {
457 printf(_("unknown nfs mount parameter: "
Eric Andersenda1d1e72000-07-10 23:39:44 +0000458 "%s=%d\n"), opt, val);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000459 goto fail;
460 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000461 }
462 else {
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000463 val = 1;
464 if (!strncmp(opt, "no", 2)) {
465 val = 0;
466 opt += 2;
467 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000468 if (!strcmp(opt, "bg"))
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000469 bg = val;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000470 else if (!strcmp(opt, "fg"))
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000471 bg = !val;
472 else if (!strcmp(opt, "soft"))
473 soft = val;
474 else if (!strcmp(opt, "hard"))
475 soft = !val;
476 else if (!strcmp(opt, "intr"))
477 intr = val;
478 else if (!strcmp(opt, "posix"))
479 posix = val;
480 else if (!strcmp(opt, "cto"))
481 nocto = !val;
482 else if (!strcmp(opt, "ac"))
483 noac = !val;
484 else if (!strcmp(opt, "tcp"))
485 tcp = val;
486 else if (!strcmp(opt, "udp"))
487 tcp = !val;
488 else if (!strcmp(opt, "lock")) {
489 if (nfs_mount_version >= 3)
490 nolock = !val;
491 else
Eric Andersenda1d1e72000-07-10 23:39:44 +0000492 printf(_("Warning: option nolock is not supported.\n"));
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000493 } else {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000494 printf(_("unknown nfs mount option: "
495 "%s%s\n"), val ? "" : "no", opt);
496 goto fail;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000497 }
498 }
499 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000500 proto = (tcp) ? IPPROTO_TCP : IPPROTO_UDP;
501
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000502 data.flags = (soft ? NFS_MOUNT_SOFT : 0)
503 | (intr ? NFS_MOUNT_INTR : 0)
504 | (posix ? NFS_MOUNT_POSIX : 0)
505 | (nocto ? NFS_MOUNT_NOCTO : 0)
506 | (noac ? NFS_MOUNT_NOAC : 0);
507#if NFS_MOUNT_VERSION >= 2
508 if (nfs_mount_version >= 2)
509 data.flags |= (tcp ? NFS_MOUNT_TCP : 0);
510#endif
511#if NFS_MOUNT_VERSION >= 3
512 if (nfs_mount_version >= 3)
513 data.flags |= (nolock ? NFS_MOUNT_NONLM : 0);
514#endif
Eric Andersenda1d1e72000-07-10 23:39:44 +0000515 if (nfsvers > MAX_NFSPROT) {
Mark Whitleyf57c9442000-12-07 19:56:48 +0000516 error_msg("NFSv%d not supported!\n", nfsvers);
Eric Andersenda1d1e72000-07-10 23:39:44 +0000517 return 0;
518 }
519 if (mountvers > MAX_NFSPROT) {
Mark Whitleyf57c9442000-12-07 19:56:48 +0000520 error_msg("NFSv%d not supported!\n", nfsvers);
Eric Andersenda1d1e72000-07-10 23:39:44 +0000521 return 0;
522 }
523 if (nfsvers && !mountvers)
524 mountvers = (nfsvers < 3) ? 1 : nfsvers;
525 if (nfsvers && nfsvers < mountvers) {
526 mountvers = nfsvers;
527 }
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000528
529 /* Adjust options if none specified */
530 if (!data.timeo)
531 data.timeo = tcp ? 70 : 7;
532
533#ifdef NFS_MOUNT_DEBUG
534 printf("rsize = %d, wsize = %d, timeo = %d, retrans = %d\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000535 data.rsize, data.wsize, data.timeo, data.retrans);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000536 printf("acreg (min, max) = (%d, %d), acdir (min, max) = (%d, %d)\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000537 data.acregmin, data.acregmax, data.acdirmin, data.acdirmax);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000538 printf("port = %d, bg = %d, retry = %d, flags = %.8x\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000539 port, bg, retry, data.flags);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000540 printf("mountprog = %d, mountvers = %d, nfsprog = %d, nfsvers = %d\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000541 mountprog, mountvers, nfsprog, nfsvers);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000542 printf("soft = %d, intr = %d, posix = %d, nocto = %d, noac = %d\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000543 (data.flags & NFS_MOUNT_SOFT) != 0,
544 (data.flags & NFS_MOUNT_INTR) != 0,
545 (data.flags & NFS_MOUNT_POSIX) != 0,
546 (data.flags & NFS_MOUNT_NOCTO) != 0,
547 (data.flags & NFS_MOUNT_NOAC) != 0);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000548#if NFS_MOUNT_VERSION >= 2
Eric Andersenda1d1e72000-07-10 23:39:44 +0000549 printf("tcp = %d\n",
550 (data.flags & NFS_MOUNT_TCP) != 0);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000551#endif
552#endif
553
554 data.version = nfs_mount_version;
555 *mount_opts = (char *) &data;
556
557 if (*flags & MS_REMOUNT)
558 return 0;
559
560 /*
561 * If the previous mount operation on the same host was
562 * backgrounded, and the "bg" for this mount is also set,
563 * give up immediately, to avoid the initial timeout.
564 */
565 if (bg && !running_bg &&
Eric Andersenda1d1e72000-07-10 23:39:44 +0000566 prev_bg_host && strcmp(hostname, prev_bg_host) == 0) {
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000567 if (retry > 0)
568 retval = EX_BG;
569 return retval;
570 }
571
572 /* create mount deamon client */
573 /* See if the nfs host = mount host. */
574 if (mounthost) {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000575 if (mounthost[0] >= '0' && mounthost[0] <= '9') {
576 mount_server_addr.sin_family = AF_INET;
577 mount_server_addr.sin_addr.s_addr = inet_addr(hostname);
578 } else {
579 if ((hp = gethostbyname(mounthost)) == NULL) {
Mark Whitleyf57c9442000-12-07 19:56:48 +0000580 error_msg("can't get address for %s\n", hostname);
Eric Andersenda1d1e72000-07-10 23:39:44 +0000581 goto fail;
582 } else {
583 if (hp->h_length > sizeof(struct in_addr)) {
Mark Whitleyf57c9442000-12-07 19:56:48 +0000584 error_msg("got bad hp->h_length?\n");
Eric Andersenda1d1e72000-07-10 23:39:44 +0000585 hp->h_length = sizeof(struct in_addr);
586 }
587 mount_server_addr.sin_family = AF_INET;
588 memcpy(&mount_server_addr.sin_addr,
589 hp->h_addr, hp->h_length);
590 }
591 }
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000592 }
593
594 /*
595 * The following loop implements the mount retries. On the first
596 * call, "running_bg" is 0. When the mount times out, and the
597 * "bg" option is set, the exit status EX_BG will be returned.
598 * For a backgrounded mount, there will be a second call by the
599 * child process with "running_bg" set to 1.
600 *
601 * The case where the mount point is not present and the "bg"
602 * option is set, is treated as a timeout. This is done to
603 * support nested mounts.
604 *
605 * The "retry" count specified by the user is the number of
606 * minutes to retry before giving up.
607 *
608 * Only the first error message will be displayed.
609 */
610 retry_timeout.tv_sec = 3;
611 retry_timeout.tv_usec = 0;
612 total_timeout.tv_sec = 20;
613 total_timeout.tv_usec = 0;
614 timeout = time(NULL) + 60 * retry;
615 prevt = 0;
616 t = 30;
617 val = 1;
618 for (;;) {
619 if (bg && stat(node, &statbuf) == -1) {
620 if (running_bg) {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000621 sleep(val); /* 1, 2, 4, 8, 16, 30, ... */
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000622 val *= 2;
623 if (val > 30)
624 val = 30;
625 }
626 } else {
627 /* be careful not to use too many CPU cycles */
628 if (t - prevt < 30)
629 sleep(30);
630
Eric Andersenda1d1e72000-07-10 23:39:44 +0000631 pm_mnt = get_mountport(&mount_server_addr,
632 mountprog,
633 mountvers,
634 proto,
635 mountport);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000636
Eric Andersenda1d1e72000-07-10 23:39:44 +0000637 /* contact the mount daemon via TCP */
638 mount_server_addr.sin_port = htons(pm_mnt->pm_port);
639 msock = RPC_ANYSOCK;
640
641 switch (pm_mnt->pm_prot) {
642 case IPPROTO_UDP:
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000643 mclient = clntudp_create(&mount_server_addr,
Eric Andersenda1d1e72000-07-10 23:39:44 +0000644 pm_mnt->pm_prog,
645 pm_mnt->pm_vers,
646 retry_timeout,
647 &msock);
648 if (mclient)
649 break;
650 mount_server_addr.sin_port = htons(pm_mnt->pm_port);
651 msock = RPC_ANYSOCK;
652 case IPPROTO_TCP:
653 mclient = clnttcp_create(&mount_server_addr,
654 pm_mnt->pm_prog,
655 pm_mnt->pm_vers,
656 &msock, 0, 0);
657 break;
658 default:
659 mclient = 0;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000660 }
661 if (mclient) {
662 /* try to mount hostname:dirname */
663 mclient->cl_auth = authunix_create_default();
Eric Andersenda1d1e72000-07-10 23:39:44 +0000664
665 /* make pointers in xdr_mountres3 NULL so
666 * that xdr_array allocates memory for us
667 */
668 memset(&status, 0, sizeof(status));
669
670 if (pm_mnt->pm_vers == 3)
671 clnt_stat = clnt_call(mclient, MOUNTPROC3_MNT,
672 (xdrproc_t) xdr_dirpath,
673 (caddr_t) &dirname,
674 (xdrproc_t) xdr_mountres3,
675 (caddr_t) &status,
676 total_timeout);
677 else
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000678 clnt_stat = clnt_call(mclient, MOUNTPROC_MNT,
Eric Andersenda1d1e72000-07-10 23:39:44 +0000679 (xdrproc_t) xdr_dirpath,
680 (caddr_t) &dirname,
681 (xdrproc_t) xdr_fhstatus,
682 (caddr_t) &status,
683 total_timeout);
684
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000685 if (clnt_stat == RPC_SUCCESS)
686 break; /* we're done */
687 if (errno != ECONNREFUSED) {
688 clnt_perror(mclient, "mount");
689 goto fail; /* don't retry */
690 }
691 if (!running_bg && prevt == 0)
692 clnt_perror(mclient, "mount");
693 auth_destroy(mclient->cl_auth);
694 clnt_destroy(mclient);
695 mclient = 0;
696 close(msock);
697 } else {
698 if (!running_bg && prevt == 0)
699 clnt_pcreateerror("mount");
700 }
701 prevt = t;
702 }
703 if (!bg)
Eric Andersenda1d1e72000-07-10 23:39:44 +0000704 goto fail;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000705 if (!running_bg) {
706 prev_bg_host = xstrdup(hostname);
707 if (retry > 0)
708 retval = EX_BG;
709 goto fail;
710 }
711 t = time(NULL);
712 if (t >= timeout)
713 goto fail;
714 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000715 nfsvers = (pm_mnt->pm_vers < 2) ? 2 : pm_mnt->pm_vers;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000716
Eric Andersenda1d1e72000-07-10 23:39:44 +0000717 if (nfsvers == 2) {
718 if (status.nfsv2.fhs_status != 0) {
Mark Whitleyf57c9442000-12-07 19:56:48 +0000719 error_msg("%s:%s failed, reason given by server: %s\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000720 hostname, dirname,
721 nfs_strerror(status.nfsv2.fhs_status));
722 goto fail;
723 }
724 memcpy(data.root.data,
725 (char *) status.nfsv2.fhstatus_u.fhs_fhandle,
726 NFS_FHSIZE);
727#if NFS_MOUNT_VERSION >= 4
728 data.root.size = NFS_FHSIZE;
729 memcpy(data.old_root.data,
730 (char *) status.nfsv2.fhstatus_u.fhs_fhandle,
731 NFS_FHSIZE);
732#endif
733 } else {
734#if NFS_MOUNT_VERSION >= 4
735 fhandle3 *fhandle;
736 if (status.nfsv3.fhs_status != 0) {
Mark Whitleyf57c9442000-12-07 19:56:48 +0000737 error_msg("%s:%s failed, reason given by server: %s\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000738 hostname, dirname,
739 nfs_strerror(status.nfsv3.fhs_status));
740 goto fail;
741 }
742 fhandle = &status.nfsv3.mountres3_u.mountinfo.fhandle;
743 memset(data.old_root.data, 0, NFS_FHSIZE);
744 memset(&data.root, 0, sizeof(data.root));
745 data.root.size = fhandle->fhandle3_len;
746 memcpy(data.root.data,
747 (char *) fhandle->fhandle3_val,
748 fhandle->fhandle3_len);
749
750 data.flags |= NFS_MOUNT_VER3;
751#endif
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000752 }
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000753
754 /* create nfs socket for kernel */
755
756 if (tcp) {
757 if (nfs_mount_version < 3) {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000758 printf(_("NFS over TCP is not supported.\n"));
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000759 goto fail;
760 }
761 fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
762 } else
763 fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
764 if (fsock < 0) {
765 perror(_("nfs socket"));
766 goto fail;
767 }
768 if (bindresvport(fsock, 0) < 0) {
769 perror(_("nfs bindresvport"));
770 goto fail;
771 }
772 if (port == 0) {
773 server_addr.sin_port = PMAPPORT;
774 port = pmap_getport(&server_addr, nfsprog, nfsvers,
Eric Andersenda1d1e72000-07-10 23:39:44 +0000775 tcp ? IPPROTO_TCP : IPPROTO_UDP);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000776 if (port == 0)
777 port = NFS_PORT;
778#ifdef NFS_MOUNT_DEBUG
779 else
780 printf(_("used portmapper to find NFS port\n"));
781#endif
782 }
783#ifdef NFS_MOUNT_DEBUG
784 printf(_("using port %d for nfs deamon\n"), port);
785#endif
786 server_addr.sin_port = htons(port);
Eric Andersenda1d1e72000-07-10 23:39:44 +0000787 /*
788 * connect() the socket for kernels 1.3.10 and below only,
789 * to avoid problems with multihomed hosts.
790 * --Swen
791 */
Eric Andersenef936da2000-10-30 17:22:04 +0000792 if (get_kernel_revision() <= 66314
Eric Andersenda1d1e72000-07-10 23:39:44 +0000793 && connect(fsock, (struct sockaddr *) &server_addr,
794 sizeof (server_addr)) < 0) {
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000795 perror(_("nfs connect"));
796 goto fail;
797 }
798
799 /* prepare data structure for kernel */
800
801 data.fd = fsock;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000802 memcpy((char *) &data.addr, (char *) &server_addr, sizeof(data.addr));
803 strncpy(data.hostname, hostname, sizeof(data.hostname));
804
805 /* clean up */
806
807 auth_destroy(mclient->cl_auth);
808 clnt_destroy(mclient);
809 close(msock);
810 return 0;
811
812 /* abort */
813
Eric Andersenda1d1e72000-07-10 23:39:44 +0000814fail:
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000815 if (msock != -1) {
816 if (mclient) {
817 auth_destroy(mclient->cl_auth);
818 clnt_destroy(mclient);
819 }
820 close(msock);
821 }
822 if (fsock != -1)
823 close(fsock);
824 return retval;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000825}
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000826
827/*
828 * We need to translate between nfs status return values and
829 * the local errno values which may not be the same.
830 *
831 * Andreas Schwab <schwab@LS5.informatik.uni-dortmund.de>: change errno:
832 * "after #include <errno.h> the symbol errno is reserved for any use,
833 * it cannot even be used as a struct tag or field name".
834 */
835
836#ifndef EDQUOT
837#define EDQUOT ENOSPC
838#endif
839
840static struct {
841 enum nfs_stat stat;
842 int errnum;
843} nfs_errtbl[] = {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000844 { NFS_OK, 0 },
845 { NFSERR_PERM, EPERM },
846 { NFSERR_NOENT, ENOENT },
847 { NFSERR_IO, EIO },
848 { NFSERR_NXIO, ENXIO },
849 { NFSERR_ACCES, EACCES },
850 { NFSERR_EXIST, EEXIST },
851 { NFSERR_NODEV, ENODEV },
852 { NFSERR_NOTDIR, ENOTDIR },
853 { NFSERR_ISDIR, EISDIR },
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000854#ifdef NFSERR_INVAL
Eric Andersenda1d1e72000-07-10 23:39:44 +0000855 { NFSERR_INVAL, EINVAL }, /* that Sun forgot */
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000856#endif
Eric Andersenda1d1e72000-07-10 23:39:44 +0000857 { NFSERR_FBIG, EFBIG },
858 { NFSERR_NOSPC, ENOSPC },
859 { NFSERR_ROFS, EROFS },
860 { NFSERR_NAMETOOLONG, ENAMETOOLONG },
861 { NFSERR_NOTEMPTY, ENOTEMPTY },
862 { NFSERR_DQUOT, EDQUOT },
863 { NFSERR_STALE, ESTALE },
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000864#ifdef EWFLUSH
Eric Andersenda1d1e72000-07-10 23:39:44 +0000865 { NFSERR_WFLUSH, EWFLUSH },
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000866#endif
Eric Andersenda1d1e72000-07-10 23:39:44 +0000867 /* Throw in some NFSv3 values for even more fun (HP returns these) */
868 { 71, EREMOTE },
869
870 { -1, EIO }
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000871};
872
873static char *nfs_strerror(int stat)
874{
875 int i;
876 static char buf[256];
877
878 for (i = 0; nfs_errtbl[i].stat != -1; i++) {
879 if (nfs_errtbl[i].stat == stat)
880 return strerror(nfs_errtbl[i].errnum);
881 }
882 sprintf(buf, _("unknown nfs status return value: %d"), stat);
883 return buf;
884}
885
Eric Andersenda1d1e72000-07-10 23:39:44 +0000886bool_t
887xdr_fhandle (XDR *xdrs, fhandle objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000888{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000889 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000890
Eric Andersenda1d1e72000-07-10 23:39:44 +0000891 if (!xdr_opaque (xdrs, objp, FHSIZE))
892 return FALSE;
893 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000894}
895
Eric Andersenda1d1e72000-07-10 23:39:44 +0000896bool_t
897xdr_fhstatus (XDR *xdrs, fhstatus *objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000898{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000899 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000900
Eric Andersenda1d1e72000-07-10 23:39:44 +0000901 if (!xdr_u_int (xdrs, &objp->fhs_status))
902 return FALSE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000903 switch (objp->fhs_status) {
904 case 0:
Eric Andersenda1d1e72000-07-10 23:39:44 +0000905 if (!xdr_fhandle (xdrs, objp->fhstatus_u.fhs_fhandle))
906 return FALSE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000907 break;
908 default:
909 break;
910 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000911 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000912}
913
Eric Andersenda1d1e72000-07-10 23:39:44 +0000914bool_t
915xdr_dirpath (XDR *xdrs, dirpath *objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000916{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000917 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000918
Eric Andersenda1d1e72000-07-10 23:39:44 +0000919 if (!xdr_string (xdrs, objp, MNTPATHLEN))
920 return FALSE;
921 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000922}
923
Eric Andersenda1d1e72000-07-10 23:39:44 +0000924bool_t
925xdr_fhandle3 (XDR *xdrs, fhandle3 *objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000926{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000927 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000928
Eric Andersenda1d1e72000-07-10 23:39:44 +0000929 if (!xdr_bytes (xdrs, (char **)&objp->fhandle3_val, (u_int *) &objp->fhandle3_len, FHSIZE3))
930 return FALSE;
931 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000932}
933
Eric Andersenda1d1e72000-07-10 23:39:44 +0000934bool_t
935xdr_mountres3_ok (XDR *xdrs, mountres3_ok *objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000936{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000937 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000938
Eric Andersenda1d1e72000-07-10 23:39:44 +0000939 if (!xdr_fhandle3 (xdrs, &objp->fhandle))
940 return FALSE;
941 if (!xdr_array (xdrs, (char **)&objp->auth_flavours.auth_flavours_val, (u_int *) &objp->auth_flavours.auth_flavours_len, ~0,
942 sizeof (int), (xdrproc_t) xdr_int))
943 return FALSE;
944 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000945}
946
Eric Andersenda1d1e72000-07-10 23:39:44 +0000947bool_t
948xdr_mountstat3 (XDR *xdrs, mountstat3 *objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000949{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000950 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000951
Eric Andersenda1d1e72000-07-10 23:39:44 +0000952 if (!xdr_enum (xdrs, (enum_t *) objp))
953 return FALSE;
954 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000955}
956
Eric Andersenda1d1e72000-07-10 23:39:44 +0000957bool_t
958xdr_mountres3 (XDR *xdrs, mountres3 *objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000959{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000960 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000961
Eric Andersenda1d1e72000-07-10 23:39:44 +0000962 if (!xdr_mountstat3 (xdrs, &objp->fhs_status))
963 return FALSE;
964 switch (objp->fhs_status) {
965 case MNT_OK:
966 if (!xdr_mountres3_ok (xdrs, &objp->mountres3_u.mountinfo))
967 return FALSE;
968 break;
969 default:
970 break;
Erik Andersene49d5ec2000-02-08 19:58:47 +0000971 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000972 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000973}
974