#include <sys/sysmacros.h>
#include "devtable.h"
+#include "ubifs.h"
#include "defs.h"
#include "hashtable/hashtable.h"
#include "hashtable/hashtable_itr.h"
*path = malloc(path_len + 1);
if (!*path)
- return err_msg("cannot allocate %d bytes of memory",
+ return errmsg("cannot allocate %d bytes of memory",
path_len + 1);
memcpy(*path, buf, path_len);
(*path)[path_len] = '\0';
*name = malloc(name_len + 1);
if (!*name) {
free(*path);
- return err_msg("cannot allocate %d bytes of memory",
+ return errmsg("cannot allocate %d bytes of memory",
name_len + 1);
}
memcpy(*name, n, name_len + 1);
if (sscanf(line, "%1023s %c %o %u %u %u %u %u %u %u",
buf, &type, &mode, &uid, &gid, &major, &minor,
&start, &increment, &count) < 0)
- return sys_err_msg("sscanf failed");
+ return sys_errmsg("sscanf failed");
dbg_msg(3, "name %s, type %c, mode %o, uid %u, gid %u, major %u, "
"minor %u, start %u, inc %u, cnt %u",
len = strnlen(buf, 1024);
if (len == 0)
- return err_msg("empty path");
+ return errmsg("empty path");
if (len == 1024)
- return err_msg("too long path");
+ return errmsg("too long path");
if (buf[0] != '/')
- return err_msg("device table entries require absolute paths");
+ return errmsg("device table entries require absolute paths");
if (strstr(buf, "//"))
- return err_msg("'//' cannot be used in the path");
+ return errmsg("'//' cannot be used in the path");
if (len > 1 && buf[len - 1] == '/')
- return err_msg("do not put '/' at the end");
+ return errmsg("do not put '/' at the end");
if (strstr(buf, "/./") || strstr(buf, "/../") ||
!strcmp(buf + len - 2, "/.") || !strcmp(buf + len - 3, "/.."))
- return err_msg("'.' and '..' cannot be used in the path");
+ return errmsg("'.' and '..' cannot be used in the path");
switch (type) {
case 'd':
case 'l':
mode |= S_IFLNK;
if ((mode & 0777) != 0777)
- return err_msg("link permission must be 0777");
+ return errmsg("link permission must be 0777");
break;
default:
- return err_msg("unsupported file type '%c'", type);
+ return errmsg("unsupported file type '%c'", type);
}
if (separate_last(buf, len, &path, &name))
dbg_msg(3, "inserting '%s' into path hash table", path);
ph_elt = malloc(sizeof(struct path_htbl_element));
if (!ph_elt) {
- err_msg("cannot allocate %zd bytes of memory",
+ errmsg("cannot allocate %zd bytes of memory",
sizeof(struct path_htbl_element));
goto out_free;
}
if (!hashtable_insert(path_htbl, path, ph_elt)) {
- err_msg("cannot insert into path hash table");
+ errmsg("cannot insert into path hash table");
goto out_free;
}
ph_elt->name_htbl = create_hashtable(128, &r5_hash,
&is_equivalent);
if (!ph_elt->name_htbl) {
- err_msg("cannot create name hash table");
+ errmsg("cannot create name hash table");
goto out_free;
}
}
if (increment != 0 && count == 0) {
- err_msg("count cannot be zero if increment is non-zero");
+ errmsg("count cannot be zero if increment is non-zero");
goto out_free;
}
/* This entry does not require any iterating */
nh_elt = malloc(sizeof(struct name_htbl_element));
if (!nh_elt) {
- err_msg("cannot allocate %zd bytes of memory",
+ errmsg("cannot allocate %zd bytes of memory",
sizeof(struct name_htbl_element));
goto out_free;
}
name, major(nh_elt->dev), minor(nh_elt->dev));
if (hashtable_search(ph_elt->name_htbl, name)) {
- err_msg("'%s' is referred twice", buf);
+ errmsg("'%s' is referred twice", buf);
goto out_free;
}
nh_elt->name = name;
if (!hashtable_insert(ph_elt->name_htbl, name, nh_elt)) {
- err_msg("cannot insert into name hash table");
+ errmsg("cannot insert into name hash table");
goto out_free;
}
} else {
for (i = start; i < num; i++) {
nh_elt = malloc(sizeof(struct name_htbl_element));
if (!nh_elt) {
- err_msg("cannot allocate %zd bytes of memory",
+ errmsg("cannot allocate %zd bytes of memory",
sizeof(struct name_htbl_element));
goto out_free;
}
nm = malloc(len);
if (!nm) {
- err_msg("cannot allocate %d bytes of memory", len);
+ errmsg("cannot allocate %d bytes of memory", len);
goto out_free;
}
nm, major(nh_elt->dev), minor(nh_elt->dev));
if (hashtable_search(ph_elt->name_htbl, nm)) {
- err_msg("'%s' is referred twice", buf);
+ errmsg("'%s' is referred twice", buf);
free (nm);
goto out_free;
}
if (!hashtable_insert(ph_elt->name_htbl, nm, nh_elt)) {
- err_msg("cannot insert into name hash table");
+ errmsg("cannot insert into name hash table");
free (nm);
goto out_free;
}
path_htbl = create_hashtable(128, &r5_hash, &is_equivalent);
if (!path_htbl)
- return err_msg("cannot create path hash table");
+ return errmsg("cannot create path hash table");
f = fopen(tbl_file, "r");
if (!f)
- return sys_err_msg("cannot open '%s'", tbl_file);
+ return sys_errmsg("cannot open '%s'", tbl_file);
if (fstat(fileno(f), &st) < 0) {
- sys_err_msg("cannot stat '%s'", tbl_file);
+ sys_errmsg("cannot stat '%s'", tbl_file);
goto out_close;
}
if (st.st_size < 10) {
- sys_err_msg("'%s' is too short", tbl_file);
+ sys_errmsg("'%s' is too short", tbl_file);
goto out_close;
}
/* If this is not a comment line, try to interpret it */
if (len && *line != '#') {
if (interpret_table_entry(line)) {
- err_msg("cannot parse '%s'", line);
+ errmsg("cannot parse '%s'", line);
goto out_close;
}
}
if (S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode) ||
S_ISFIFO(st->st_mode))
- return err_msg("%s/%s both exists at UBIFS root at host, "
+ return errmsg("%s/%s both exists at UBIFS root at host, "
"and is referred from the device table",
strcmp(ph_elt->path, "/") ? ph_elt->path : "",
nh_elt->name);
if ((st->st_mode & S_IFMT) != (nh_elt->mode & S_IFMT))
- return err_msg("%s/%s is referred from the device table also exists in "
+ return errmsg("%s/%s is referred from the device table also exists in "
"the UBIFS root directory at host, but the file type is "
"different", strcmp(ph_elt->path, "/") ? ph_elt->path : "",
nh_elt->name);
#include <zstd.h>
#endif
-/* common.h requires the PROGRAM_NAME macro */
-#define PROGRAM_NAME "mkfs.ubifs"
-#include "common.h"
#include "defs.h"
#include "crypto.h"
#include "fscrypt.h"
int tmp;
if (!output)
- return err_msg("no output file or UBI volume specified");
+ return errmsg("no output file or UBI volume specified");
if (root) {
tmp = is_contained(output, root);
if (tmp < 0)
- return err_msg("failed to perform output file root check");
+ return errmsg("failed to perform output file root check");
else if (tmp)
- return err_msg("output file cannot be in the UBIFS root "
+ return errmsg("output file cannot be in the UBIFS root "
"directory");
}
if (!is_power_of_2(c->min_io_size))
- return err_msg("min. I/O unit size should be power of 2");
+ return errmsg("min. I/O unit size should be power of 2");
if (c->leb_size < c->min_io_size)
- return err_msg("min. I/O unit cannot be larger than LEB size");
+ return errmsg("min. I/O unit cannot be larger than LEB size");
if (c->leb_size < UBIFS_MIN_LEB_SZ)
- return err_msg("too small LEB size %d, minimum is %d",
+ return errmsg("too small LEB size %d, minimum is %d",
c->leb_size, UBIFS_MIN_LEB_SZ);
if (c->leb_size % c->min_io_size)
- return err_msg("LEB should be multiple of min. I/O units");
+ return errmsg("LEB should be multiple of min. I/O units");
if (c->leb_size % 8)
- return err_msg("LEB size has to be multiple of 8");
+ return errmsg("LEB size has to be multiple of 8");
if (c->leb_size > UBIFS_MAX_LEB_SZ)
- return err_msg("too large LEB size %d, maximum is %d",
+ return errmsg("too large LEB size %d, maximum is %d",
c->leb_size, UBIFS_MAX_LEB_SZ);
if (c->max_leb_cnt < UBIFS_MIN_LEB_CNT)
- return err_msg("too low max. count of LEBs, minimum is %d",
+ return errmsg("too low max. count of LEBs, minimum is %d",
UBIFS_MIN_LEB_CNT);
if (c->fanout < UBIFS_MIN_FANOUT)
- return err_msg("too low fanout, minimum is %d",
+ return errmsg("too low fanout, minimum is %d",
UBIFS_MIN_FANOUT);
tmp = c->leb_size - UBIFS_IDX_NODE_SZ;
tmp /= UBIFS_BRANCH_SZ + UBIFS_MAX_KEY_LEN;
if (c->fanout > tmp)
- return err_msg("too high fanout, maximum is %d", tmp);
+ return errmsg("too high fanout, maximum is %d", tmp);
if (c->log_lebs < UBIFS_MIN_LOG_LEBS)
- return err_msg("too few log LEBs, minimum is %d",
+ return errmsg("too few log LEBs, minimum is %d",
UBIFS_MIN_LOG_LEBS);
if (c->log_lebs >= c->max_leb_cnt - UBIFS_MIN_LEB_CNT)
- return err_msg("too many log LEBs, maximum is %d",
+ return errmsg("too many log LEBs, maximum is %d",
c->max_leb_cnt - UBIFS_MIN_LEB_CNT);
if (c->orph_lebs < UBIFS_MIN_ORPH_LEBS)
- return err_msg("too few orphan LEBs, minimum is %d",
+ return errmsg("too few orphan LEBs, minimum is %d",
UBIFS_MIN_ORPH_LEBS);
if (c->orph_lebs >= c->max_leb_cnt - UBIFS_MIN_LEB_CNT)
- return err_msg("too many orphan LEBs, maximum is %d",
+ return errmsg("too many orphan LEBs, maximum is %d",
c->max_leb_cnt - UBIFS_MIN_LEB_CNT);
tmp = UBIFS_SB_LEBS + UBIFS_MST_LEBS + c->log_lebs + c->lpt_lebs;
tmp += c->orph_lebs + 4;
if (tmp > c->max_leb_cnt)
- return err_msg("too low max. count of LEBs, expected at "
+ return errmsg("too low max. count of LEBs, expected at "
"least %d", tmp);
tmp = calc_min_log_lebs(c->max_bud_bytes);
if (c->log_lebs < calc_min_log_lebs(c->max_bud_bytes))
- return err_msg("too few log LEBs, expected at least %d", tmp);
+ return errmsg("too few log LEBs, expected at least %d", tmp);
if (c->rp_size >= ((long long)c->leb_size * c->max_leb_cnt) / 2)
- return err_msg("too much reserved space %lld", c->rp_size);
+ return errmsg("too much reserved space %lld", c->rp_size);
return 0;
}
long long bytes = strtoull(str, &endp, 0);
if (endp == str || bytes < 0)
- return err_msg("incorrect amount of bytes: \"%s\"", str);
+ return errmsg("incorrect amount of bytes: \"%s\"", str);
if (*endp != '\0') {
int mult = get_multiplier(endp);
if (mult == -1)
- return err_msg("bad size specifier: \"%s\" - "
+ return errmsg("bad size specifier: \"%s\" - "
"should be 'KiB', 'MiB' or 'GiB'", endp);
bytes *= mult;
}
/* Make sure the root directory exists */
if (stat(root, &st))
- return sys_err_msg("bad root directory '%s'",
+ return sys_errmsg("bad root directory '%s'",
root);
break;
case 'm':
c->min_io_size = get_bytes(optarg);
if (c->min_io_size <= 0)
- return err_msg("bad min. I/O size");
+ return errmsg("bad min. I/O size");
break;
case 'e':
c->leb_size = get_bytes(optarg);
if (c->leb_size <= 0)
- return err_msg("bad LEB size");
+ return errmsg("bad LEB size");
break;
case 'c':
c->max_leb_cnt = get_bytes(optarg);
if (c->max_leb_cnt <= 0)
- return err_msg("bad maximum LEB count");
+ return errmsg("bad maximum LEB count");
break;
case 'o':
output = xstrdup(optarg);
case 'D':
tbl_file = optarg;
if (stat(tbl_file, &st) < 0)
- return sys_err_msg("bad device table file '%s'",
+ return sys_errmsg("bad device table file '%s'",
tbl_file);
break;
case 'y':
debug_level = strtol(optarg, &endp, 0);
if (*endp != '\0' || endp == optarg ||
debug_level < 0 || debug_level > 3)
- return err_msg("bad debugging level '%s'",
+ return errmsg("bad debugging level '%s'",
optarg);
break;
case 'f':
c->fanout = strtol(optarg, &endp, 0);
if (*endp != '\0' || endp == optarg || c->fanout <= 0)
- return err_msg("bad fanout %s", optarg);
+ return errmsg("bad fanout %s", optarg);
break;
case 'F':
c->space_fixup = 1;
case 'l':
c->log_lebs = strtol(optarg, &endp, 0);
if (*endp != '\0' || endp == optarg || c->log_lebs <= 0)
- return err_msg("bad count of log LEBs '%s'",
+ return errmsg("bad count of log LEBs '%s'",
optarg);
break;
case 'p':
c->orph_lebs = strtol(optarg, &endp, 0);
if (*endp != '\0' || endp == optarg ||
c->orph_lebs <= 0)
- return err_msg("bad orphan LEB count '%s'",
+ return errmsg("bad orphan LEB count '%s'",
optarg);
break;
case 'k':
c->key_hash = key_test_hash;
c->key_hash_type = UBIFS_KEY_HASH_TEST;
} else
- return err_msg("bad key hash");
+ return errmsg("bad key hash");
break;
case 'x':
if (strcmp(optarg, "none") == 0)
}
#endif
else
- return err_msg("bad compressor name");
+ return errmsg("bad compressor name");
break;
case 'X':
#if !defined(WITH_LZO) && !defined(WITH_ZLIB)
- return err_msg("built without LZO or ZLIB support");
+ return errmsg("built without LZO or ZLIB support");
#else
c->favor_percent = strtol(optarg, &endp, 0);
if (*endp != '\0' || endp == optarg ||
c->favor_percent <= 0 || c->favor_percent >= 100)
- return err_msg("bad favor LZO percent '%s'",
+ return errmsg("bad favor LZO percent '%s'",
optarg);
#endif
break;
case 'j':
c->max_bud_bytes = get_bytes(optarg);
if (c->max_bud_bytes <= 0)
- return err_msg("bad maximum amount of buds");
+ return errmsg("bad maximum amount of buds");
break;
case 'R':
c->rp_size = get_bytes(optarg);
if (c->rp_size < 0)
- return err_msg("bad reserved bytes count");
+ return errmsg("bad reserved bytes count");
break;
case 'U':
squash_owner = 1;
context_len = strlen(optarg);
context = (char *) xmalloc(context_len + 1);
if (!context)
- return err_msg("xmalloc failed\n");
+ return errmsg("xmalloc failed\n");
memcpy(context, optarg, context_len);
context[context_len] = '\0';
/* Make sure root directory exists */
if (stat(context, &context_st))
- return sys_err_msg("bad file context %s\n",
+ return sys_errmsg("bad file context %s\n",
context);
break;
case 'K':
if (key_file) {
- return err_msg("key file specified more than once");
+ return errmsg("key file specified more than once");
}
key_file = optarg;
break;
case 'b':
if (key_desc) {
- return err_msg("key descriptor specified more than once");
+ return errmsg("key descriptor specified more than once");
}
key_desc = optarg;
break;
case HASH_ALGO_OPTION:
case AUTH_KEY_OPTION:
case AUTH_CERT_OPTION:
- return err_msg("mkfs.ubifs was built without crypto support.");
+ return errmsg("mkfs.ubifs was built without crypto support.");
#endif
}
}
output = xstrdup(argv[optind]);
if (!output)
- return err_msg("not output device or file specified");
+ return errmsg("not output device or file specified");
out_ubi = !open_ubi(output);
if (key_file || key_desc) {
#ifdef WITH_CRYPTO
if (!key_file)
- return err_msg("no key file specified");
+ return errmsg("no key file specified");
c->double_hash = 1;
c->encrypted = 1;
if (!root_fctx)
return -1;
#else
- return err_msg("mkfs.ubifs was built without crypto support.");
+ return errmsg("mkfs.ubifs was built without crypto support.");
#endif
}
select_default_compr();
if (c->min_io_size == -1)
- return err_msg("min. I/O unit was not specified "
+ return errmsg("min. I/O unit was not specified "
"(use -h for help)");
if (c->leb_size == -1)
- return err_msg("LEB size was not specified (use -h for help)");
+ return errmsg("LEB size was not specified (use -h for help)");
if (c->max_leb_cnt == -1)
- return err_msg("Maximum count of LEBs was not specified "
+ return errmsg("Maximum count of LEBs was not specified "
"(use -h for help)");
if (c->max_bud_bytes == -1) {
return -1;
if (tbl_file && parse_devtable(tbl_file))
- return err_msg("cannot parse device table file '%s'", tbl_file);
+ return errmsg("cannot parse device table file '%s'", tbl_file);
return 0;
}
memset(buf + len, 0xff, c->leb_size - len);
if (out_ubi)
if (ubi_leb_change_start(ubi, out_fd, lnum, c->leb_size))
- return sys_err_msg("ubi_leb_change_start failed");
+ return sys_errmsg("ubi_leb_change_start failed");
if (lseek(out_fd, pos, SEEK_SET) != pos)
- return sys_err_msg("lseek failed seeking %lld", (long long)pos);
+ return sys_errmsg("lseek failed seeking %lld", (long long)pos);
if (write(out_fd, buf, c->leb_size) != c->leb_size)
- return sys_err_msg("write failed writing %d bytes at pos %lld",
+ return sys_errmsg("write failed writing %d bytes at pos %lld",
c->leb_size, (long long)pos);
return 0;
if (type == UBIFS_DENT_KEY || type == UBIFS_XENT_KEY) {
if (!name)
- return err_msg("Directory entry or xattr "
+ return errmsg("Directory entry or xattr "
"without name!");
} else {
if (name)
- return err_msg("Name given for non dir/xattr node!");
+ return errmsg("Name given for non dir/xattr node!");
}
prepare_node(node, len);
if (errno == ENOENT || errno == EOPNOTSUPP)
return 0;
- sys_err_msg("llistxattr failed on %s", path_name);
+ sys_errmsg("llistxattr failed on %s", path_name);
return len;
}
len = llistxattr(path_name, buf, len);
if (len < 0) {
- sys_err_msg("llistxattr failed on %s", path_name);
+ sys_errmsg("llistxattr failed on %s", path_name);
goto out_free;
}
attrsize = lgetxattr(path_name, name, attrbuf, sizeof(attrbuf) - 1);
if (attrsize < 0) {
- sys_err_msg("lgetxattr failed on %s", path_name);
+ sys_errmsg("lgetxattr failed on %s", path_name);
goto out_free;
}
inum_from_xattr = strtoull(attrbuf, NULL, 10);
if (inum != inum_from_xattr) {
errno = EINVAL;
- sys_err_msg("calculated inum (%llu) doesn't match inum from xattr (%llu) size (%zd) on %s",
+ sys_errmsg("calculated inum (%llu) doesn't match inum from xattr (%llu) size (%zd) on %s",
(unsigned long long)inum,
(unsigned long long)inum_from_xattr,
attrsize,
sepath = NULL;
if (!sepath)
- return sys_err_msg("could not get sepath\n");
+ return sys_errmsg("could not get sepath\n");
if (selabel_lookup(sehnd, &secontext, sepath, st->st_mode) < 0) {
/* Failed to lookup context, assume unlabeled */
} else {
/* TODO: what about device files? */
if (!S_ISLNK(st->st_mode))
- return err_msg("Expected symlink");
+ return errmsg("Expected symlink");
ret = encrypt_symlink(&ino->data, data, data_len, fctx);
if (ret < 0)
if (dir) {
fd = dirfd(dir);
if (fd == -1)
- return sys_err_msg("dirfd failed");
+ return sys_errmsg("dirfd failed");
if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1)
flags = 0;
}
/* Take the symlink as is */
len = readlink(path_name, buf, UBIFS_MAX_INO_DATA + 1);
if (len <= 0)
- return sys_err_msg("readlink failed for %s", path_name);
+ return sys_errmsg("readlink failed for %s", path_name);
if (len > UBIFS_MAX_INO_DATA)
- return err_msg("symlink too long for %s", path_name);
+ return errmsg("symlink too long for %s", path_name);
return add_inode(st, inum, buf, len, flags, path_name, fctx);
}
*kname_len = dname.len;
kname = strdup(name);
if (!kname)
- return err_msg("cannot allocate memory");
+ return errmsg("cannot allocate memory");
} else {
unsigned int max_namelen = UBIFS_MAX_NLEN;
int ret;
fd = open(path_name, O_RDONLY | O_LARGEFILE);
if (fd == -1)
- return sys_err_msg("failed to open file '%s'", path_name);
+ return sys_errmsg("failed to open file '%s'", path_name);
do {
/* Read next block */
bytes_read = 0;
ret = read(fd, buf + bytes_read,
UBIFS_BLOCK_SIZE - bytes_read);
if (ret == -1) {
- sys_err_msg("failed to read file '%s'",
+ sys_errmsg("failed to read file '%s'",
path_name);
close(fd);
return 1;
} while (ret != 0);
if (close(fd) == -1)
- return sys_err_msg("failed to close file '%s'", path_name);
+ return sys_errmsg("failed to close file '%s'", path_name);
if (file_size != st->st_size)
- return err_msg("file size changed during writing file '%s'",
+ return errmsg("file size changed during writing file '%s'",
path_name);
return add_inode(st, inum, NULL, 0, flags, path_name, fctx);
if (S_ISREG(st->st_mode)) {
fd = open(path_name, O_RDONLY);
if (fd == -1)
- return sys_err_msg("failed to open file '%s'",
+ return sys_errmsg("failed to open file '%s'",
path_name);
if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1)
flags = 0;
if (close(fd) == -1)
- return sys_err_msg("failed to close file '%s'",
+ return sys_errmsg("failed to close file '%s'",
path_name);
*type = UBIFS_ITYPE_REG;
} else if (S_ISCHR(st->st_mode))
else if (S_ISFIFO(st->st_mode))
*type = UBIFS_ITYPE_FIFO;
else
- return err_msg("file '%s' has unknown inode type", path_name);
+ return errmsg("file '%s' has unknown inode type", path_name);
if (nlink)
st->st_nlink = nlink;
im = lookup_inum_mapping(st->st_dev, st->st_ino);
if (!im)
- return err_msg("out of memory");
+ return errmsg("out of memory");
if (im->use_nlink == 0) {
/* New entry */
im->use_inum = *inum;
if (S_ISFIFO(st->st_mode))
return add_inode(st, *inum, NULL, 0, flags, NULL, NULL);
- return err_msg("file '%s' has unknown inode type", path_name);
+ return errmsg("file '%s' has unknown inode type", path_name);
}
/**
if (existing) {
dir = opendir(dir_name);
if (dir == NULL)
- return sys_err_msg("cannot open directory '%s'",
+ return sys_errmsg("cannot open directory '%s'",
dir_name);
}
if (!entry) {
if (errno == 0)
break;
- sys_err_msg("error reading directory '%s'", dir_name);
+ sys_errmsg("error reading directory '%s'", dir_name);
goto out_free;
}
free(name);
name = make_path(dir_name, entry->d_name);
if (lstat(name, &dent_st) == -1) {
- sys_err_msg("lstat failed for file '%s'", name);
+ sys_errmsg("lstat failed for file '%s'", name);
goto out_free;
}
* files.
*/
if (S_ISREG(nh_elt->mode)) {
- err_msg("Bad device table entry %s/%s - it is "
+ errmsg("Bad device table entry %s/%s - it is "
"prohibited to create regular files "
"via device table",
strcmp(ph_elt->path, "/") ? ph_elt->path : "",
free(name);
if (existing && closedir(dir) == -1)
- return sys_err_msg("error closing directory '%s'", dir_name);
+ return sys_errmsg("error closing directory '%s'", dir_name);
return 0;
if (root) {
err = stat(root, &root_st);
if (err)
- return sys_err_msg("bad root file-system directory '%s'",
+ return sys_errmsg("bad root file-system directory '%s'",
root);
if (squash_owner)
root_st.st_uid = root_st.st_gid = 0;
sz = idx_cnt * sizeof(struct idx_entry *);
if (sz / sizeof(struct idx_entry *) != idx_cnt) {
free(idx);
- return err_msg("index is too big (%zu entries)", idx_cnt);
+ return errmsg("index is too big (%zu entries)", idx_cnt);
}
idx_ptr = xmalloc(sz);
idx_ptr[0] = idx_list_first;
{
c->leb_cnt = head_lnum;
if (c->leb_cnt > c->max_leb_cnt)
- return err_msg("max_leb_cnt too low (%d needed)", c->leb_cnt);
+ return errmsg("max_leb_cnt too low (%d needed)", c->leb_cnt);
c->main_lebs = c->leb_cnt - c->main_first;
if (verbose) {
printf("\tsuper lebs: %d\n", UBIFS_SB_LEBS);
out_fd = open(output, O_RDWR | O_EXCL);
if (out_fd == -1)
- return sys_err_msg("cannot open the UBI volume '%s'",
+ return sys_errmsg("cannot open the UBI volume '%s'",
output);
if (ubi_set_property(out_fd, UBI_VOL_PROP_DIRECT_WRITE, 1)) {
close(out_fd);
- return sys_err_msg("ubi_set_property(set direct_write) failed");
+ return sys_errmsg("ubi_set_property(set direct_write) failed");
}
if (!yes && check_volume_empty()) {
if (!prompt("UBI volume is not empty. Format anyways?", false)) {
close(out_fd);
- return err_msg("UBI volume is not empty");
+ return errmsg("UBI volume is not empty");
}
}
} else {
out_fd = open(output, O_CREAT | O_RDWR | O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
if (out_fd == -1)
- return sys_err_msg("cannot create output file '%s'",
+ return sys_errmsg("cannot create output file '%s'",
output);
}
return 0;
{
if (out_fd >= 0) {
if (ubi && ubi_set_property(out_fd, UBI_VOL_PROP_DIRECT_WRITE, 0))
- return sys_err_msg("ubi_set_property(clear direct_write) failed");
+ return sys_errmsg("ubi_set_property(clear direct_write) failed");
if (close(out_fd) == -1)
- return sys_err_msg("cannot close the target '%s'", output);
+ return sys_errmsg("cannot close the target '%s'", output);
}
return 0;
}
sehnd = selabel_open(SELABEL_CTX_FILE, seopts, 1);
if (!sehnd)
- return err_msg("could not open selinux context\n");
+ return errmsg("could not open selinux context\n");
}
#endif