various: use _NEG_ macros to reduce indentation
No functional change intended.
This commit is contained in:
@@ -285,11 +285,10 @@ int home_resize_directory(
|
||||
return r;
|
||||
|
||||
r = home_update_quota_auto(h, NULL);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_NOT_SUPPORTED(r))
|
||||
return -ESOCKTNOSUPPORT; /* make recognizable */
|
||||
if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
|
||||
return -ESOCKTNOSUPPORT; /* make recognizable */
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
r = home_store_embedded_identity(new_home, setup->root_fd, h->uid, embedded_home);
|
||||
if (r < 0)
|
||||
|
||||
+11
-14
@@ -498,11 +498,10 @@ static int acquire_open_luks_device(
|
||||
return r;
|
||||
|
||||
r = sym_crypt_init_by_name(&cd, setup->dm_name);
|
||||
if (r < 0) {
|
||||
if ((ERRNO_IS_DEVICE_ABSENT(r) || r == -EINVAL) && graceful)
|
||||
return 0;
|
||||
if ((ERRNO_IS_NEG_DEVICE_ABSENT(r) || r == -EINVAL) && graceful)
|
||||
return 0;
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to initialize cryptsetup context for %s: %m", setup->dm_name);
|
||||
}
|
||||
|
||||
cryptsetup_enable_logging(cd);
|
||||
|
||||
@@ -1639,12 +1638,11 @@ int home_deactivate_luks(UserRecord *h, HomeSetup *setup) {
|
||||
cryptsetup_enable_logging(setup->crypt_device);
|
||||
|
||||
r = sym_crypt_deactivate_by_name(setup->crypt_device, setup->dm_name, 0);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_DEVICE_ABSENT(r) || r == -EINVAL)
|
||||
log_debug_errno(r, "LUKS device %s is already detached.", setup->dm_node);
|
||||
else
|
||||
return log_info_errno(r, "LUKS device %s couldn't be deactivated: %m", setup->dm_node);
|
||||
} else {
|
||||
if (ERRNO_IS_NEG_DEVICE_ABSENT(r) || r == -EINVAL)
|
||||
log_debug_errno(r, "LUKS device %s is already detached.", setup->dm_node);
|
||||
else if (r < 0)
|
||||
return log_info_errno(r, "LUKS device %s couldn't be deactivated: %m", setup->dm_node);
|
||||
else {
|
||||
log_info("LUKS device detaching completed.");
|
||||
we_detached = true;
|
||||
}
|
||||
@@ -2026,11 +2024,10 @@ static int wait_for_devlink(const char *path) {
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ETIMEDOUT), "Device link %s still hasn't shown up, giving up.", path);
|
||||
|
||||
r = fd_wait_for_event(inotify_fd, POLLIN, until - w);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_TRANSIENT(r))
|
||||
continue;
|
||||
if (ERRNO_IS_NEG_TRANSIENT(r))
|
||||
continue;
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to watch inotify: %m");
|
||||
}
|
||||
|
||||
(void) flush_fd(inotify_fd);
|
||||
}
|
||||
|
||||
+11
-17
@@ -55,32 +55,26 @@ int home_update_quota_classic(UserRecord *h, const char *path) {
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENODEV), "File system %s not backed by a block device.", path);
|
||||
|
||||
r = quotactl_devnum(QCMD_FIXED(Q_GETQUOTA, USRQUOTA), devno, h->uid, &req);
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_NOT_SUPPORTED(r))
|
||||
return log_error_errno(r, "No UID quota support on %s.", path);
|
||||
|
||||
if (r != -ESRCH)
|
||||
return log_error_errno(r, "Failed to query disk quota for UID " UID_FMT ": %m", h->uid);
|
||||
|
||||
if (r == -ESRCH)
|
||||
zero(req);
|
||||
} else {
|
||||
else if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
|
||||
return log_error_errno(r, "No UID quota support on %s.", path);
|
||||
else if (r < 0)
|
||||
return log_error_errno(r, "Failed to query disk quota for UID " UID_FMT ": %m", h->uid);
|
||||
else if (FLAGS_SET(req.dqb_valid, QIF_BLIMITS) && h->disk_size / QIF_DQBLKSIZE == req.dqb_bhardlimit) {
|
||||
/* Shortcut things if everything is set up properly already */
|
||||
if (FLAGS_SET(req.dqb_valid, QIF_BLIMITS) && h->disk_size / QIF_DQBLKSIZE == req.dqb_bhardlimit) {
|
||||
log_info("Configured quota already matches the intended setting, not updating quota.");
|
||||
return 0;
|
||||
}
|
||||
log_info("Configured quota already matches the intended setting, not updating quota.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
req.dqb_valid = QIF_BLIMITS;
|
||||
req.dqb_bsoftlimit = req.dqb_bhardlimit = h->disk_size / QIF_DQBLKSIZE;
|
||||
|
||||
r = quotactl_devnum(QCMD_FIXED(Q_SETQUOTA, USRQUOTA), devno, h->uid, &req);
|
||||
if (r < 0) {
|
||||
if (r == -ESRCH)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENOTTY), "UID quota not available on %s.", path);
|
||||
|
||||
if (r == -ESRCH)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENOTTY), "UID quota not available on %s.", path);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to set disk quota for UID " UID_FMT ": %m", h->uid);
|
||||
}
|
||||
|
||||
log_info("Updated per-UID quota.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user