blob: 5c29b5f6b56768aaa2d522b249d60dfc495032cb [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 Andersene7413a92000-07-14 06:19:41 +000036#include "internal.h"
37#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>
50#include <sys/stat.h>
51#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
Eric Andersen1c43d0c1999-11-18 07:58:07 +000057
Eric Andersenda1d1e72000-07-10 23:39:44 +000058/* Disable the nls stuff */
59# undef bindtextdomain
60# define bindtextdomain(Domain, Directory) /* empty */
61# undef textdomain
62# define textdomain(Domain) /* empty */
63# define _(Text) (Text)
64# define N_(Text) (Text)
65
66#define MS_MGC_VAL 0xc0ed0000 /* Magic number indicatng "new" flags */
67#define MS_RDONLY 1 /* Mount read-only */
68#define MS_NOSUID 2 /* Ignore suid and sgid bits */
69#define MS_NODEV 4 /* Disallow access to device special files */
70#define MS_NOEXEC 8 /* Disallow program execution */
71#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
72#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
73#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
74#define S_QUOTA 128 /* Quota initialized for file/directory/symlink */
75#define S_APPEND 256 /* Append-only file */
76#define S_IMMUTABLE 512 /* Immutable file */
77#define MS_NOATIME 1024 /* Do not update access times. */
78#define MS_NODIRATIME 2048 /* Do not update directory access times */
79
80
81/*
82 * We want to be able to compile mount on old kernels in such a way
83 * that the binary will work well on more recent kernels.
84 * Thus, if necessary we teach nfsmount.c the structure of new fields
85 * that will come later.
86 *
87 * Moreover, the new kernel includes conflict with glibc includes
88 * so it is easiest to ignore the kernel altogether (at compile time).
89 */
90
91#define NFS_MOUNT_VERSION 4
92
93struct nfs2_fh {
94 char data[32];
95};
96struct nfs3_fh {
97 unsigned short size;
98 unsigned char data[64];
99};
100
101struct nfs_mount_data {
102 int version; /* 1 */
103 int fd; /* 1 */
104 struct nfs2_fh old_root; /* 1 */
105 int flags; /* 1 */
106 int rsize; /* 1 */
107 int wsize; /* 1 */
108 int timeo; /* 1 */
109 int retrans; /* 1 */
110 int acregmin; /* 1 */
111 int acregmax; /* 1 */
112 int acdirmin; /* 1 */
113 int acdirmax; /* 1 */
114 struct sockaddr_in addr; /* 1 */
115 char hostname[256]; /* 1 */
116 int namlen; /* 2 */
117 unsigned int bsize; /* 3 */
118 struct nfs3_fh root; /* 4 */
119};
120
121/* bits in the flags field */
122
123#define NFS_MOUNT_SOFT 0x0001 /* 1 */
124#define NFS_MOUNT_INTR 0x0002 /* 1 */
125#define NFS_MOUNT_SECURE 0x0004 /* 1 */
126#define NFS_MOUNT_POSIX 0x0008 /* 1 */
127#define NFS_MOUNT_NOCTO 0x0010 /* 1 */
128#define NFS_MOUNT_NOAC 0x0020 /* 1 */
129#define NFS_MOUNT_TCP 0x0040 /* 2 */
130#define NFS_MOUNT_VER3 0x0080 /* 3 */
131#define NFS_MOUNT_KERBEROS 0x0100 /* 3 */
132#define NFS_MOUNT_NONLM 0x0200 /* 3 */
133
134
135#define UTIL_LINUX_VERSION "2.10m"
136#define util_linux_version "util-linux-2.10m"
137
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000138#define HAVE_inet_aton
Eric Andersenda1d1e72000-07-10 23:39:44 +0000139#define HAVE_scsi_h
140#define HAVE_blkpg_h
141#define HAVE_kd_h
142#define HAVE_termcap
143#define HAVE_locale_h
144#define HAVE_libintl_h
145#define ENABLE_NLS
146#define HAVE_langinfo_h
147#define HAVE_progname
148#define HAVE_openpty
149#define HAVE_nanosleep
150#define HAVE_personality
151#define HAVE_tm_gmtoff
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000152
Eric Andersenda1d1e72000-07-10 23:39:44 +0000153extern char *xstrdup (const char *s);
154extern char *xstrndup (const char *s, int n);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000155static char *nfs_strerror(int stat);
156
157#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
Eric Andersenda1d1e72000-07-10 23:39:44 +0000158#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000159
Eric Andersenda1d1e72000-07-10 23:39:44 +0000160#define EX_FAIL 32 /* mount failure */
161#define EX_BG 256 /* retry in background (internal only) */
162
163
164static int
165linux_version_code(void) {
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000166 struct utsname my_utsname;
167 int p, q, r;
168
169 if (uname(&my_utsname) == 0) {
170 p = atoi(strtok(my_utsname.release, "."));
171 q = atoi(strtok(NULL, "."));
172 r = atoi(strtok(NULL, "."));
Eric Andersenda1d1e72000-07-10 23:39:44 +0000173 return MAKE_VERSION(p,q,r);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000174 }
175 return 0;
176}
177
178/*
Eric Andersenda1d1e72000-07-10 23:39:44 +0000179 * nfs_mount_version according to the sources seen at compile time.
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000180 */
Eric Andersenda1d1e72000-07-10 23:39:44 +0000181int nfs_mount_version = NFS_MOUNT_VERSION;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000182
183/*
184 * Unfortunately, the kernel prints annoying console messages
185 * in case of an unexpected nfs mount version (instead of
186 * just returning some error). Therefore we'll have to try
187 * and figure out what version the kernel expects.
188 *
189 * Variables:
190 * KERNEL_NFS_MOUNT_VERSION: kernel sources at compile time
191 * NFS_MOUNT_VERSION: these nfsmount sources at compile time
192 * nfs_mount_version: version this source and running kernel can handle
193 */
Eric Andersenda1d1e72000-07-10 23:39:44 +0000194static void
195find_kernel_nfs_mount_version(void) {
196 static int kernel_version = 0;
197
198 if (kernel_version)
199 return;
200
201 kernel_version = linux_version_code();
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000202
203 if (kernel_version) {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000204 if (kernel_version < MAKE_VERSION(2,1,32))
205 nfs_mount_version = 1;
206 else if (kernel_version < MAKE_VERSION(2,3,99))
207 nfs_mount_version = 3;
208 else
209 nfs_mount_version = 4; /* since 2.3.99pre4 */
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000210 }
211 if (nfs_mount_version > NFS_MOUNT_VERSION)
Eric Andersenda1d1e72000-07-10 23:39:44 +0000212 nfs_mount_version = NFS_MOUNT_VERSION;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000213}
214
Eric Andersenda1d1e72000-07-10 23:39:44 +0000215static struct pmap *
216get_mountport(struct sockaddr_in *server_addr,
217 long unsigned prog,
218 long unsigned version,
219 long unsigned proto,
220 long unsigned port)
221{
222struct pmaplist *pmap;
223static struct pmap p = {0, 0, 0, 0};
224
225server_addr->sin_port = PMAPPORT;
226pmap = pmap_getmaps(server_addr);
227
228if (version > MAX_NFSPROT)
229 version = MAX_NFSPROT;
230if (!prog)
231 prog = MOUNTPROG;
232p.pm_prog = prog;
233p.pm_vers = version;
234p.pm_prot = proto;
235p.pm_port = port;
236
237while (pmap) {
238 if (pmap->pml_map.pm_prog != prog)
239 goto next;
240 if (!version && p.pm_vers > pmap->pml_map.pm_vers)
241 goto next;
242 if (version > 2 && pmap->pml_map.pm_vers != version)
243 goto next;
244 if (version && version <= 2 && pmap->pml_map.pm_vers > 2)
245 goto next;
246 if (pmap->pml_map.pm_vers > MAX_NFSPROT ||
247 (proto && p.pm_prot && pmap->pml_map.pm_prot != proto) ||
248 (port && pmap->pml_map.pm_port != port))
249 goto next;
250 memcpy(&p, &pmap->pml_map, sizeof(p));
251next:
252 pmap = pmap->pml_next;
253}
254if (!p.pm_vers)
255 p.pm_vers = MOUNTVERS;
256if (!p.pm_port)
257 p.pm_port = MOUNTPORT;
258if (!p.pm_prot)
259 p.pm_prot = IPPROTO_TCP;
260return &p;
261}
262
263int nfsmount(const char *spec, const char *node, int *flags,
264 char **extra_opts, char **mount_opts, int running_bg)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000265{
266 static char *prev_bg_host;
267 char hostdir[1024];
268 CLIENT *mclient;
269 char *hostname;
270 char *dirname;
271 char *old_opts;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000272 char *mounthost=NULL;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000273 char new_opts[1024];
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000274 struct timeval total_timeout;
275 enum clnt_stat clnt_stat;
276 static struct nfs_mount_data data;
277 char *opt, *opteq;
278 int val;
279 struct hostent *hp;
280 struct sockaddr_in server_addr;
281 struct sockaddr_in mount_server_addr;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000282 struct pmap* pm_mnt;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000283 int msock, fsock;
284 struct timeval retry_timeout;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000285 union {
286 struct fhstatus nfsv2;
287 struct mountres3 nfsv3;
288 } status;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000289 struct stat statbuf;
290 char *s;
291 int port;
292 int mountport;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000293 int proto;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000294 int bg;
295 int soft;
296 int intr;
297 int posix;
298 int nocto;
299 int noac;
300 int nolock;
301 int retry;
302 int tcp;
303 int mountprog;
304 int mountvers;
305 int nfsprog;
306 int nfsvers;
307 int retval;
308 time_t t;
309 time_t prevt;
310 time_t timeout;
311
312 find_kernel_nfs_mount_version();
313
314 retval = EX_FAIL;
315 msock = fsock = -1;
316 mclient = NULL;
317 if (strlen(spec) >= sizeof(hostdir)) {
Matt Kraaid537a952000-07-14 01:51:25 +0000318 errorMsg("excessively long host:dir argument\n");
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000319 goto fail;
320 }
321 strcpy(hostdir, spec);
322 if ((s = strchr(hostdir, ':'))) {
323 hostname = hostdir;
324 dirname = s + 1;
325 *s = '\0';
326 /* Ignore all but first hostname in replicated mounts
327 until they can be fully supported. (mack@sgi.com) */
328 if ((s = strchr(hostdir, ','))) {
329 *s = '\0';
Matt Kraaid537a952000-07-14 01:51:25 +0000330 errorMsg("warning: multiple hostnames not supported\n");
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000331 }
332 } else {
Matt Kraaid537a952000-07-14 01:51:25 +0000333 errorMsg("directory to mount not in host:dir format\n");
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000334 goto fail;
335 }
336
337 server_addr.sin_family = AF_INET;
338#ifdef HAVE_inet_aton
339 if (!inet_aton(hostname, &server_addr.sin_addr))
340#endif
341 {
342 if ((hp = gethostbyname(hostname)) == NULL) {
Matt Kraaid537a952000-07-14 01:51:25 +0000343 errorMsg("can't get address for %s\n", hostname);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000344 goto fail;
345 } else {
346 if (hp->h_length > sizeof(struct in_addr)) {
Matt Kraaid537a952000-07-14 01:51:25 +0000347 errorMsg("got bad hp->h_length\n");
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000348 hp->h_length = sizeof(struct in_addr);
349 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000350 memcpy(&server_addr.sin_addr,
351 hp->h_addr, hp->h_length);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000352 }
353 }
354
Eric Andersenda1d1e72000-07-10 23:39:44 +0000355 memcpy (&mount_server_addr, &server_addr, sizeof (mount_server_addr));
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000356
357 /* add IP address to mtab options for use when unmounting */
358
359 s = inet_ntoa(server_addr.sin_addr);
360 old_opts = *extra_opts;
361 if (!old_opts)
362 old_opts = "";
363 if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) {
Matt Kraaid537a952000-07-14 01:51:25 +0000364 errorMsg("excessively long option argument\n");
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000365 goto fail;
366 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000367 sprintf(new_opts, "%s%saddr=%s",
368 old_opts, *old_opts ? "," : "", s);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000369 *extra_opts = xstrdup(new_opts);
370
371 /* Set default options.
372 * rsize/wsize (and bsize, for ver >= 3) are left 0 in order to
373 * let the kernel decide.
374 * timeo is filled in after we know whether it'll be TCP or UDP. */
375 memset(&data, 0, sizeof(data));
Eric Andersenda1d1e72000-07-10 23:39:44 +0000376 data.retrans = 3;
377 data.acregmin = 3;
378 data.acregmax = 60;
379 data.acdirmin = 30;
380 data.acdirmax = 60;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000381#if NFS_MOUNT_VERSION >= 2
Eric Andersenda1d1e72000-07-10 23:39:44 +0000382 data.namlen = NAME_MAX;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000383#endif
384
385 bg = 0;
386 soft = 0;
387 intr = 0;
388 posix = 0;
389 nocto = 0;
390 nolock = 0;
391 noac = 0;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000392 retry = 10000; /* 10000 minutes ~ 1 week */
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000393 tcp = 0;
394
395 mountprog = MOUNTPROG;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000396 mountvers = 0;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000397 port = 0;
398 mountport = 0;
399 nfsprog = NFS_PROGRAM;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000400 nfsvers = 0;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000401
402 /* parse options */
403
404 for (opt = strtok(old_opts, ","); opt; opt = strtok(NULL, ",")) {
405 if ((opteq = strchr(opt, '='))) {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000406 val = atoi(opteq + 1);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000407 *opteq = '\0';
408 if (!strcmp(opt, "rsize"))
409 data.rsize = val;
410 else if (!strcmp(opt, "wsize"))
411 data.wsize = val;
412 else if (!strcmp(opt, "timeo"))
413 data.timeo = val;
414 else if (!strcmp(opt, "retrans"))
415 data.retrans = val;
416 else if (!strcmp(opt, "acregmin"))
417 data.acregmin = val;
418 else if (!strcmp(opt, "acregmax"))
419 data.acregmax = val;
420 else if (!strcmp(opt, "acdirmin"))
421 data.acdirmin = val;
422 else if (!strcmp(opt, "acdirmax"))
423 data.acdirmax = val;
424 else if (!strcmp(opt, "actimeo")) {
425 data.acregmin = val;
426 data.acregmax = val;
427 data.acdirmin = val;
428 data.acdirmax = val;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000429 }
430 else if (!strcmp(opt, "retry"))
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000431 retry = val;
432 else if (!strcmp(opt, "port"))
433 port = val;
434 else if (!strcmp(opt, "mountport"))
Eric Andersenda1d1e72000-07-10 23:39:44 +0000435 mountport = val;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000436 else if (!strcmp(opt, "mounthost"))
Eric Andersenda1d1e72000-07-10 23:39:44 +0000437 mounthost=xstrndup(opteq+1,
438 strcspn(opteq+1," \t\n\r,"));
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000439 else if (!strcmp(opt, "mountprog"))
440 mountprog = val;
441 else if (!strcmp(opt, "mountvers"))
442 mountvers = val;
443 else if (!strcmp(opt, "nfsprog"))
444 nfsprog = val;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000445 else if (!strcmp(opt, "nfsvers") ||
446 !strcmp(opt, "vers"))
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000447 nfsvers = val;
448 else if (!strcmp(opt, "proto")) {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000449 if (!strncmp(opteq+1, "tcp", 3))
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000450 tcp = 1;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000451 else if (!strncmp(opteq+1, "udp", 3))
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000452 tcp = 0;
453 else
454 printf(_("Warning: Unrecognized proto= option.\n"));
455 } else if (!strcmp(opt, "namlen")) {
456#if NFS_MOUNT_VERSION >= 2
457 if (nfs_mount_version >= 2)
458 data.namlen = val;
459 else
460#endif
Eric Andersenda1d1e72000-07-10 23:39:44 +0000461 printf(_("Warning: Option namlen is not supported.\n"));
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000462 } else if (!strcmp(opt, "addr"))
Eric Andersenda1d1e72000-07-10 23:39:44 +0000463 /* ignore */;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000464 else {
465 printf(_("unknown nfs mount parameter: "
Eric Andersenda1d1e72000-07-10 23:39:44 +0000466 "%s=%d\n"), opt, val);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000467 goto fail;
468 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000469 }
470 else {
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000471 val = 1;
472 if (!strncmp(opt, "no", 2)) {
473 val = 0;
474 opt += 2;
475 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000476 if (!strcmp(opt, "bg"))
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000477 bg = val;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000478 else if (!strcmp(opt, "fg"))
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000479 bg = !val;
480 else if (!strcmp(opt, "soft"))
481 soft = val;
482 else if (!strcmp(opt, "hard"))
483 soft = !val;
484 else if (!strcmp(opt, "intr"))
485 intr = val;
486 else if (!strcmp(opt, "posix"))
487 posix = val;
488 else if (!strcmp(opt, "cto"))
489 nocto = !val;
490 else if (!strcmp(opt, "ac"))
491 noac = !val;
492 else if (!strcmp(opt, "tcp"))
493 tcp = val;
494 else if (!strcmp(opt, "udp"))
495 tcp = !val;
496 else if (!strcmp(opt, "lock")) {
497 if (nfs_mount_version >= 3)
498 nolock = !val;
499 else
Eric Andersenda1d1e72000-07-10 23:39:44 +0000500 printf(_("Warning: option nolock is not supported.\n"));
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000501 } else {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000502 printf(_("unknown nfs mount option: "
503 "%s%s\n"), val ? "" : "no", opt);
504 goto fail;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000505 }
506 }
507 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000508 proto = (tcp) ? IPPROTO_TCP : IPPROTO_UDP;
509
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000510 data.flags = (soft ? NFS_MOUNT_SOFT : 0)
511 | (intr ? NFS_MOUNT_INTR : 0)
512 | (posix ? NFS_MOUNT_POSIX : 0)
513 | (nocto ? NFS_MOUNT_NOCTO : 0)
514 | (noac ? NFS_MOUNT_NOAC : 0);
515#if NFS_MOUNT_VERSION >= 2
516 if (nfs_mount_version >= 2)
517 data.flags |= (tcp ? NFS_MOUNT_TCP : 0);
518#endif
519#if NFS_MOUNT_VERSION >= 3
520 if (nfs_mount_version >= 3)
521 data.flags |= (nolock ? NFS_MOUNT_NONLM : 0);
522#endif
Eric Andersenda1d1e72000-07-10 23:39:44 +0000523 if (nfsvers > MAX_NFSPROT) {
Matt Kraaid537a952000-07-14 01:51:25 +0000524 errorMsg("NFSv%d not supported!\n", nfsvers);
Eric Andersenda1d1e72000-07-10 23:39:44 +0000525 return 0;
526 }
527 if (mountvers > MAX_NFSPROT) {
Matt Kraaid537a952000-07-14 01:51:25 +0000528 errorMsg("NFSv%d not supported!\n", nfsvers);
Eric Andersenda1d1e72000-07-10 23:39:44 +0000529 return 0;
530 }
531 if (nfsvers && !mountvers)
532 mountvers = (nfsvers < 3) ? 1 : nfsvers;
533 if (nfsvers && nfsvers < mountvers) {
534 mountvers = nfsvers;
535 }
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000536
537 /* Adjust options if none specified */
538 if (!data.timeo)
539 data.timeo = tcp ? 70 : 7;
540
541#ifdef NFS_MOUNT_DEBUG
542 printf("rsize = %d, wsize = %d, timeo = %d, retrans = %d\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000543 data.rsize, data.wsize, data.timeo, data.retrans);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000544 printf("acreg (min, max) = (%d, %d), acdir (min, max) = (%d, %d)\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000545 data.acregmin, data.acregmax, data.acdirmin, data.acdirmax);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000546 printf("port = %d, bg = %d, retry = %d, flags = %.8x\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000547 port, bg, retry, data.flags);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000548 printf("mountprog = %d, mountvers = %d, nfsprog = %d, nfsvers = %d\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000549 mountprog, mountvers, nfsprog, nfsvers);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000550 printf("soft = %d, intr = %d, posix = %d, nocto = %d, noac = %d\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000551 (data.flags & NFS_MOUNT_SOFT) != 0,
552 (data.flags & NFS_MOUNT_INTR) != 0,
553 (data.flags & NFS_MOUNT_POSIX) != 0,
554 (data.flags & NFS_MOUNT_NOCTO) != 0,
555 (data.flags & NFS_MOUNT_NOAC) != 0);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000556#if NFS_MOUNT_VERSION >= 2
Eric Andersenda1d1e72000-07-10 23:39:44 +0000557 printf("tcp = %d\n",
558 (data.flags & NFS_MOUNT_TCP) != 0);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000559#endif
560#endif
561
562 data.version = nfs_mount_version;
563 *mount_opts = (char *) &data;
564
565 if (*flags & MS_REMOUNT)
566 return 0;
567
568 /*
569 * If the previous mount operation on the same host was
570 * backgrounded, and the "bg" for this mount is also set,
571 * give up immediately, to avoid the initial timeout.
572 */
573 if (bg && !running_bg &&
Eric Andersenda1d1e72000-07-10 23:39:44 +0000574 prev_bg_host && strcmp(hostname, prev_bg_host) == 0) {
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000575 if (retry > 0)
576 retval = EX_BG;
577 return retval;
578 }
579
580 /* create mount deamon client */
581 /* See if the nfs host = mount host. */
582 if (mounthost) {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000583 if (mounthost[0] >= '0' && mounthost[0] <= '9') {
584 mount_server_addr.sin_family = AF_INET;
585 mount_server_addr.sin_addr.s_addr = inet_addr(hostname);
586 } else {
587 if ((hp = gethostbyname(mounthost)) == NULL) {
Matt Kraaid537a952000-07-14 01:51:25 +0000588 errorMsg("can't get address for %s\n", hostname);
Eric Andersenda1d1e72000-07-10 23:39:44 +0000589 goto fail;
590 } else {
591 if (hp->h_length > sizeof(struct in_addr)) {
Matt Kraaid537a952000-07-14 01:51:25 +0000592 errorMsg("got bad hp->h_length?\n");
Eric Andersenda1d1e72000-07-10 23:39:44 +0000593 hp->h_length = sizeof(struct in_addr);
594 }
595 mount_server_addr.sin_family = AF_INET;
596 memcpy(&mount_server_addr.sin_addr,
597 hp->h_addr, hp->h_length);
598 }
599 }
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000600 }
601
602 /*
603 * The following loop implements the mount retries. On the first
604 * call, "running_bg" is 0. When the mount times out, and the
605 * "bg" option is set, the exit status EX_BG will be returned.
606 * For a backgrounded mount, there will be a second call by the
607 * child process with "running_bg" set to 1.
608 *
609 * The case where the mount point is not present and the "bg"
610 * option is set, is treated as a timeout. This is done to
611 * support nested mounts.
612 *
613 * The "retry" count specified by the user is the number of
614 * minutes to retry before giving up.
615 *
616 * Only the first error message will be displayed.
617 */
618 retry_timeout.tv_sec = 3;
619 retry_timeout.tv_usec = 0;
620 total_timeout.tv_sec = 20;
621 total_timeout.tv_usec = 0;
622 timeout = time(NULL) + 60 * retry;
623 prevt = 0;
624 t = 30;
625 val = 1;
626 for (;;) {
627 if (bg && stat(node, &statbuf) == -1) {
628 if (running_bg) {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000629 sleep(val); /* 1, 2, 4, 8, 16, 30, ... */
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000630 val *= 2;
631 if (val > 30)
632 val = 30;
633 }
634 } else {
635 /* be careful not to use too many CPU cycles */
636 if (t - prevt < 30)
637 sleep(30);
638
Eric Andersenda1d1e72000-07-10 23:39:44 +0000639 pm_mnt = get_mountport(&mount_server_addr,
640 mountprog,
641 mountvers,
642 proto,
643 mountport);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000644
Eric Andersenda1d1e72000-07-10 23:39:44 +0000645 /* contact the mount daemon via TCP */
646 mount_server_addr.sin_port = htons(pm_mnt->pm_port);
647 msock = RPC_ANYSOCK;
648
649 switch (pm_mnt->pm_prot) {
650 case IPPROTO_UDP:
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000651 mclient = clntudp_create(&mount_server_addr,
Eric Andersenda1d1e72000-07-10 23:39:44 +0000652 pm_mnt->pm_prog,
653 pm_mnt->pm_vers,
654 retry_timeout,
655 &msock);
656 if (mclient)
657 break;
658 mount_server_addr.sin_port = htons(pm_mnt->pm_port);
659 msock = RPC_ANYSOCK;
660 case IPPROTO_TCP:
661 mclient = clnttcp_create(&mount_server_addr,
662 pm_mnt->pm_prog,
663 pm_mnt->pm_vers,
664 &msock, 0, 0);
665 break;
666 default:
667 mclient = 0;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000668 }
669 if (mclient) {
670 /* try to mount hostname:dirname */
671 mclient->cl_auth = authunix_create_default();
Eric Andersenda1d1e72000-07-10 23:39:44 +0000672
673 /* make pointers in xdr_mountres3 NULL so
674 * that xdr_array allocates memory for us
675 */
676 memset(&status, 0, sizeof(status));
677
678 if (pm_mnt->pm_vers == 3)
679 clnt_stat = clnt_call(mclient, MOUNTPROC3_MNT,
680 (xdrproc_t) xdr_dirpath,
681 (caddr_t) &dirname,
682 (xdrproc_t) xdr_mountres3,
683 (caddr_t) &status,
684 total_timeout);
685 else
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000686 clnt_stat = clnt_call(mclient, MOUNTPROC_MNT,
Eric Andersenda1d1e72000-07-10 23:39:44 +0000687 (xdrproc_t) xdr_dirpath,
688 (caddr_t) &dirname,
689 (xdrproc_t) xdr_fhstatus,
690 (caddr_t) &status,
691 total_timeout);
692
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000693 if (clnt_stat == RPC_SUCCESS)
694 break; /* we're done */
695 if (errno != ECONNREFUSED) {
696 clnt_perror(mclient, "mount");
697 goto fail; /* don't retry */
698 }
699 if (!running_bg && prevt == 0)
700 clnt_perror(mclient, "mount");
701 auth_destroy(mclient->cl_auth);
702 clnt_destroy(mclient);
703 mclient = 0;
704 close(msock);
705 } else {
706 if (!running_bg && prevt == 0)
707 clnt_pcreateerror("mount");
708 }
709 prevt = t;
710 }
711 if (!bg)
Eric Andersenda1d1e72000-07-10 23:39:44 +0000712 goto fail;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000713 if (!running_bg) {
714 prev_bg_host = xstrdup(hostname);
715 if (retry > 0)
716 retval = EX_BG;
717 goto fail;
718 }
719 t = time(NULL);
720 if (t >= timeout)
721 goto fail;
722 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000723 nfsvers = (pm_mnt->pm_vers < 2) ? 2 : pm_mnt->pm_vers;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000724
Eric Andersenda1d1e72000-07-10 23:39:44 +0000725 if (nfsvers == 2) {
726 if (status.nfsv2.fhs_status != 0) {
Matt Kraaid537a952000-07-14 01:51:25 +0000727 errorMsg("%s:%s failed, reason given by server: %s\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000728 hostname, dirname,
729 nfs_strerror(status.nfsv2.fhs_status));
730 goto fail;
731 }
732 memcpy(data.root.data,
733 (char *) status.nfsv2.fhstatus_u.fhs_fhandle,
734 NFS_FHSIZE);
735#if NFS_MOUNT_VERSION >= 4
736 data.root.size = NFS_FHSIZE;
737 memcpy(data.old_root.data,
738 (char *) status.nfsv2.fhstatus_u.fhs_fhandle,
739 NFS_FHSIZE);
740#endif
741 } else {
742#if NFS_MOUNT_VERSION >= 4
743 fhandle3 *fhandle;
744 if (status.nfsv3.fhs_status != 0) {
Matt Kraaid537a952000-07-14 01:51:25 +0000745 errorMsg("%s:%s failed, reason given by server: %s\n",
Eric Andersenda1d1e72000-07-10 23:39:44 +0000746 hostname, dirname,
747 nfs_strerror(status.nfsv3.fhs_status));
748 goto fail;
749 }
750 fhandle = &status.nfsv3.mountres3_u.mountinfo.fhandle;
751 memset(data.old_root.data, 0, NFS_FHSIZE);
752 memset(&data.root, 0, sizeof(data.root));
753 data.root.size = fhandle->fhandle3_len;
754 memcpy(data.root.data,
755 (char *) fhandle->fhandle3_val,
756 fhandle->fhandle3_len);
757
758 data.flags |= NFS_MOUNT_VER3;
759#endif
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000760 }
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000761
762 /* create nfs socket for kernel */
763
764 if (tcp) {
765 if (nfs_mount_version < 3) {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000766 printf(_("NFS over TCP is not supported.\n"));
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000767 goto fail;
768 }
769 fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
770 } else
771 fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
772 if (fsock < 0) {
773 perror(_("nfs socket"));
774 goto fail;
775 }
776 if (bindresvport(fsock, 0) < 0) {
777 perror(_("nfs bindresvport"));
778 goto fail;
779 }
780 if (port == 0) {
781 server_addr.sin_port = PMAPPORT;
782 port = pmap_getport(&server_addr, nfsprog, nfsvers,
Eric Andersenda1d1e72000-07-10 23:39:44 +0000783 tcp ? IPPROTO_TCP : IPPROTO_UDP);
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000784 if (port == 0)
785 port = NFS_PORT;
786#ifdef NFS_MOUNT_DEBUG
787 else
788 printf(_("used portmapper to find NFS port\n"));
789#endif
790 }
791#ifdef NFS_MOUNT_DEBUG
792 printf(_("using port %d for nfs deamon\n"), port);
793#endif
794 server_addr.sin_port = htons(port);
Eric Andersenda1d1e72000-07-10 23:39:44 +0000795 /*
796 * connect() the socket for kernels 1.3.10 and below only,
797 * to avoid problems with multihomed hosts.
798 * --Swen
799 */
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000800 if (linux_version_code() <= 66314
Eric Andersenda1d1e72000-07-10 23:39:44 +0000801 && connect(fsock, (struct sockaddr *) &server_addr,
802 sizeof (server_addr)) < 0) {
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000803 perror(_("nfs connect"));
804 goto fail;
805 }
806
807 /* prepare data structure for kernel */
808
809 data.fd = fsock;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000810 memcpy((char *) &data.addr, (char *) &server_addr, sizeof(data.addr));
811 strncpy(data.hostname, hostname, sizeof(data.hostname));
812
813 /* clean up */
814
815 auth_destroy(mclient->cl_auth);
816 clnt_destroy(mclient);
817 close(msock);
818 return 0;
819
820 /* abort */
821
Eric Andersenda1d1e72000-07-10 23:39:44 +0000822fail:
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000823 if (msock != -1) {
824 if (mclient) {
825 auth_destroy(mclient->cl_auth);
826 clnt_destroy(mclient);
827 }
828 close(msock);
829 }
830 if (fsock != -1)
831 close(fsock);
832 return retval;
Eric Andersenda1d1e72000-07-10 23:39:44 +0000833}
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000834
835/*
836 * We need to translate between nfs status return values and
837 * the local errno values which may not be the same.
838 *
839 * Andreas Schwab <schwab@LS5.informatik.uni-dortmund.de>: change errno:
840 * "after #include <errno.h> the symbol errno is reserved for any use,
841 * it cannot even be used as a struct tag or field name".
842 */
843
844#ifndef EDQUOT
845#define EDQUOT ENOSPC
846#endif
847
848static struct {
849 enum nfs_stat stat;
850 int errnum;
851} nfs_errtbl[] = {
Eric Andersenda1d1e72000-07-10 23:39:44 +0000852 { NFS_OK, 0 },
853 { NFSERR_PERM, EPERM },
854 { NFSERR_NOENT, ENOENT },
855 { NFSERR_IO, EIO },
856 { NFSERR_NXIO, ENXIO },
857 { NFSERR_ACCES, EACCES },
858 { NFSERR_EXIST, EEXIST },
859 { NFSERR_NODEV, ENODEV },
860 { NFSERR_NOTDIR, ENOTDIR },
861 { NFSERR_ISDIR, EISDIR },
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000862#ifdef NFSERR_INVAL
Eric Andersenda1d1e72000-07-10 23:39:44 +0000863 { NFSERR_INVAL, EINVAL }, /* that Sun forgot */
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000864#endif
Eric Andersenda1d1e72000-07-10 23:39:44 +0000865 { NFSERR_FBIG, EFBIG },
866 { NFSERR_NOSPC, ENOSPC },
867 { NFSERR_ROFS, EROFS },
868 { NFSERR_NAMETOOLONG, ENAMETOOLONG },
869 { NFSERR_NOTEMPTY, ENOTEMPTY },
870 { NFSERR_DQUOT, EDQUOT },
871 { NFSERR_STALE, ESTALE },
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000872#ifdef EWFLUSH
Eric Andersenda1d1e72000-07-10 23:39:44 +0000873 { NFSERR_WFLUSH, EWFLUSH },
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000874#endif
Eric Andersenda1d1e72000-07-10 23:39:44 +0000875 /* Throw in some NFSv3 values for even more fun (HP returns these) */
876 { 71, EREMOTE },
877
878 { -1, EIO }
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000879};
880
881static char *nfs_strerror(int stat)
882{
883 int i;
884 static char buf[256];
885
886 for (i = 0; nfs_errtbl[i].stat != -1; i++) {
887 if (nfs_errtbl[i].stat == stat)
888 return strerror(nfs_errtbl[i].errnum);
889 }
890 sprintf(buf, _("unknown nfs status return value: %d"), stat);
891 return buf;
892}
893
Eric Andersenda1d1e72000-07-10 23:39:44 +0000894bool_t
895xdr_fhandle (XDR *xdrs, fhandle objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000896{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000897 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000898
Eric Andersenda1d1e72000-07-10 23:39:44 +0000899 if (!xdr_opaque (xdrs, objp, FHSIZE))
900 return FALSE;
901 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000902}
903
Eric Andersenda1d1e72000-07-10 23:39:44 +0000904bool_t
905xdr_fhstatus (XDR *xdrs, fhstatus *objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000906{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000907 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000908
Eric Andersenda1d1e72000-07-10 23:39:44 +0000909 if (!xdr_u_int (xdrs, &objp->fhs_status))
910 return FALSE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000911 switch (objp->fhs_status) {
912 case 0:
Eric Andersenda1d1e72000-07-10 23:39:44 +0000913 if (!xdr_fhandle (xdrs, objp->fhstatus_u.fhs_fhandle))
914 return FALSE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000915 break;
916 default:
917 break;
918 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000919 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000920}
921
Eric Andersenda1d1e72000-07-10 23:39:44 +0000922bool_t
923xdr_dirpath (XDR *xdrs, dirpath *objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000924{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000925 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000926
Eric Andersenda1d1e72000-07-10 23:39:44 +0000927 if (!xdr_string (xdrs, objp, MNTPATHLEN))
928 return FALSE;
929 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000930}
931
Eric Andersenda1d1e72000-07-10 23:39:44 +0000932bool_t
933xdr_fhandle3 (XDR *xdrs, fhandle3 *objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000934{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000935 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000936
Eric Andersenda1d1e72000-07-10 23:39:44 +0000937 if (!xdr_bytes (xdrs, (char **)&objp->fhandle3_val, (u_int *) &objp->fhandle3_len, FHSIZE3))
938 return FALSE;
939 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000940}
941
Eric Andersenda1d1e72000-07-10 23:39:44 +0000942bool_t
943xdr_mountres3_ok (XDR *xdrs, mountres3_ok *objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000944{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000945 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000946
Eric Andersenda1d1e72000-07-10 23:39:44 +0000947 if (!xdr_fhandle3 (xdrs, &objp->fhandle))
948 return FALSE;
949 if (!xdr_array (xdrs, (char **)&objp->auth_flavours.auth_flavours_val, (u_int *) &objp->auth_flavours.auth_flavours_len, ~0,
950 sizeof (int), (xdrproc_t) xdr_int))
951 return FALSE;
952 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000953}
954
Eric Andersenda1d1e72000-07-10 23:39:44 +0000955bool_t
956xdr_mountstat3 (XDR *xdrs, mountstat3 *objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000957{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000958 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000959
Eric Andersenda1d1e72000-07-10 23:39:44 +0000960 if (!xdr_enum (xdrs, (enum_t *) objp))
961 return FALSE;
962 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000963}
964
Eric Andersenda1d1e72000-07-10 23:39:44 +0000965bool_t
966xdr_mountres3 (XDR *xdrs, mountres3 *objp)
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000967{
Eric Andersenda1d1e72000-07-10 23:39:44 +0000968 //register int32_t *buf;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000969
Eric Andersenda1d1e72000-07-10 23:39:44 +0000970 if (!xdr_mountstat3 (xdrs, &objp->fhs_status))
971 return FALSE;
972 switch (objp->fhs_status) {
973 case MNT_OK:
974 if (!xdr_mountres3_ok (xdrs, &objp->mountres3_u.mountinfo))
975 return FALSE;
976 break;
977 default:
978 break;
Erik Andersene49d5ec2000-02-08 19:58:47 +0000979 }
Eric Andersenda1d1e72000-07-10 23:39:44 +0000980 return TRUE;
Eric Andersen1c43d0c1999-11-18 07:58:07 +0000981}
982