19 |
#include <stdio.h> |
#include <stdio.h> |
20 |
#include <stdlib.h> |
#include <stdlib.h> |
21 |
#include <string.h> |
#include <string.h> |
22 |
|
#include <argp.h> |
23 |
#include <hurd/fsys.h> |
#include <hurd/fsys.h> |
24 |
#include <fcntl.h> |
#include <fcntl.h> |
25 |
#include <errno.h> |
#include <errno.h> |
26 |
#include <error.h> |
#include <error.h> |
27 |
|
#include <version.h> |
28 |
#include "fsys_S.h" |
#include "fsys_S.h" |
29 |
|
|
30 |
mach_port_t realnode; |
mach_port_t realnode; |
37 |
|
|
38 |
extern int fsys_server (mach_msg_header_t *, mach_msg_header_t *); |
extern int fsys_server (mach_msg_header_t *, mach_msg_header_t *); |
39 |
|
|
40 |
|
const char *argp_program_version = STANDARD_HURD_VERSION (symlink); |
41 |
|
|
42 |
|
static const struct argp_option options[] = |
43 |
|
{ |
44 |
|
{ 0 } |
45 |
|
}; |
46 |
|
|
47 |
|
static const char args_doc[] = "TARGET"; |
48 |
|
static const char doc[] = "A translator for symlinks." |
49 |
|
"\vA symlink is an alias for another node in the filesystem." |
50 |
|
"\n" |
51 |
|
"\nA symbolic link refers to its target `by name', and contains no actual" |
52 |
|
" reference to the target. The target referenced by the symlink is" |
53 |
|
" looked up in the namespace of the client."; |
54 |
|
|
55 |
|
/* Parse a single option/argument. */ |
56 |
|
static error_t |
57 |
|
parse_opt (int key, char *arg, struct argp_state *state) |
58 |
|
{ |
59 |
|
if (key == ARGP_KEY_ARG && state->arg_num == 0) |
60 |
|
linktarget = arg; |
61 |
|
else if (key == ARGP_KEY_ARG || key == ARGP_KEY_NO_ARGS) |
62 |
|
argp_usage (state); |
63 |
|
else |
64 |
|
return ARGP_ERR_UNKNOWN; |
65 |
|
return 0; |
66 |
|
} |
67 |
|
|
68 |
|
static struct argp argp = { options, parse_opt, args_doc, doc }; |
69 |
|
|
70 |
|
|
71 |
int |
int |
72 |
main (int argc, char **argv) |
main (int argc, char **argv) |
73 |
{ |
{ |
75 |
mach_port_t control; |
mach_port_t control; |
76 |
error_t err; |
error_t err; |
77 |
|
|
78 |
if (argc != 2) |
/* Parse our options... */ |
79 |
{ |
argp_parse (&argp, argc, argv, 0, 0, 0); |
|
fprintf (stderr, "Usage: %s link-target\n", argv[0]); |
|
|
exit (1); |
|
|
} |
|
80 |
|
|
81 |
task_get_bootstrap_port (mach_task_self (), &bootstrap); |
task_get_bootstrap_port (mach_task_self (), &bootstrap); |
82 |
if (bootstrap == MACH_PORT_NULL) |
if (bootstrap == MACH_PORT_NULL) |