]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - io/link.c
xfs: convert to new timestamp accessors
[thirdparty/xfsprogs-dev.git] / io / link.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) 2014 Christoph Hellwig.
4 * All Rights Reserved.
5 */
6
7 #include "command.h"
8 #include "input.h"
9 #include "init.h"
10 #include "io.h"
11
12 #ifndef AT_EMPTY_PATH
13 #define AT_EMPTY_PATH 0x1000
14 #endif
15
16 static cmdinfo_t flink_cmd;
17
18 static void
19 flink_help(void)
20 {
21 printf(_(
22 "\n"
23 "link the open file descriptor to the supplied filename\n"
24 "\n"
25 "\n"));
26 }
27
28 static int
29 flink_f(
30 int argc,
31 char **argv)
32 {
33 if (argc != 2)
34 return command_usage(&flink_cmd);
35
36 if (linkat(file->fd, "", AT_FDCWD, argv[1], AT_EMPTY_PATH) < 0) {
37 perror("flink");
38 exitcode = 1;
39 return 0;
40 }
41 return 0;
42 }
43
44 void
45 flink_init(void)
46 {
47 flink_cmd.name = "flink";
48 flink_cmd.cfunc = flink_f;
49 flink_cmd.argmin = 1;
50 flink_cmd.argmax = 1;
51 flink_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK | CMD_FLAG_ONESHOT;
52 flink_cmd.args = _("filename");
53 flink_cmd.oneline =
54 _("link the open file descriptor to the supplied filename");
55 flink_cmd.help = flink_help;
56
57 add_command(&flink_cmd);
58 }