2 Copyright (c) 2010 Frank Lahm <franklahm@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
17 #endif /* HAVE_CONFIG_H */
20 #include <sys/types.h>
34 #include <atalk/adouble.h>
35 #include <atalk/cnid.h>
36 #include <atalk/volinfo.h>
39 static volatile sig_atomic_t alarmed;
43 catch SIGINT and SIGTERM which cause clean exit. Ignore anything else.
46 static void sig_handler(int signo)
52 static void set_signal(void)
56 sv.sa_handler = sig_handler;
57 sv.sa_flags = SA_RESTART;
58 sigemptyset(&sv.sa_mask);
59 if (sigaction(SIGTERM, &sv, NULL) < 0)
60 ERROR("error in sigaction(SIGTERM): %s", strerror(errno));
62 if (sigaction(SIGINT, &sv, NULL) < 0)
63 ERROR("error in sigaction(SIGINT): %s", strerror(errno));
65 memset(&sv, 0, sizeof(struct sigaction));
66 sv.sa_handler = SIG_IGN;
67 sigemptyset(&sv.sa_mask);
69 if (sigaction(SIGABRT, &sv, NULL) < 0)
70 ERROR("error in sigaction(SIGABRT): %s", strerror(errno));
72 if (sigaction(SIGHUP, &sv, NULL) < 0)
73 ERROR("error in sigaction(SIGHUP): %s", strerror(errno));
75 if (sigaction(SIGQUIT, &sv, NULL) < 0)
76 ERROR("error in sigaction(SIGQUIT): %s", strerror(errno));
79 static void usage_find(void)
82 "Usage: ad find VOLUME_PATH NAME\n"
86 int ad_find(int argc, char **argv)
91 printf("argc: %d, argv0: %s\n", argc, argv[0]);
101 openvol(argv[2], &vol);
102 cnid_find(vol.volume.v_cdb, argv[3], strlen(argv[3]) + 1);