]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - spaceman/file.c
b779432858c8cfb64c2885f9d820c73dcaa1581c
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2004-2005 Silicon Graphics, Inc.
4 * Copyright (c) 2012 Red Hat, Inc.
13 #include "libfrog/logging.h"
14 #include "libfrog/paths.h"
15 #include "libfrog/fsgeom.h"
18 static cmdinfo_t print_cmd
;
20 struct fileio
*filetable
;
30 printf(_("%c%03d%c %-14s\n"), braces
? '[' : ' ', index
,
31 braces
? ']' : ' ', file
->name
);
41 for (i
= 0; i
< filecount
; i
++)
42 print_fileio(&filetable
[i
], i
, &filetable
[i
] == file
);
50 struct fs_path
*fs_path
)
55 ret
= xfd_open(xfd
, path
, O_RDONLY
);
59 _("%s: Not on a mounted XFS filesystem.\n"),
62 xfrog_perror(ret
, path
);
66 fsp
= fs_table_lookup(path
, FS_MOUNT_POINT
);
68 fprintf(stderr
, _("%s: cannot find mount point."),
73 memcpy(fs_path
, fsp
, sizeof(struct fs_path
));
82 struct fs_path
*fs_path
)
86 filename
= strdup(name
);
93 /* Extend the table of currently open files */
94 filetable
= (struct fileio
*)realloc(filetable
, /* growing */
95 ++filecount
* sizeof(struct fileio
));
104 /* Finally, make this the new active open file */
105 file
= &filetable
[filecount
- 1];
106 file
->name
= filename
;
107 memcpy(&file
->xfd
, xfd
, sizeof(struct xfs_fd
));
108 memcpy(&file
->fs_path
, fs_path
, sizeof(file
->fs_path
));
115 print_cmd
.name
= "print";
116 print_cmd
.altname
= "p";
117 print_cmd
.cfunc
= print_f
;
118 print_cmd
.argmin
= 0;
119 print_cmd
.argmax
= 0;
120 print_cmd
.flags
= CMD_FLAG_ONESHOT
;
121 print_cmd
.oneline
= _("list current open files");
123 add_command(&print_cmd
);