amq.c (38500) | amq.c (42633) |
---|---|
1/* 2 * Copyright (c) 1997-1998 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 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software | 1/* 2 * Copyright (c) 1997-1998 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 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software |
20 * must display the following acknowledgement: | 20 * must display the following acknowledgment: |
21 * This product includes software developed by the University of 22 * California, Berkeley and its contributors. 23 * 4. Neither the name of the University nor the names of its contributors 24 * may be used to endorse or promote products derived from this software 25 * without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE --- 4 unchanged lines hidden (view full) --- 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 * | 21 * This product includes software developed by the University of 22 * California, Berkeley and its contributors. 23 * 4. Neither the name of the University nor the names of its contributors 24 * may be used to endorse or promote products derived from this software 25 * without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE --- 4 unchanged lines hidden (view full) --- 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 * |
41 * $Id: amq.c,v 1.1.1.1 1998/08/23 22:07:20 obrien Exp $ | 41 * $Id: amq.c,v 1.2 1998/08/23 22:52:08 obrien Exp $ |
42 * 43 */ 44 45/* 46 * Automounter query tool 47 */ 48 49#ifndef lint 50char copyright[] = "\ 51@(#)Copyright (c) 1997-1998 Erez Zadok\n\ 52@(#)Copyright (c) 1990 Jan-Simon Pendry\n\ 53@(#)Copyright (c) 1990 Imperial College of Science, Technology & Medicine\n\ 54@(#)Copyright (c) 1990 The Regents of the University of California.\n\ 55@(#)All rights reserved.\n"; 56#if __GNUC__ < 2 | 42 * 43 */ 44 45/* 46 * Automounter query tool 47 */ 48 49#ifndef lint 50char copyright[] = "\ 51@(#)Copyright (c) 1997-1998 Erez Zadok\n\ 52@(#)Copyright (c) 1990 Jan-Simon Pendry\n\ 53@(#)Copyright (c) 1990 Imperial College of Science, Technology & Medicine\n\ 54@(#)Copyright (c) 1990 The Regents of the University of California.\n\ 55@(#)All rights reserved.\n"; 56#if __GNUC__ < 2 |
57static char rcsid[] = "$Id: amq.c,v 1.1.1.1 1998/08/23 22:07:20 obrien Exp $"; | 57static char rcsid[] = "$Id: amq.c,v 1.2 1998/08/23 22:52:08 obrien Exp $"; |
58static char sccsid[] = "%W% (Berkeley) %G%"; 59#endif /* __GNUC__ < 2 */ 60#endif /* not lint */ 61 62#ifdef HAVE_CONFIG_H 63# include <config.h> 64#endif /* HAVE_CONFIG_H */ 65#include <am_defs.h> 66#include <amq.h> 67 68/* locals */ | 58static char sccsid[] = "%W% (Berkeley) %G%"; 59#endif /* __GNUC__ < 2 */ 60#endif /* not lint */ 61 62#ifdef HAVE_CONFIG_H 63# include <config.h> 64#endif /* HAVE_CONFIG_H */ 65#include <am_defs.h> 66#include <amq.h> 67 68/* locals */ |
69#if 0 |
|
69char *progname; | 70char *progname; |
71#endif |
|
70static int flush_flag; 71static int minfo_flag; 72static int getpid_flag; 73static int unmount_flag; 74static int stats_flag; 75static int getvers_flag; 76static int amd_program_number = AMQ_PROGRAM; 77static int use_tcp_flag, use_udp_flag; 78static char *debug_opts; 79static char *amq_logfile; 80static char *mount_map; 81static char *xlog_optstr; 82static char localhost[] = "localhost"; 83static char *def_server = localhost; 84 85/* externals */ 86extern int optind; 87extern char *optarg; 88 | 72static int flush_flag; 73static int minfo_flag; 74static int getpid_flag; 75static int unmount_flag; 76static int stats_flag; 77static int getvers_flag; 78static int amd_program_number = AMQ_PROGRAM; 79static int use_tcp_flag, use_udp_flag; 80static char *debug_opts; 81static char *amq_logfile; 82static char *mount_map; 83static char *xlog_optstr; 84static char localhost[] = "localhost"; 85static char *def_server = localhost; 86 87/* externals */ 88extern int optind; 89extern char *optarg; 90 |
89/* forward decalrations */ | 91/* forward declarations */ |
90#ifdef HAVE_TRANSPORT_TYPE_TLI 91static CLIENT *get_secure_amd_client(char *host, struct timeval *tv, int *sock); 92static int amq_bind_resv_port(int td, u_short *pp); 93#else /* not HAVE_TRANSPORT_TYPE_TLI */ 94static int privsock(int ty); 95#endif /* not HAVE_TRANSPORT_TYPE_TLI */ 96 97/* dummy variables */ | 92#ifdef HAVE_TRANSPORT_TYPE_TLI 93static CLIENT *get_secure_amd_client(char *host, struct timeval *tv, int *sock); 94static int amq_bind_resv_port(int td, u_short *pp); 95#else /* not HAVE_TRANSPORT_TYPE_TLI */ 96static int privsock(int ty); 97#endif /* not HAVE_TRANSPORT_TYPE_TLI */ 98 99/* dummy variables */ |
100#if 0 |
|
98char hostname[MAXHOSTNAMELEN]; | 101char hostname[MAXHOSTNAMELEN]; |
99int orig_umask, foreground, debug_flags; | |
100pid_t mypid; 101serv_state amd_state; | 102pid_t mypid; 103serv_state amd_state; |
104int foreground, orig_umask; 105int debug_flags; 106#endif |
|
102 103/* structures */ 104enum show_opt { 105 Full, Stats, Calc, Short, ShowDone 106}; 107 108 109/* --- 194 unchanged lines hidden (view full) --- 304 int errs = 0; 305 char *server; 306 struct sockaddr_in server_addr; 307 int s; /* to pass the Amd security check, we must use a priv port */ 308 CLIENT *clnt = NULL; 309 struct hostent *hp; 310 int nodefault = 0; 311 struct timeval tv; | 107 108/* structures */ 109enum show_opt { 110 Full, Stats, Calc, Short, ShowDone 111}; 112 113 114/* --- 194 unchanged lines hidden (view full) --- 309 int errs = 0; 310 char *server; 311 struct sockaddr_in server_addr; 312 int s; /* to pass the Amd security check, we must use a priv port */ 313 CLIENT *clnt = NULL; 314 struct hostent *hp; 315 int nodefault = 0; 316 struct timeval tv; |
317 char *progname = NULL; |
|
312#ifndef HAVE_TRANSPORT_TYPE_TLI 313 enum clnt_stat cs; 314#endif /* not HAVE_TRANSPORT_TYPE_TLI */ 315 316 317 /* 318 * Compute program name 319 */ 320 if (argv[0]) { 321 progname = strrchr(argv[0], '/'); 322 if (progname && progname[1]) 323 progname++; 324 else 325 progname = argv[0]; 326 } 327 if (!progname) 328 progname = "amq"; | 318#ifndef HAVE_TRANSPORT_TYPE_TLI 319 enum clnt_stat cs; 320#endif /* not HAVE_TRANSPORT_TYPE_TLI */ 321 322 323 /* 324 * Compute program name 325 */ 326 if (argv[0]) { 327 progname = strrchr(argv[0], '/'); 328 if (progname && progname[1]) 329 progname++; 330 else 331 progname = argv[0]; 332 } 333 if (!progname) 334 progname = "amq"; |
335 am_set_progname(progname); |
|
329 330 /* 331 * Parse arguments 332 */ 333 while ((opt_ch = getopt(argc, argv, "fh:l:msuvx:D:M:pP:TU")) != -1) 334 switch (opt_ch) { 335 case 'f': 336 flush_flag = 1; --- 70 unchanged lines hidden (view full) --- 407 if (unmount_flag) 408 errs = 1; 409 } 410 if (errs) { 411 show_usage: 412 fprintf(stderr, "\ 413Usage: %s [-h host] [[-f] [-m] [-p] [-v] [-s]] | [[-u] directory ...]]\n\ 414\t[-l logfile|\"syslog\"] [-x log_flags] [-D dbg_opts] [-M mapent]\n\ | 336 337 /* 338 * Parse arguments 339 */ 340 while ((opt_ch = getopt(argc, argv, "fh:l:msuvx:D:M:pP:TU")) != -1) 341 switch (opt_ch) { 342 case 'f': 343 flush_flag = 1; --- 70 unchanged lines hidden (view full) --- 414 if (unmount_flag) 415 errs = 1; 416 } 417 if (errs) { 418 show_usage: 419 fprintf(stderr, "\ 420Usage: %s [-h host] [[-f] [-m] [-p] [-v] [-s]] | [[-u] directory ...]]\n\ 421\t[-l logfile|\"syslog\"] [-x log_flags] [-D dbg_opts] [-M mapent]\n\ |
415\t[-P prognum] [-T] [-U]\n", progname); | 422\t[-P prognum] [-T] [-U]\n", am_get_progname()); |
416 exit(1); 417 } 418 419 /* set use_udp and use_tcp flags both to on if none are defined */ 420 if (!use_tcp_flag && !use_udp_flag) 421 use_tcp_flag = use_udp_flag = 1; 422 423#if defined(HAVE_CLUSTER_H) && defined(HAVE_CNODEID) && defined(HAVE_GETCCENT) --- 5 unchanged lines hidden (view full) --- 429 else 430#endif /* defined(HAVE_CLUSTER_H) && defined(HAVE_CNODEID) && defined(HAVE_GETCCENT) */ 431 server = def_server; 432 433 /* 434 * Get address of server 435 */ 436 if ((hp = gethostbyname(server)) == 0 && !STREQ(server, localhost)) { | 423 exit(1); 424 } 425 426 /* set use_udp and use_tcp flags both to on if none are defined */ 427 if (!use_tcp_flag && !use_udp_flag) 428 use_tcp_flag = use_udp_flag = 1; 429 430#if defined(HAVE_CLUSTER_H) && defined(HAVE_CNODEID) && defined(HAVE_GETCCENT) --- 5 unchanged lines hidden (view full) --- 436 else 437#endif /* defined(HAVE_CLUSTER_H) && defined(HAVE_CNODEID) && defined(HAVE_GETCCENT) */ 438 server = def_server; 439 440 /* 441 * Get address of server 442 */ 443 if ((hp = gethostbyname(server)) == 0 && !STREQ(server, localhost)) { |
437 fprintf(stderr, "%s: Can't get address of %s\n", progname, server); | 444 fprintf(stderr, "%s: Can't get address of %s\n", 445 am_get_progname(), server); |
438 exit(1); 439 } 440 memset(&server_addr, 0, sizeof server_addr); 441 server_addr.sin_family = AF_INET; 442 if (hp) { 443 memmove((voidp) &server_addr.sin_addr, (voidp) hp->h_addr, 444 sizeof(server_addr.sin_addr)); 445 } else { --- 18 unchanged lines hidden (view full) --- 464 clnt_control(clnt, CLSET_RETRY_TIMEOUT, (char *) &tv); 465 } 466#else /* not HAVE_TRANSPORT_TYPE_TLI */ 467 468 /* first check if remote portmapper is up */ 469 cs = pmap_ping(&server_addr); 470 if (cs == RPC_TIMEDOUT) { 471 fprintf(stderr, "%s: failed to contact portmapper on host \"%s\". %s\n", | 446 exit(1); 447 } 448 memset(&server_addr, 0, sizeof server_addr); 449 server_addr.sin_family = AF_INET; 450 if (hp) { 451 memmove((voidp) &server_addr.sin_addr, (voidp) hp->h_addr, 452 sizeof(server_addr.sin_addr)); 453 } else { --- 18 unchanged lines hidden (view full) --- 472 clnt_control(clnt, CLSET_RETRY_TIMEOUT, (char *) &tv); 473 } 474#else /* not HAVE_TRANSPORT_TYPE_TLI */ 475 476 /* first check if remote portmapper is up */ 477 cs = pmap_ping(&server_addr); 478 if (cs == RPC_TIMEDOUT) { 479 fprintf(stderr, "%s: failed to contact portmapper on host \"%s\". %s\n", |
472 progname, server, clnt_sperrno(cs)); | 480 am_get_progname(), server, clnt_sperrno(cs)); |
473 exit(1); 474 } 475 476 /* portmapper exists: get remote amd info from it */ 477 if (!clnt && use_tcp_flag) { /* try tcp first */ 478 s = RPC_ANYSOCK; 479 clnt = clnttcp_create(&server_addr, amd_program_number, 480 AMQ_VERSION, &s, 0, 0); 481 } 482 if (!clnt && use_udp_flag) { /* try udp next */ 483 /* XXX: do we need to close(s) ? */ 484 s = privsock(SOCK_DGRAM); 485 clnt = clntudp_create(&server_addr, amd_program_number, 486 AMQ_VERSION, tv, &s); 487 } 488#endif /* not HAVE_TRANSPORT_TYPE_TLI */ 489 if (!clnt) { | 481 exit(1); 482 } 483 484 /* portmapper exists: get remote amd info from it */ 485 if (!clnt && use_tcp_flag) { /* try tcp first */ 486 s = RPC_ANYSOCK; 487 clnt = clnttcp_create(&server_addr, amd_program_number, 488 AMQ_VERSION, &s, 0, 0); 489 } 490 if (!clnt && use_udp_flag) { /* try udp next */ 491 /* XXX: do we need to close(s) ? */ 492 s = privsock(SOCK_DGRAM); 493 clnt = clntudp_create(&server_addr, amd_program_number, 494 AMQ_VERSION, tv, &s); 495 } 496#endif /* not HAVE_TRANSPORT_TYPE_TLI */ 497 if (!clnt) { |
490 fprintf(stderr, "%s: ", progname); | 498 fprintf(stderr, "%s: ", am_get_progname()); |
491 clnt_pcreateerror(server); 492 exit(1); 493 } 494 495 /* 496 * Control debugging 497 */ 498 if (debug_opts) { 499 int *rc; 500 amq_setopt opt; 501 opt.as_opt = AMOPT_DEBUG; 502 opt.as_str = debug_opts; 503 rc = amqproc_setopt_1(&opt, clnt); 504 if (rc && *rc < 0) { | 499 clnt_pcreateerror(server); 500 exit(1); 501 } 502 503 /* 504 * Control debugging 505 */ 506 if (debug_opts) { 507 int *rc; 508 amq_setopt opt; 509 opt.as_opt = AMOPT_DEBUG; 510 opt.as_str = debug_opts; 511 rc = amqproc_setopt_1(&opt, clnt); 512 if (rc && *rc < 0) { |
505 fprintf(stderr, "%s: daemon not compiled for debug\n", progname); | 513 fprintf(stderr, "%s: daemon not compiled for debug\n", 514 am_get_progname()); |
506 errs = 1; 507 } else if (!rc || *rc > 0) { | 515 errs = 1; 516 } else if (!rc || *rc > 0) { |
508 fprintf(stderr, "%s: debug setting for \"%s\" failed\n", progname, debug_opts); | 517 fprintf(stderr, "%s: debug setting for \"%s\" failed\n", 518 am_get_progname(), debug_opts); |
509 errs = 1; 510 } 511 } 512 513 /* 514 * Control logging 515 */ 516 if (xlog_optstr) { 517 int *rc; 518 amq_setopt opt; 519 opt.as_opt = AMOPT_XLOG; 520 opt.as_str = xlog_optstr; 521 rc = amqproc_setopt_1(&opt, clnt); 522 if (!rc || *rc) { | 519 errs = 1; 520 } 521 } 522 523 /* 524 * Control logging 525 */ 526 if (xlog_optstr) { 527 int *rc; 528 amq_setopt opt; 529 opt.as_opt = AMOPT_XLOG; 530 opt.as_str = xlog_optstr; 531 rc = amqproc_setopt_1(&opt, clnt); 532 if (!rc || *rc) { |
523 fprintf(stderr, "%s: setting log level to \"%s\" failed\n", progname, xlog_optstr); | 533 fprintf(stderr, "%s: setting log level to \"%s\" failed\n", 534 am_get_progname(), xlog_optstr); |
524 errs = 1; 525 } 526 } 527 528 /* 529 * Control log file 530 */ 531 if (amq_logfile) { 532 int *rc; 533 amq_setopt opt; 534 opt.as_opt = AMOPT_LOGFILE; 535 opt.as_str = amq_logfile; 536 rc = amqproc_setopt_1(&opt, clnt); 537 if (!rc || *rc) { | 535 errs = 1; 536 } 537 } 538 539 /* 540 * Control log file 541 */ 542 if (amq_logfile) { 543 int *rc; 544 amq_setopt opt; 545 opt.as_opt = AMOPT_LOGFILE; 546 opt.as_str = amq_logfile; 547 rc = amqproc_setopt_1(&opt, clnt); 548 if (!rc || *rc) { |
538 fprintf(stderr, "%s: setting logfile to \"%s\" failed\n", progname, amq_logfile); | 549 fprintf(stderr, "%s: setting logfile to \"%s\" failed\n", 550 am_get_progname(), amq_logfile); |
539 errs = 1; 540 } 541 } 542 543 /* 544 * Flush map cache 545 */ 546 if (flush_flag) { 547 int *rc; 548 amq_setopt opt; 549 opt.as_opt = AMOPT_FLUSHMAPC; 550 opt.as_str = ""; 551 rc = amqproc_setopt_1(&opt, clnt); 552 if (!rc || *rc) { | 551 errs = 1; 552 } 553 } 554 555 /* 556 * Flush map cache 557 */ 558 if (flush_flag) { 559 int *rc; 560 amq_setopt opt; 561 opt.as_opt = AMOPT_FLUSHMAPC; 562 opt.as_str = ""; 563 rc = amqproc_setopt_1(&opt, clnt); 564 if (!rc || *rc) { |
553 fprintf(stderr, "%s: amd on %s cannot flush the map cache\n", progname, server); | 565 fprintf(stderr, "%s: amd on %s cannot flush the map cache\n", 566 am_get_progname(), server); |
554 errs = 1; 555 } 556 } 557 558 /* 559 * Mount info 560 */ 561 if (minfo_flag) { 562 int dummy; 563 amq_mount_info_list *ml = amqproc_getmntfs_1(&dummy, clnt); 564 if (ml) { 565 int mwid = 0, dwid = 0, twid = 0; 566 show_mi(ml, Calc, &mwid, &dwid, &twid); 567 mwid++; 568 dwid++; 569 twid++; 570 show_mi(ml, Full, &mwid, &dwid, &twid); 571 572 } else { | 567 errs = 1; 568 } 569 } 570 571 /* 572 * Mount info 573 */ 574 if (minfo_flag) { 575 int dummy; 576 amq_mount_info_list *ml = amqproc_getmntfs_1(&dummy, clnt); 577 if (ml) { 578 int mwid = 0, dwid = 0, twid = 0; 579 show_mi(ml, Calc, &mwid, &dwid, &twid); 580 mwid++; 581 dwid++; 582 twid++; 583 show_mi(ml, Full, &mwid, &dwid, &twid); 584 585 } else { |
573 fprintf(stderr, "%s: amd on %s cannot provide mount info\n", progname, server); | 586 fprintf(stderr, "%s: amd on %s cannot provide mount info\n", 587 am_get_progname(), server); |
574 } 575 } 576 577 /* 578 * Mount map 579 */ 580 if (mount_map) { 581 int *rc; 582 do { 583 rc = amqproc_mount_1(&mount_map, clnt); 584 } while (rc && *rc < 0); 585 if (!rc || *rc > 0) { 586 if (rc) 587 errno = *rc; 588 else 589 errno = ETIMEDOUT; | 588 } 589 } 590 591 /* 592 * Mount map 593 */ 594 if (mount_map) { 595 int *rc; 596 do { 597 rc = amqproc_mount_1(&mount_map, clnt); 598 } while (rc && *rc < 0); 599 if (!rc || *rc > 0) { 600 if (rc) 601 errno = *rc; 602 else 603 errno = ETIMEDOUT; |
590 fprintf(stderr, "%s: could not start new ", progname); 591 perror("autmount point"); | 604 fprintf(stderr, "%s: could not start new ", am_get_progname()); 605 perror("automount point"); |
592 } 593 } 594 595 /* 596 * Get Version 597 */ 598 if (getvers_flag) { 599 amq_string *spp = amqproc_getvers_1((voidp) 0, clnt); 600 if (spp && *spp) { 601 fputs(*spp, stdout); 602 XFREE(*spp); 603 } else { | 606 } 607 } 608 609 /* 610 * Get Version 611 */ 612 if (getvers_flag) { 613 amq_string *spp = amqproc_getvers_1((voidp) 0, clnt); 614 if (spp && *spp) { 615 fputs(*spp, stdout); 616 XFREE(*spp); 617 } else { |
604 fprintf(stderr, "%s: failed to get version information\n", progname); | 618 fprintf(stderr, "%s: failed to get version information\n", 619 am_get_progname()); |
605 errs = 1; 606 } 607 } 608 609 /* 610 * Get PID of amd 611 */ 612 if (getpid_flag) { 613 int *ip = amqproc_getpid_1((voidp) 0, clnt); 614 if (ip && *ip) { 615 printf("%d\n", *ip); 616 } else { | 620 errs = 1; 621 } 622 } 623 624 /* 625 * Get PID of amd 626 */ 627 if (getpid_flag) { 628 int *ip = amqproc_getpid_1((voidp) 0, clnt); 629 if (ip && *ip) { 630 printf("%d\n", *ip); 631 } else { |
617 fprintf(stderr, "%s: failed to get PID of amd\n", progname); | 632 fprintf(stderr, "%s: failed to get PID of amd\n", am_get_progname()); |
618 errs = 1; 619 } 620 } 621 622 /* 623 * Apply required operation to all remaining arguments 624 */ 625 if (optind < argc) { --- 15 unchanged lines hidden (view full) --- 641 int mwid = 0, dwid = 0, twid = 0; 642 show_mt(mt, Calc, &mwid, &dwid, &twid); 643 mwid++; 644 dwid++, twid++; 645 printf("%-*.*s Uid Getattr Lookup RdDir RdLnk Statfs Mounted@\n", 646 dwid, dwid, "What"); 647 show_mt(mt, Stats, &mwid, &dwid, &twid); 648 } else { | 633 errs = 1; 634 } 635 } 636 637 /* 638 * Apply required operation to all remaining arguments 639 */ 640 if (optind < argc) { --- 15 unchanged lines hidden (view full) --- 656 int mwid = 0, dwid = 0, twid = 0; 657 show_mt(mt, Calc, &mwid, &dwid, &twid); 658 mwid++; 659 dwid++, twid++; 660 printf("%-*.*s Uid Getattr Lookup RdDir RdLnk Statfs Mounted@\n", 661 dwid, dwid, "What"); 662 show_mt(mt, Stats, &mwid, &dwid, &twid); 663 } else { |
649 fprintf(stderr, "%s: %s not automounted\n", progname, fs); | 664 fprintf(stderr, "%s: %s not automounted\n", am_get_progname(), fs); |
650 } 651 xdr_pri_free((XDRPROC_T_TYPE) xdr_amq_mount_tree_p, (caddr_t) mtp); 652 } else { | 665 } 666 xdr_pri_free((XDRPROC_T_TYPE) xdr_amq_mount_tree_p, (caddr_t) mtp); 667 } else { |
653 fprintf(stderr, "%s: ", progname); | 668 fprintf(stderr, "%s: ", am_get_progname()); |
654 clnt_perror(clnt, server); 655 errs = 1; 656 } 657 } 658 } while (optind < argc); 659 660 } else if (unmount_flag) { 661 goto show_usage; 662 663 } else if (stats_flag) { 664 amq_mount_stats *ms = amqproc_stats_1((voidp) 0, clnt); 665 if (ms) { 666 show_ms(ms); 667 } else { | 669 clnt_perror(clnt, server); 670 errs = 1; 671 } 672 } 673 } while (optind < argc); 674 675 } else if (unmount_flag) { 676 goto show_usage; 677 678 } else if (stats_flag) { 679 amq_mount_stats *ms = amqproc_stats_1((voidp) 0, clnt); 680 if (ms) { 681 show_ms(ms); 682 } else { |
668 fprintf(stderr, "%s: ", progname); | 683 fprintf(stderr, "%s: ", am_get_progname()); |
669 clnt_perror(clnt, server); 670 errs = 1; 671 } 672 673 } else if (!nodefault) { 674 amq_mount_tree_list *mlp = amqproc_export_1((voidp) 0, clnt); 675 if (mlp) { 676 enum show_opt e = Calc; --- 8 unchanged lines hidden (view full) --- 685 dwid++, pwid++; 686 if (e == Calc) 687 e = Short; 688 else if (e == Short) 689 e = ShowDone; 690 } 691 692 } else { | 684 clnt_perror(clnt, server); 685 errs = 1; 686 } 687 688 } else if (!nodefault) { 689 amq_mount_tree_list *mlp = amqproc_export_1((voidp) 0, clnt); 690 if (mlp) { 691 enum show_opt e = Calc; --- 8 unchanged lines hidden (view full) --- 700 dwid++, pwid++; 701 if (e == Calc) 702 e = Short; 703 else if (e == Short) 704 e = ShowDone; 705 } 706 707 } else { |
693 fprintf(stderr, "%s: ", progname); | 708 fprintf(stderr, "%s: ", am_get_progname()); |
694 clnt_perror(clnt, server); 695 errs = 1; 696 } 697 } 698 exit(errs); | 709 clnt_perror(clnt, server); 710 errs = 1; 711 } 712 } 713 exit(errs); |
699 return errs; /* should never reache here */ | 714 return errs; /* should never reach here */ |
700} 701 702 703#ifdef HAVE_TRANSPORT_TYPE_TLI 704 705/* 706 * How to bind to reserved ports. 707 * TLI handle (socket) and port version. --- 80 unchanged lines hidden (view full) --- 788 (XDRPROC_T_TYPE) xdr_void, 789 NULL, 790 (XDRPROC_T_TYPE) xdr_void, 791 NULL, 792 *tv, 793 NULL); 794 if (cs == RPC_TIMEDOUT) { 795 fprintf(stderr, "%s: failed to contact portmapper on host \"%s\". %s\n", | 715} 716 717 718#ifdef HAVE_TRANSPORT_TYPE_TLI 719 720/* 721 * How to bind to reserved ports. 722 * TLI handle (socket) and port version. --- 80 unchanged lines hidden (view full) --- 803 (XDRPROC_T_TYPE) xdr_void, 804 NULL, 805 (XDRPROC_T_TYPE) xdr_void, 806 NULL, 807 *tv, 808 NULL); 809 if (cs == RPC_TIMEDOUT) { 810 fprintf(stderr, "%s: failed to contact portmapper on host \"%s\". %s\n", |
796 progname, host, clnt_sperrno(cs)); | 811 am_get_progname(), host, clnt_sperrno(cs)); |
797 exit(1); 798 } 799 } 800 801 /* 802 * First transport type to try: TCP 803 */ 804 if (use_tcp_flag) { 805 /* Find amd address on TCP */ 806 nc = getnetconfigent(NC_TCP); 807 if (!nc) { 808 fprintf(stderr, "getnetconfig for tcp failed: %s\n", nc_sperror()); 809 goto tryudp; 810 } 811 812 if (!rpcb_getaddr(amd_program_number, AMQ_VERSION, nc, &nb, host)) { 813 /* | 812 exit(1); 813 } 814 } 815 816 /* 817 * First transport type to try: TCP 818 */ 819 if (use_tcp_flag) { 820 /* Find amd address on TCP */ 821 nc = getnetconfigent(NC_TCP); 822 if (!nc) { 823 fprintf(stderr, "getnetconfig for tcp failed: %s\n", nc_sperror()); 824 goto tryudp; 825 } 826 827 if (!rpcb_getaddr(amd_program_number, AMQ_VERSION, nc, &nb, host)) { 828 /* |
814 * don't pring error messages here, since amd might legitimately | 829 * don't print error messages here, since amd might legitimately |
815 * serve udp only 816 */ 817 goto tryudp; 818 } | 830 * serve udp only 831 */ 832 goto tryudp; 833 } |
819 /* Create priviledged TCP socket */ | 834 /* Create privileged TCP socket */ |
820 *sock = t_open(nc->nc_device, O_RDWR, 0); 821 822 if (*sock < 0) { 823 fprintf(stderr, "t_open %s: %m\n", nc->nc_device); 824 goto tryudp; 825 } 826 if (amq_bind_resv_port(*sock, (u_short *) 0) < 0) 827 goto tryudp; --- 19 unchanged lines hidden (view full) --- 847 fprintf(stderr, "getnetconfig for udp failed: %s\n", nc_sperror()); 848 return NULL; 849 } 850 if (!rpcb_getaddr(amd_program_number, AMQ_VERSION, nc, &nb, host)) { 851 fprintf(stderr, "%s\n", 852 clnt_spcreateerror("couldn't get amd address on udp")); 853 return NULL; 854 } | 835 *sock = t_open(nc->nc_device, O_RDWR, 0); 836 837 if (*sock < 0) { 838 fprintf(stderr, "t_open %s: %m\n", nc->nc_device); 839 goto tryudp; 840 } 841 if (amq_bind_resv_port(*sock, (u_short *) 0) < 0) 842 goto tryudp; --- 19 unchanged lines hidden (view full) --- 862 fprintf(stderr, "getnetconfig for udp failed: %s\n", nc_sperror()); 863 return NULL; 864 } 865 if (!rpcb_getaddr(amd_program_number, AMQ_VERSION, nc, &nb, host)) { 866 fprintf(stderr, "%s\n", 867 clnt_spcreateerror("couldn't get amd address on udp")); 868 return NULL; 869 } |
855 /* create priviledged UDP socket */ | 870 /* create privileged UDP socket */ |
856 *sock = t_open(nc->nc_device, O_RDWR, 0); 857 858 if (*sock < 0) { 859 fprintf(stderr, "t_open %s: %m\n", nc->nc_device); 860 return NULL; /* neither tcp not udp succeeded */ 861 } 862 if (amq_bind_resv_port(*sock, (u_short *) 0) < 0) 863 return NULL; --- 75 unchanged lines hidden --- | 871 *sock = t_open(nc->nc_device, O_RDWR, 0); 872 873 if (*sock < 0) { 874 fprintf(stderr, "t_open %s: %m\n", nc->nc_device); 875 return NULL; /* neither tcp not udp succeeded */ 876 } 877 if (amq_bind_resv_port(*sock, (u_short *) 0) < 0) 878 return NULL; --- 75 unchanged lines hidden --- |