#include "strutils.h"
#include "xalloc.h"
#include "bitops.h"
+#include "exitcodes.h"
#define BFS_ROOT_INO 2
#define BFS_NAMELEN 14
" -v, --verbose explain what is being done\n"
" -c this option is silently ignored\n"
" -l this option is silently ignored\n"
+ " --lock=[=<mode>] use exclusive device lock (yes, no or nonblock)\n"
));
printf(USAGE_HELP_OPTIONS(21));
int main(int argc, char **argv)
{
char *device, *volume, *fsname;
+ char *lockmode = 0;
long inodes;
unsigned long long total_blocks, ino_bytes, ino_blocks, data_blocks;
unsigned long long user_specified_total_blocks = 0;
time_t now;
int c, i, len;
- enum { VERSION_OPTION = CHAR_MAX + 1 };
+ enum {
+ VERSION_OPTION = CHAR_MAX + 1,
+ OPT_LOCK
+ };
static const struct option longopts[] = {
{"inodes", required_argument, NULL, 'N'},
{"vname", required_argument, NULL, 'V'},
{"verbose", no_argument, NULL, 'v'},
{"version", no_argument, NULL, VERSION_OPTION},
{"help", no_argument, NULL, 'h'},
+ {"lock", optional_argument, NULL, OPT_LOCK},
{NULL, 0, NULL, 0}
};
/* when called via mkfs we may get options c,l,v */
break;
+ case OPT_LOCK:
+ lockmode = "1";
+ if (optarg) {
+ if (*optarg == '=')
+ optarg++;
+ lockmode = optarg;
+ }
+ break;
+
case VERSION_OPTION:
print_version(EXIT_SUCCESS);
case 'h':
if (fd < 0)
err(EXIT_FAILURE, _("cannot open %s"), device);
+ if (blkdev_lock(fd, device, lockmode) != 0)
+ exit(MKFS_EX_ERROR);
+
if (optind == argc - 1)
user_specified_total_blocks =
strtou64_or_err(argv[optind], _("invalid block-count"));