Deleted Added
full compact
fixmount.c (131706) fixmount.c (174313)
1/*
1/*
2 * Copyright (c) 1997-2004 Erez Zadok
2 * Copyright (c) 1997-2006 Erez Zadok
3 * Copyright (c) 1990 Jan-Simon Pendry
4 * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
5 * Copyright (c) 1990 The Regents of the University of California.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * Jan-Simon Pendry at Imperial College, London.
10 *

--- 20 unchanged lines hidden (view full) ---

31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
3 * Copyright (c) 1990 Jan-Simon Pendry
4 * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
5 * Copyright (c) 1990 The Regents of the University of California.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * Jan-Simon Pendry at Imperial College, London.
10 *

--- 20 unchanged lines hidden (view full) ---

31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * %W% (Berkeley) %G%
40 *
39 *
41 * $Id: fixmount.c,v 1.5.2.4 2004/01/06 03:15:23 ezk Exp $
42 * $FreeBSD: head/contrib/amd/fixmount/fixmount.c 131706 2004-07-06 13:16:49Z mbr $
40 * File: am-utils/fixmount/fixmount.c
43 *
44 */
45
46#ifdef HAVE_CONFIG_H
47# include <config.h>
48#endif /* HAVE_CONFIG_H */
49#include <am_defs.h>
50
51#define CREATE_TIMEOUT 2 /* seconds */
52#define CALL_TIMEOUT 5 /* seconds */
53
41 *
42 */
43
44#ifdef HAVE_CONFIG_H
45# include <config.h>
46#endif /* HAVE_CONFIG_H */
47#include <am_defs.h>
48
49#define CREATE_TIMEOUT 2 /* seconds */
50#define CALL_TIMEOUT 5 /* seconds */
51
54#ifndef INADDR_NONE
55# define INADDR_NONE 0xffffffff
56#endif /* not INADDR_NONE */
57
58/* Constant defs */
59#define ALL 1
60#define DIRS 2
61
62#define DODUMP 0x1
63#define DOEXPORTS 0x2
64#define DOREMOVE 0x4
65#define DOVERIFY 0x8

--- 50 unchanged lines hidden (view full) ---

116 * is typically called repeatedly on the same names,
117 * cache the last lookup result and reuse it if possible.
118 */
119 if (strcasecmp(name1, lasthost) == 0) {
120 return (addr1.s_addr == addr2.s_addr);
121 } else if (!(he = gethostbyname(name1))) {
122 return 0;
123 } else {
52/* Constant defs */
53#define ALL 1
54#define DIRS 2
55
56#define DODUMP 0x1
57#define DOEXPORTS 0x2
58#define DOREMOVE 0x4
59#define DOVERIFY 0x8

--- 50 unchanged lines hidden (view full) ---

110 * is typically called repeatedly on the same names,
111 * cache the last lookup result and reuse it if possible.
112 */
113 if (strcasecmp(name1, lasthost) == 0) {
114 return (addr1.s_addr == addr2.s_addr);
115 } else if (!(he = gethostbyname(name1))) {
116 return 0;
117 } else {
124 strncpy(lasthost, name1, sizeof(lasthost) - 1);
118 xstrlcpy(lasthost, name1, MAXHOSTNAMELEN);
125 memcpy(&addr1, he->h_addr, sizeof(addr1));
126 return (addr1.s_addr == addr2.s_addr);
127 }
128 }
129}
130
131
132/*

--- 27 unchanged lines hidden (view full) ---

160 */
161int
162remove_mount(CLIENT *client, char *host, mountlist ml, int fixit)
163{
164 enum clnt_stat estat;
165 struct timeval tv;
166 char *pathp = dir_path;
167
119 memcpy(&addr1, he->h_addr, sizeof(addr1));
120 return (addr1.s_addr == addr2.s_addr);
121 }
122 }
123}
124
125
126/*

--- 27 unchanged lines hidden (view full) ---

154 */
155int
156remove_mount(CLIENT *client, char *host, mountlist ml, int fixit)
157{
158 enum clnt_stat estat;
159 struct timeval tv;
160 char *pathp = dir_path;
161
168 strncpy(dir_path, ml->ml_directory, sizeof(dir_path));
162 xstrlcpy(dir_path, ml->ml_directory, sizeof(dir_path));
169
170 if (!fixit) {
171 printf("%s: bogus mount %s:%s\n", host, ml->ml_hostname, ml->ml_directory);
172 fflush(stdout);
173 } else {
174 printf("%s: removing %s:%s\n", host, ml->ml_hostname, ml->ml_directory);
175 fflush(stdout);
176

--- 145 unchanged lines hidden (view full) ---

322 quiet = 1;
323 break;
324
325 case 'f':
326 force = 1;
327 break;
328
329 case 'h':
163
164 if (!fixit) {
165 printf("%s: bogus mount %s:%s\n", host, ml->ml_hostname, ml->ml_directory);
166 fflush(stdout);
167 } else {
168 printf("%s: removing %s:%s\n", host, ml->ml_hostname, ml->ml_directory);
169 fflush(stdout);
170

--- 145 unchanged lines hidden (view full) ---

316 quiet = 1;
317 break;
318
319 case 'f':
320 force = 1;
321 break;
322
323 case 'h':
330 strncpy(thishost, optarg, sizeof(thishost));
331 thishost[sizeof(thishost) - 1] = '\0';
324 xstrlcpy(thishost, optarg, sizeof(thishost));
332 break;
333
334 case '?':
335 default:
336 usage();
337 }
338
339 if (optind == argc)

--- 23 unchanged lines hidden (view full) ---

363 }
364 memcpy(&thisaddr, he->h_addr, sizeof(thisaddr));
365 if (!(he = gethostbyaddr((char *) &thisaddr, sizeof(thisaddr),
366 he->h_addrtype))) {
367 fprintf(stderr, "gethostbyaddr failed on %s\n",
368 inet_ntoa(thisaddr));
369 exit(1);
370 }
325 break;
326
327 case '?':
328 default:
329 usage();
330 }
331
332 if (optind == argc)

