mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
@@ -37,7 +37,6 @@ int name_to_handle_at_loop(
|
||||
int *ret_mnt_id,
|
||||
int flags) {
|
||||
|
||||
_cleanup_free_ struct file_handle *h = NULL;
|
||||
size_t n = ORIGINAL_MAX_HANDLE_SZ;
|
||||
|
||||
assert((flags & ~(AT_SYMLINK_FOLLOW|AT_EMPTY_PATH)) == 0);
|
||||
@@ -50,6 +49,7 @@ int name_to_handle_at_loop(
|
||||
* as NULL if there's no interest in either. */
|
||||
|
||||
for (;;) {
|
||||
_cleanup_free_ struct file_handle *h = NULL;
|
||||
int mnt_id = -1;
|
||||
|
||||
h = malloc0(offsetof(struct file_handle, f_handle) + n);
|
||||
@@ -91,8 +91,6 @@ int name_to_handle_at_loop(
|
||||
n = h->handle_bytes;
|
||||
if (offsetof(struct file_handle, f_handle) + n < n) /* check for addition overflow */
|
||||
return -EOVERFLOW;
|
||||
|
||||
h = mfree(h);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
bool ratelimit_below(RateLimit *r) {
|
||||
usec_t ts;
|
||||
bool good = false;
|
||||
|
||||
assert(r);
|
||||
|
||||
@@ -24,18 +25,12 @@ bool ratelimit_below(RateLimit *r) {
|
||||
|
||||
/* Reset counter */
|
||||
r->num = 0;
|
||||
goto good;
|
||||
}
|
||||
|
||||
if (r->num < r->burst)
|
||||
goto good;
|
||||
good = true;
|
||||
} else if (r->num < r->burst)
|
||||
good = true;
|
||||
|
||||
r->num++;
|
||||
return false;
|
||||
|
||||
good:
|
||||
r->num++;
|
||||
return true;
|
||||
return good;
|
||||
}
|
||||
|
||||
unsigned ratelimit_num_dropped(RateLimit *r) {
|
||||
|
||||
@@ -676,7 +676,7 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
|
||||
}
|
||||
|
||||
int parse_xml_introspect(const char *prefix, const char *xml, const XMLIntrospectOps *ops, void *userdata) {
|
||||
Context context = {
|
||||
_cleanup_(context_reset_interface) Context context = {
|
||||
.ops = ops,
|
||||
.userdata = userdata,
|
||||
.current = xml,
|
||||
@@ -692,36 +692,24 @@ int parse_xml_introspect(const char *prefix, const char *xml, const XMLIntrospec
|
||||
_cleanup_free_ char *name = NULL;
|
||||
|
||||
r = xml_tokenize(&context.current, &name, &context.xml_state, NULL);
|
||||
if (r < 0) {
|
||||
log_error("XML parse error");
|
||||
goto finish;
|
||||
}
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "XML parse error");
|
||||
|
||||
if (r == XML_END) {
|
||||
r = 0;
|
||||
if (r == XML_END)
|
||||
break;
|
||||
}
|
||||
|
||||
if (r == XML_TAG_OPEN) {
|
||||
|
||||
if (streq(name, "node")) {
|
||||
r = parse_xml_node(&context, prefix, 0);
|
||||
if (r < 0)
|
||||
goto finish;
|
||||
} else {
|
||||
log_error("Unexpected tag '%s' in introspection data.", name);
|
||||
r = -EBADMSG;
|
||||
goto finish;
|
||||
}
|
||||
} else if (r != XML_TEXT || !in_charset(name, WHITESPACE)) {
|
||||
log_error("Unexpected token.");
|
||||
r = -EBADMSG;
|
||||
goto finish;
|
||||
}
|
||||
return r;
|
||||
} else
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Unexpected tag '%s' in introspection data.", name);
|
||||
} else if (r != XML_TEXT || !in_charset(name, WHITESPACE))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EBADMSG), "Unexpected token.");
|
||||
}
|
||||
|
||||
finish:
|
||||
context_reset_interface(&context);
|
||||
|
||||
return r;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ int vconsole_write_data(Context *c) {
|
||||
|
||||
int x11_write_data(Context *c) {
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
_cleanup_free_ char *temp_path = NULL;
|
||||
_cleanup_(unlink_and_freep) char *temp_path = NULL;
|
||||
struct stat st;
|
||||
int r;
|
||||
|
||||
@@ -300,23 +300,15 @@ int x11_write_data(Context *c) {
|
||||
|
||||
r = fflush_sync_and_check(f);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
return r;
|
||||
|
||||
if (rename(temp_path, "/etc/X11/xorg.conf.d/00-keyboard.conf") < 0) {
|
||||
r = -errno;
|
||||
goto fail;
|
||||
}
|
||||
if (rename(temp_path, "/etc/X11/xorg.conf.d/00-keyboard.conf") < 0)
|
||||
return -errno;
|
||||
|
||||
if (stat("/etc/X11/xorg.conf.d/00-keyboard.conf", &st) >= 0)
|
||||
c->x11_mtime = timespec_load(&st.st_mtim);
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
if (temp_path)
|
||||
(void) unlink(temp_path);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int read_next_mapping(const char* filename,
|
||||
|
||||
@@ -33,12 +33,16 @@
|
||||
#include "unit-name.h"
|
||||
#include "user-util.h"
|
||||
|
||||
Machine* machine_new(Manager *manager, MachineClass class, const char *name) {
|
||||
Machine *m;
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(Machine*, machine_free);
|
||||
|
||||
int machine_new(Manager *manager, MachineClass class, const char *name, Machine **ret) {
|
||||
_cleanup_(machine_freep) Machine *m = NULL;
|
||||
int r;
|
||||
|
||||
assert(manager);
|
||||
assert(class < _MACHINE_CLASS_MAX);
|
||||
assert(name);
|
||||
assert(ret);
|
||||
|
||||
/* Passing class == _MACHINE_CLASS_INVALID here is fine. It
|
||||
* means as much as "we don't know yet", and that we'll figure
|
||||
@@ -46,31 +50,28 @@ Machine* machine_new(Manager *manager, MachineClass class, const char *name) {
|
||||
|
||||
m = new0(Machine, 1);
|
||||
if (!m)
|
||||
return NULL;
|
||||
return -ENOMEM;
|
||||
|
||||
m->name = strdup(name);
|
||||
if (!m->name)
|
||||
goto fail;
|
||||
return -ENOMEM;
|
||||
|
||||
if (class != MACHINE_HOST) {
|
||||
m->state_file = path_join("/run/systemd/machines", m->name);
|
||||
if (!m->state_file)
|
||||
goto fail;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
m->class = class;
|
||||
|
||||
if (hashmap_put(manager->machines, m->name, m) < 0)
|
||||
goto fail;
|
||||
r = hashmap_put(manager->machines, m->name, m);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
m->manager = manager;
|
||||
|
||||
return m;
|
||||
|
||||
fail:
|
||||
free(m->state_file);
|
||||
free(m->name);
|
||||
return mfree(m);
|
||||
*ret = TAKE_PTR(m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Machine* machine_free(Machine *m) {
|
||||
|
||||
@@ -66,7 +66,7 @@ struct Machine {
|
||||
LIST_FIELDS(Machine, gc_queue);
|
||||
};
|
||||
|
||||
Machine* machine_new(Manager *manager, MachineClass class, const char *name);
|
||||
int machine_new(Manager *manager, MachineClass class, const char *name, Machine **ret);
|
||||
Machine* machine_free(Machine *m);
|
||||
bool machine_may_gc(Machine *m, bool drop_not_started);
|
||||
void machine_add_to_gc_queue(Machine *m);
|
||||
|
||||
@@ -1492,15 +1492,16 @@ int manager_get_machine_by_pid(Manager *m, pid_t pid, Machine **machine) {
|
||||
|
||||
int manager_add_machine(Manager *m, const char *name, Machine **_machine) {
|
||||
Machine *machine;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
assert(name);
|
||||
|
||||
machine = hashmap_get(m->machines, name);
|
||||
if (!machine) {
|
||||
machine = machine_new(m, _MACHINE_CLASS_INVALID, name);
|
||||
if (!machine)
|
||||
return -ENOMEM;
|
||||
r = machine_new(m, _MACHINE_CLASS_INVALID, name, &machine);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (_machine)
|
||||
|
||||
@@ -117,9 +117,9 @@ static int manager_add_host_machine(Manager *m) {
|
||||
if (!unit)
|
||||
return log_oom();
|
||||
|
||||
t = machine_new(m, MACHINE_HOST, ".host");
|
||||
if (!t)
|
||||
return log_oom();
|
||||
r = machine_new(m, MACHINE_HOST, ".host", &t);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to create machine: %m");
|
||||
|
||||
t->leader = 1;
|
||||
t->id = mid;
|
||||
|
||||
@@ -511,10 +511,7 @@ int btrfs_subvol_get_info_fd(int fd, uint64_t subvol_id, BtrfsSubvolInfo *ret) {
|
||||
}
|
||||
|
||||
finish:
|
||||
if (!found)
|
||||
return -ENODATA;
|
||||
|
||||
return 0;
|
||||
return found ? 0 : -ENODATA;
|
||||
}
|
||||
|
||||
int btrfs_qgroup_get_quota_fd(int fd, uint64_t qgroupid, BtrfsQuotaInfo *ret) {
|
||||
|
||||
Reference in New Issue
Block a user