/* prepare the libxfs_init structure */
memset(&xargs, 0, sizeof(xargs));
- xargs.isdirect = LIBXFS_DIRECT;
- xargs.isreadonly = LIBXFS_ISREADONLY;
-
+ xargs.flags = LIBXFS_ISREADONLY | LIBXFS_DIRECT;
xargs.dname = source_name;
xargs.disfile = source_is_file;
}
if ((invalidate || recalculate) &&
- ((x.isreadonly & LIBXFS_ISREADONLY) || !expert_mode)) {
+ ((x.flags & LIBXFS_ISREADONLY) || !expert_mode)) {
dbprintf(_("%s not in expert mode, writing disabled\n"),
progname);
return 0;
struct xfs_buf_ops local_ops;
const struct xfs_buf_ops *stashed_ops = NULL;
- if (x.isreadonly & LIBXFS_ISREADONLY) {
+ if (x.flags & LIBXFS_ISREADONLY) {
dbprintf(_("%s started in read only mode, fuzzing disabled\n"),
progname);
return 0;
force = 1;
break;
case 'i':
- x.isreadonly = (LIBXFS_ISREADONLY|LIBXFS_ISINACTIVE);
+ x.flags = LIBXFS_ISREADONLY | LIBXFS_ISINACTIVE;
break;
case 'p':
progname = optarg;
break;
case 'r':
- x.isreadonly = LIBXFS_ISREADONLY;
+ x.flags = LIBXFS_ISREADONLY;
break;
case 'l':
x.logname = optarg;
usage();
x.dname = argv[optind];
- x.isdirect = LIBXFS_DIRECT;
+ x.flags |= LIBXFS_DIRECT;
x.bcache_flags = CACHE_MISCOMPARE_PURGE;
if (!libxfs_init(&x)) {
if (argc == 2) { /* WRITE UUID */
- if ((x.isreadonly & LIBXFS_ISREADONLY) || !expert_mode) {
+ if ((x.flags & LIBXFS_ISREADONLY) || !expert_mode) {
dbprintf(_("%s: not in expert mode, writing disabled\n"),
progname);
return 0;
if (argc == 2) { /* WRITE LABEL */
- if ((x.isreadonly & LIBXFS_ISREADONLY) || !expert_mode) {
+ if ((x.flags & LIBXFS_ISREADONLY) || !expert_mode) {
dbprintf(_("%s: not in expert mode, writing disabled\n"),
progname);
return 0;
if (argc == 2) { /* WRITE VERSION */
- if ((x.isreadonly & LIBXFS_ISREADONLY) || !expert_mode) {
+ if ((x.flags & LIBXFS_ISREADONLY) || !expert_mode) {
dbprintf(_("%s: not in expert mode, writing disabled\n"),
progname);
return 0;
struct xfs_buf_ops local_ops;
const struct xfs_buf_ops *stashed_ops = NULL;
- if (x.isreadonly & LIBXFS_ISREADONLY) {
+ if (x.flags & LIBXFS_ISREADONLY) {
dbprintf(_("%s started in read only mode, writing disabled\n"),
progname);
return 0;
xi.dname = datadev;
xi.logname = logdev;
xi.rtname = rtdev;
- xi.isreadonly = LIBXFS_ISREADONLY;
+ xi.flags = LIBXFS_ISREADONLY;
if (!libxfs_init(&xi))
usage();
char *dname; /* pathname of data "subvolume" */
char *logname; /* pathname of log "subvolume" */
char *rtname; /* pathname of realtime "subvolume" */
- int isreadonly; /* filesystem is only read in applic */
- int isdirect; /* we can attempt to use direct I/O */
+ unsigned flags; /* LIBXFS_* flags below */
int disfile; /* data "subvolume" is a regular file */
int dcreat; /* try to create data subvolume */
int lisfile; /* log "subvolume" is a regular file */
int risfile; /* realtime "subvolume" is a reg file */
int rcreat; /* try to create realtime subvolume */
int setblksize; /* attempt to set device blksize */
- int usebuflock; /* lock xfs_buf's - for MT usage */
/* output results */
dev_t ddev; /* device for data subvolume */
dev_t logdev; /* device for log subvolume */
int bcache_flags; /* cache init flags */
};
-#define LIBXFS_ISREADONLY 0x0002 /* disallow all mounted filesystems */
-#define LIBXFS_ISINACTIVE 0x0004 /* allow mounted only if mounted ro */
-#define LIBXFS_DANGEROUSLY 0x0008 /* repairing a device mounted ro */
-#define LIBXFS_EXCLUSIVELY 0x0010 /* disallow other accesses (O_EXCL) */
-#define LIBXFS_DIRECT 0x0020 /* can use direct I/O, not buffered */
+/* disallow all mounted filesystems: */
+#define LIBXFS_ISREADONLY (1U << 0)
+
+/* allow mounted only if mounted ro: */
+#define LIBXFS_ISINACTIVE (1U << 1)
+
+/* repairing a device mounted ro: */
+#define LIBXFS_DANGEROUSLY (1U << 2)
+
+/* disallow other accesses (O_EXCL): */
+#define LIBXFS_EXCLUSIVELY (1U << 3)
+
+/* can use direct I/O, not buffered: */
+#define LIBXFS_DIRECT (1U << 4)
+
+/* lock xfs_buf's - for MT usage */
+#define LIBXFS_USEBUFLOCK (1U << 5)
extern char *progname;
extern xfs_lsn_t libxfs_max_lsn;
char *dname;
char *logname;
char *rtname;
- int flags;
dname = a->dname;
logname = a->logname;
a->dsize = a->lbsize = a->rtbsize = 0;
a->dbsize = a->logBBsize = a->rtsize = 0;
- flags = (a->isreadonly | a->isdirect);
-
rcu_init();
rcu_register_thread();
radix_tree_init();
if (dname) {
- if (!a->disfile && !check_open(dname, flags))
+ if (!a->disfile && !check_open(dname, a->flags))
goto done;
- a->ddev = libxfs_device_open(dname, a->dcreat, flags,
+ a->ddev = libxfs_device_open(dname, a->dcreat, a->flags,
a->setblksize);
a->dfd = libxfs_device_to_fd(a->ddev);
platform_findsizes(dname, a->dfd, &a->dsize, &a->dbsize);
}
if (logname) {
- if (!a->lisfile && !check_open(logname, flags))
+ if (!a->lisfile && !check_open(logname, a->flags))
goto done;
- a->logdev = libxfs_device_open(logname, a->lcreat, flags,
+ a->logdev = libxfs_device_open(logname, a->lcreat, a->flags,
a->setblksize);
a->logfd = libxfs_device_to_fd(a->logdev);
platform_findsizes(logname, a->logfd, &a->logBBsize,
&a->lbsize);
}
if (rtname) {
- if (a->risfile && !check_open(rtname, flags))
+ if (a->risfile && !check_open(rtname, a->flags))
goto done;
- a->rtdev = libxfs_device_open(rtname, a->rcreat, flags,
+ a->rtdev = libxfs_device_open(rtname, a->rcreat, a->flags,
a->setblksize);
a->rtfd = libxfs_device_to_fd(a->rtdev);
platform_findsizes(dname, a->rtfd, &a->rtsize, &a->rtbsize);
libxfs_bhash_size = LIBXFS_BHASHSIZE(sbp);
libxfs_bcache = cache_init(a->bcache_flags, libxfs_bhash_size,
&libxfs_bcache_operations);
- use_xfs_buf_lock = a->usebuflock;
+ use_xfs_buf_lock = a->flags & LIBXFS_USEBUFLOCK;
xfs_dir_startup();
init_caches();
return 1;
if (x.dname == NULL)
usage();
- x.isreadonly = LIBXFS_ISINACTIVE;
+ x.flags = LIBXFS_ISINACTIVE;
printf(_("xfs_logprint:\n"));
if (!libxfs_init(&x))
exit(1);
* host filesystem.
*/
if (cli->xi->disfile || cli->xi->lisfile || cli->xi->risfile)
- cli->xi->isdirect = 0;
+ cli->xi->flags &= ~LIBXFS_DIRECT;
memset(ft, 0, sizeof(*ft));
get_topology(cli->xi, ft, force_overwrite);
int worst_freelist = 0;
struct libxfs_init xi = {
- .isdirect = LIBXFS_DIRECT,
- .isreadonly = LIBXFS_EXCLUSIVELY,
+ .flags = LIBXFS_EXCLUSIVELY | LIBXFS_DIRECT,
};
struct xfs_mount mbuf = {};
struct xfs_mount *mp = &mbuf;
/* XXX assume data file also means rt file */
}
- args->usebuflock = do_prefetch;
args->setblksize = 0;
- args->isdirect = LIBXFS_DIRECT;
if (no_modify)
- args->isreadonly = (LIBXFS_ISREADONLY | LIBXFS_ISINACTIVE);
+ args->flags = LIBXFS_ISREADONLY | LIBXFS_ISINACTIVE;
else if (dangerously)
- args->isreadonly = (LIBXFS_ISINACTIVE | LIBXFS_DANGEROUSLY);
+ args->flags = LIBXFS_ISINACTIVE | LIBXFS_DANGEROUSLY;
else
- args->isreadonly = LIBXFS_EXCLUSIVELY;
+ args->flags = LIBXFS_EXCLUSIVELY;
+ args->flags |= LIBXFS_DIRECT;
+ if (do_prefetch)
+ args->flags |= LIBXFS_USEBUFLOCK;
if (!libxfs_init(args)) {
/* would -d be an option? */
if (!no_modify && !dangerously) {
- args->isreadonly = (LIBXFS_ISINACTIVE |
- LIBXFS_DANGEROUSLY);
+ args->flags &= ~LIBXFS_EXCLUSIVELY;
+ args->flags |= LIBXFS_ISINACTIVE | LIBXFS_DANGEROUSLY;
if (libxfs_init(args))
fprintf(stderr,
_("Unmount or use the dangerous (-d) option to repair a read-only mounted filesystem\n"));