]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - spaceman/file.c
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2004-2005 Silicon Graphics, Inc.
4 * Copyright (c) 2012 Red Hat, Inc.
16 static cmdinfo_t print_cmd
;
28 printf(_("%c%03d%c %-14s\n"), braces
? '[' : ' ', index
,
29 braces
? ']' : ' ', file
->name
);
39 for (i
= 0; i
< filecount
; i
++)
40 print_fileio(&filetable
[i
], i
, &filetable
[i
] == file
);
47 xfs_fsop_geom_t
*geom
,
48 struct fs_path
*fs_path
)
59 if (ioctl(fd
, XFS_IOC_FSGEOMETRY
, geom
) < 0) {
62 _("%s: Not on a mounted XFS filesystem.\n"),
65 perror("XFS_IOC_FSGEOMETRY");
71 fsp
= fs_table_lookup(path
, FS_MOUNT_POINT
);
73 fprintf(stderr
, _("%s: cannot find mount point."),
78 memcpy(fs_path
, fsp
, sizeof(struct fs_path
));
87 xfs_fsop_geom_t
*geometry
,
88 struct fs_path
*fs_path
)
92 filename
= strdup(name
);
99 /* Extend the table of currently open files */
100 filetable
= (fileio_t
*)realloc(filetable
, /* growing */
101 ++filecount
* sizeof(fileio_t
));
110 /* Finally, make this the new active open file */
111 file
= &filetable
[filecount
- 1];
113 file
->name
= filename
;
114 file
->geom
= *geometry
;
115 memcpy(&file
->fs_path
, fs_path
, sizeof(file
->fs_path
));
122 print_cmd
.name
= "print";
123 print_cmd
.altname
= "p";
124 print_cmd
.cfunc
= print_f
;
125 print_cmd
.argmin
= 0;
126 print_cmd
.argmax
= 0;
127 print_cmd
.flags
= CMD_FLAG_ONESHOT
;
128 print_cmd
.oneline
= _("list current open files");
130 add_command(&print_cmd
);