*-z*::
Make explicit holes.
+*-l*\fR[=\fImode\fR]::
+ Use exclusive BSD lock for device or file it operates. The optional argument
+ \fImode\fP can be \fByes\fR, \fBno\fR (or 1 and 0) or \fBnonblock\fR. If the \fImode\fR
+ argument is omitted, it defaults to \fB"yes"\fR. This option overwrites
+ environment variable \fB$LOCK_BLOCK_DEVICE\fR. The default is not to use any
+ lock at all, but it's recommended to avoid collisions with udevd or other
+ tools.
+ .TP
+
include::man-common/help-version.adoc[]
== EXIT STATUS
*/
#include <zlib.h>
+#include "blkdev.h"
#include "c.h"
#include "cramfs.h"
#include "md5.h"
printf(_(" -p pad by %d bytes for boot code\n"), PAD_SIZE);
puts(_( " -s sort directory entries (old option, ignored)"));
puts(_( " -z make explicit holes"));
+ puts(_( " -l lockmode use exclusive device lock (yes, no or nonblock)"));
puts(_( " dirname root of the filesystem to be compressed"));
puts(_( " outfile output file"));
fputs(USAGE_SEPARATOR, stdout);
loff_t fslen_ub = sizeof(struct cramfs_super);
unsigned int fslen_max;
char const *dirname, *outfile;
+ char *lockmode = 0;
uint32_t crc = crc32(0L, NULL, 0);
int c;
cramfs_is_big_endian = HOST_IS_BIG_ENDIAN; /* default is to use host order */
strutils_set_exitcode(MKFS_EX_USAGE);
/* command line options */
- while ((c = getopt(argc, argv, "hb:Ee:i:n:N:psVvz")) != EOF) {
+ while ((c = getopt(argc, argv, "hb:Ee:i:n:N:l:psVvz")) != EOF) {
switch (c) {
case 'h':
usage();
image_length = st.st_size; /* may be padded later */
fslen_ub += (image_length + 3); /* 3 is for padding */
break;
+ case 'l':
+ lockmode = "1";
+ if (optarg) {
+ if (*optarg == '=')
+ optarg++;
+ lockmode = optarg;
+ }
+ break;
case 'n':
opt_name = optarg;
break;
if (fd < 0)
err(MKFS_EX_USAGE, _("cannot open %s"), outfile);
+ if (blkdev_lock(fd, outfile, lockmode) != 0)
+ exit(MKFS_EX_ERROR);
+
root_entry = xcalloc(1, sizeof(struct entry));
root_entry->mode = st.st_mode;
root_entry->uid = st.st_uid;