}
int run_mark_dirty_by_path(const char *path, bool b) {
- _cleanup_close_ int fd = -1;
+ _cleanup_close_ int fd = -EBADF;
assert(path);
}
static int probe_file_system_by_path(const char *path, char **ret_fstype, sd_id128_t *ret_uuid) {
- _cleanup_close_ int fd = -1;
+ _cleanup_close_ int fd = -EBADF;
fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
if (fd < 0)
}
static int block_get_size_by_path(const char *path, uint64_t *ret) {
- _cleanup_close_ int fd = -1;
+ _cleanup_close_ int fd = -EBADF;
fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
if (fd < 0)
}
int run_fallocate_by_path(const char *backing_path) {
- _cleanup_close_ int backing_fd = -1;
+ _cleanup_close_ int backing_fd = -EBADF;
backing_fd = open(backing_path, O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
if (backing_fd < 0)
const char *force_image_path,
struct stat *ret_stat) {
- _cleanup_close_ int image_fd = -1;
+ _cleanup_close_ int image_fd = -EBADF;
struct stat st;
const char *ip;
int r;
assert(buffer);
assert(hr);
+ bool benchmark = user_record_luks_pbkdf_force_iterations(hr) == UINT64_MAX;
+
*buffer = (struct crypt_pbkdf_type) {
.hash = user_record_luks_pbkdf_hash_algorithm(hr),
.type = user_record_luks_pbkdf_type(hr),
- .time_ms = user_record_luks_pbkdf_time_cost_usec(hr) / USEC_PER_MSEC,
+ .time_ms = benchmark ? user_record_luks_pbkdf_time_cost_usec(hr) / USEC_PER_MSEC : 0,
+ .iterations = benchmark ? 0 : user_record_luks_pbkdf_force_iterations(hr),
.max_memory_kb = user_record_luks_pbkdf_memory_cost(hr) / 1024,
.parallel_threads = user_record_luks_pbkdf_parallel_threads(hr),
+ .flags = benchmark ? 0 : CRYPT_PBKDF_NO_BENCHMARK,
};
return buffer;
}
static int wait_for_devlink(const char *path) {
- _cleanup_close_ int inotify_fd = -1;
+ _cleanup_close_ int inotify_fd = -EBADF;
usec_t until;
int r;
return !trunc; /* Return == 0 if we managed to truncate, > 0 if we managed to allocate */
}
+static int mkfs_options_for_fstype(const char *fstype, char ***ret) {
+ _cleanup_(strv_freep) char **l = NULL;
+ const char *e;
+ char *n;
+
+ assert(fstype);
+
+ n = strjoina("SYSTEMD_HOME_MKFS_OPTIONS_", fstype);
+ e = getenv(ascii_strupper(n));
+ if (e) {
+ l = strv_split(e, NULL);
+ if (!l)
+ return -ENOMEM;
+ }
+
+ *ret = TAKE_PTR(l);
+ return 0;
+}
+
int home_create_luks(
UserRecord *h,
HomeSetup *setup,
host_size = 0, partition_offset = 0, partition_size = 0; /* Unnecessary initialization to appease gcc */
_cleanup_(user_record_unrefp) UserRecord *new_home = NULL;
sd_id128_t partition_uuid, fs_uuid, luks_uuid, disk_uuid;
- _cleanup_close_ int mount_fd = -1;
+ _cleanup_close_ int mount_fd = -EBADF;
const char *fstype, *ip;
struct statfs sfs;
int r;
+ _cleanup_strv_free_ char **extra_mkfs_options = NULL;
assert(h);
assert(h->storage < 0 || h->storage == USER_LUKS);
log_info("Setting up LUKS device %s completed.", setup->dm_node);
- r = make_filesystem(setup->dm_node, fstype, user_record_user_name_and_realm(h), NULL, fs_uuid, user_record_luks_discard(h));
+ r = mkfs_options_for_fstype(fstype, &extra_mkfs_options);
+ if (r < 0)
+ return log_error_errno(r, "Failed to determine mkfs command line options for '%s': %m", fstype);
+ r = make_filesystem(setup->dm_node, fstype, user_record_user_name_and_realm(h), NULL, fs_uuid, user_record_luks_discard(h), extra_mkfs_options);
if (r < 0)
return r;
_cleanup_(user_record_unrefp) UserRecord *header_home = NULL, *embedded_home = NULL, *new_home = NULL;
_cleanup_(fdisk_unref_tablep) struct fdisk_table *table = NULL;
struct fdisk_partition *partition = NULL;
- _cleanup_close_ int opened_image_fd = -1;
+ _cleanup_close_ int opened_image_fd = -EBADF;
_cleanup_free_ char *whole_disk = NULL;
- int r, resize_type, image_fd = -1;
+ int r, resize_type, image_fd = -EBADF;
sd_id128_t disk_uuid;
const char *ip, *ipo;
struct statfs sfs;