]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - io/file.c
configure: remove unecessary definitions of _FILE_OFFSET_BITS
[thirdparty/xfsprogs-dev.git] / io / file.c
CommitLineData
48c46ee3 1/*
da23017d
NS
2 * Copyright (c) 2004-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
48c46ee3 4 *
da23017d
NS
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
48c46ee3
NS
7 * published by the Free Software Foundation.
8 *
da23017d
NS
9 * This program is distributed in the hope that it would 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.
48c46ee3 13 *
da23017d
NS
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
48c46ee3
NS
17 */
18
6b803e5a
CH
19#include "command.h"
20#include "input.h"
48c46ee3 21#include <sys/mman.h>
48c46ee3
NS
22#include "init.h"
23#include "io.h"
24
25static cmdinfo_t file_cmd;
26static cmdinfo_t print_cmd;
27
28fileio_t *filetable;
29int filecount;
30fileio_t *file;
31
32static void
33print_fileio(
34 fileio_t *file,
35 int index,
36 int braces)
37{
da2b3c09 38 printf(_("%c%03d%c %-14s (%s,%s,%s,%s%s%s%s%s)\n"),
48c46ee3
NS
39 braces? '[' : ' ', index, braces? ']' : ' ', file->name,
40 file->flags & IO_FOREIGN ? _("foreign") : _("xfs"),
41 file->flags & IO_OSYNC ? _("sync") : _("non-sync"),
42 file->flags & IO_DIRECT ? _("direct") : _("non-direct"),
43 file->flags & IO_READONLY ? _("read-only") : _("read-write"),
44 file->flags & IO_REALTIME ? _(",real-time") : "",
57f46ec0 45 file->flags & IO_APPEND ? _(",append-only") : "",
da2b3c09
CH
46 file->flags & IO_NONBLOCK ? _(",non-block") : "",
47 file->flags & IO_TMPFILE ? _(",tmpfile") : "");
48c46ee3
NS
48}
49
50int
51filelist_f(void)
52{
53 int i;
54
55 for (i = 0; i < filecount; i++)
56 print_fileio(&filetable[i], i, &filetable[i] == file);
57 return 0;
58}
59
60static int
61print_f(
62 int argc,
63 char **argv)
64{
65 filelist_f();
66 maplist_f();
67 return 0;
68}
69
70static int
71file_f(
72 int argc,
73 char **argv)
74{
75 int i;
76
77 if (argc <= 1)
78 return filelist_f();
79 i = atoi(argv[1]);
80 if (i < 0 || i >= filecount) {
24cd0fec 81 printf(_("value %d is out of range (0-%d)\n"), i, filecount-1);
48c46ee3
NS
82 } else {
83 file = &filetable[i];
84 filelist_f();
85 }
86 return 0;
87}
88
89void
90file_init(void)
91{
ad765595
AM
92 file_cmd.name = "file";
93 file_cmd.altname = "f";
48c46ee3
NS
94 file_cmd.args = _("[N]");
95 file_cmd.cfunc = file_f;
96 file_cmd.argmin = 0;
97 file_cmd.argmax = 1;
98 file_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
99 file_cmd.oneline = _("set the current file");
100
ad765595
AM
101 print_cmd.name = "print";
102 print_cmd.altname = "p";
48c46ee3
NS
103 print_cmd.cfunc = print_f;
104 print_cmd.argmin = 0;
105 print_cmd.argmax = 0;
802d66e3
BN
106 print_cmd.flags = CMD_NOMAP_OK | CMD_NOFILE_OK | CMD_FOREIGN_OK |
107 CMD_FLAG_GLOBAL;
48c46ee3
NS
108 print_cmd.oneline = _("list current open files and memory mappings");
109
110 add_command(&file_cmd);
111 add_command(&print_cmd);
112}