--- 23 unchanged lines hidden (view full) ---

356 }
357 memcpy(&thisaddr, he->h_addr, sizeof(thisaddr));
358 if (!(he = gethostbyaddr((char *) &thisaddr, sizeof(thisaddr),
359 he->h_addrtype))) {
360 fprintf(stderr, "gethostbyaddr failed on %s\n",
361 inet_ntoa(thisaddr));
362 exit(1);
363 }
371 strncpy(thishost, he->h_name, sizeof(thishost));
372 thishost[sizeof(thishost) - 1] = '\0';
364 xstrlcpy(thishost, he->h_name, sizeof(thishost));
373 } else {
374 thisaddr.s_addr = INADDR_NONE;
375 }
376
377 if (!(auth = authunix_create_default())) {
378 fprintf(stderr, "couldn't create authentication handle\n");
379 exit(1);
380 }

--- 112 unchanged lines hidden (view full) ---

493 */
494static int
495inetresport(int ty)
496{
497 int alport;
498 struct sockaddr_in addr;
499 int fd;
500
365 } else {
366 thisaddr.s_addr = INADDR_NONE;
367 }
368
369 if (!(auth = authunix_create_default())) {
370 fprintf(stderr, "couldn't create authentication handle\n");
371 exit(1);
372 }

--- 112 unchanged lines hidden (view full) ---

485 */
486static int
487inetresport(int ty)
488{
489 int alport;
490 struct sockaddr_in addr;
491 int fd;
492
501 /* Use internet address family */
502 addr.sin_family = AF_INET;
493 memset(&addr, 0, sizeof(addr));
494 /* as per POSIX, sin_len need not be set (used internally by kernel) */
495
496 addr.sin_family = AF_INET; /* use internet address family */
503 addr.sin_addr.s_addr = INADDR_ANY;
504 if ((fd = socket(AF_INET, ty, 0)) < 0)
505 return -1;
506
507 for (alport = IPPORT_RESERVED - 1; alport > IPPORT_RESERVED / 2 + 1; alport--) {
508 addr.sin_port = htons((u_short) alport);
509 if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) >= 0)
510 return fd;

--- 53 unchanged lines hidden (view full) ---

564
565 /*
566 * Get address of host
567 */
568 if ((hp = gethostbyname(host)) == 0 && !STREQ(host, localhost)) {
569 fprintf(stderr, "can't get address of %s\n", host);
570 return NULL;
571 }
497 addr.sin_addr.s_addr = INADDR_ANY;
498 if ((fd = socket(AF_INET, ty, 0)) < 0)
499 return -1;
500
501 for (alport = IPPORT_RESERVED - 1; alport > IPPORT_RESERVED / 2 + 1; alport--) {
502 addr.sin_port = htons((u_short) alport);
503 if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) >= 0)
504 return fd;

--- 53 unchanged lines hidden (view full) ---

558
559 /*
560 * Get address of host
561 */
562 if ((hp = gethostbyname(host)) == 0 && !STREQ(host, localhost)) {
563 fprintf(stderr, "can't get address of %s\n", host);
564 return NULL;
565 }
572 memset(&host_addr, 0, sizeof host_addr);
566 memset(&host_addr, 0, sizeof(host_addr));
567 /* as per POSIX, sin_len need not be set (used internally by kernel) */
573 host_addr.sin_family = AF_INET;
574 if (hp) {
575 memmove((voidp) &host_addr.sin_addr, (voidp) hp->h_addr,
576 sizeof(host_addr.sin_addr));
577 } else {
578 /* fake "localhost" */
579 host_addr.sin_addr.s_addr = htonl(0x7f000001);
580 }

--- 28 unchanged lines hidden ---
568 host_addr.sin_family = AF_INET;
569 if (hp) {
570 memmove((voidp) &host_addr.sin_addr, (voidp) hp->h_addr,
571 sizeof(host_addr.sin_addr));
572 } else {
573 /* fake "localhost" */
574 host_addr.sin_addr.s_addr = htonl(0x7f000001);
575 }

--- 28 unchanged lines hidden ---