Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src/udev: restore needed deps from src/share
- Loading branch information
Showing
20 changed files
with
11,160 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ | ||
|
||
#pragma once | ||
|
||
/*** | ||
This file is part of systemd. | ||
Copyright 2010 Lennart Poettering | ||
systemd is free software; you can redistribute it and/or modify it | ||
under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation; either version 2.1 of the License, or | ||
(at your option) any later version. | ||
systemd is distributed in the hope that it will be useful, but | ||
WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with systemd; If not, see <http://www.gnu.org/licenses/>. | ||
***/ | ||
|
||
#include <sys/types.h> | ||
#include <stdio.h> | ||
#include <dirent.h> | ||
|
||
#include "set.h" | ||
#include "def.h" | ||
|
||
int cg_enumerate_processes(const char *controller, const char *path, FILE **_f); | ||
int cg_enumerate_tasks(const char *controller, const char *path, FILE **_f); | ||
int cg_read_pid(FILE *f, pid_t *_pid); | ||
|
||
int cg_enumerate_subgroups(const char *controller, const char *path, DIR **_d); | ||
int cg_read_subgroup(DIR *d, char **fn); | ||
|
||
int cg_kill(const char *controller, const char *path, int sig, bool sigcont, bool ignore_self, Set *s); | ||
int cg_kill_recursive(const char *controller, const char *path, int sig, bool sigcont, bool ignore_self, bool remove, Set *s); | ||
int cg_kill_recursive_and_wait(const char *controller, const char *path, bool remove); | ||
|
||
int cg_migrate(const char *controller, const char *from, const char *to, bool ignore_self); | ||
int cg_migrate_recursive(const char *controller, const char *from, const char *to, bool ignore_self, bool remove); | ||
|
||
int cg_split_spec(const char *spec, char **controller, char **path); | ||
int cg_join_spec(const char *controller, const char *path, char **spec); | ||
int cg_fix_path(const char *path, char **result); | ||
|
||
int cg_get_path(const char *controller, const char *path, const char *suffix, char **fs); | ||
int cg_get_path_and_check(const char *controller, const char *path, const char *suffix, char **fs); | ||
int cg_get_by_pid(const char *controller, pid_t pid, char **path); | ||
|
||
int cg_trim(const char *controller, const char *path, bool delete_root); | ||
|
||
int cg_rmdir(const char *controller, const char *path, bool honour_sticky); | ||
int cg_delete(const char *controller, const char *path); | ||
|
||
int cg_create(const char *controller, const char *path); | ||
int cg_attach(const char *controller, const char *path, pid_t pid); | ||
int cg_create_and_attach(const char *controller, const char *path, pid_t pid); | ||
|
||
int cg_set_group_access(const char *controller, const char *path, mode_t mode, uid_t uid, gid_t gid); | ||
int cg_set_task_access(const char *controller, const char *path, mode_t mode, uid_t uid, gid_t gid, int sticky); | ||
|
||
int cg_install_release_agent(const char *controller, const char *agent); | ||
|
||
int cg_is_empty(const char *controller, const char *path, bool ignore_self); | ||
int cg_is_empty_recursive(const char *controller, const char *path, bool ignore_self); | ||
|
||
int cg_get_user_path(char **path); | ||
int cg_pid_get_cgroup(pid_t pid, char **root, char **cgroup); | ||
int cg_pid_get_unit(pid_t pid, char **unit); | ||
|
||
char **cg_shorten_controllers(char **controllers); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ | ||
|
||
#pragma once | ||
|
||
/*** | ||
This file is part of systemd. | ||
Copyright 2010-2012 Lennart Poettering | ||
systemd is free software; you can redistribute it and/or modify it | ||
under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation; either version 2.1 of the License, or | ||
(at your option) any later version. | ||
systemd is distributed in the hope that it will be useful, but | ||
WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with systemd; If not, see <http://www.gnu.org/licenses/>. | ||
***/ | ||
|
||
void dev_setup(const char *pathprefix); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ | ||
|
||
#pragma once | ||
|
||
/*** | ||
This file is part of systemd. | ||
Copyright 2010 Lennart Poettering | ||
systemd is free software; you can redistribute it and/or modify it | ||
under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation; either version 2.1 of the License, or | ||
(at your option) any later version. | ||
systemd is distributed in the hope that it will be useful, but | ||
WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with systemd; If not, see <http://www.gnu.org/licenses/>. | ||
***/ | ||
|
||
#include <stdbool.h> | ||
#include "set.h" | ||
typedef enum ExitStatus { | ||
/* EXIT_SUCCESS defined by libc */ | ||
/* EXIT_FAILURE defined by libc */ | ||
EXIT_INVALIDARGUMENT = 2, | ||
EXIT_NOTIMPLEMENTED = 3, | ||
EXIT_NOPERMISSION = 4, | ||
EXIT_NOTINSTALLED = 5, | ||
EXIT_NOTCONFIGURED = 6, | ||
EXIT_NOTRUNNING = 7, | ||
|
||
/* The LSB suggests that error codes >= 200 are "reserved". We | ||
* use them here under the assumption that they hence are | ||
* unused by init scripts. | ||
* | ||
* http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html */ | ||
|
||
EXIT_CHDIR = 200, | ||
EXIT_NICE, | ||
EXIT_FDS, | ||
EXIT_EXEC, | ||
EXIT_MEMORY, | ||
EXIT_LIMITS, | ||
EXIT_OOM_ADJUST, | ||
EXIT_SIGNAL_MASK, | ||
EXIT_STDIN, | ||
EXIT_STDOUT, | ||
EXIT_CHROOT, /* 210 */ | ||
EXIT_IOPRIO, | ||
EXIT_TIMERSLACK, | ||
EXIT_SECUREBITS, | ||
EXIT_SETSCHEDULER, | ||
EXIT_CPUAFFINITY, | ||
EXIT_GROUP, | ||
EXIT_USER, | ||
EXIT_CAPABILITIES, | ||
EXIT_CGROUP, | ||
EXIT_SETSID, /* 220 */ | ||
EXIT_CONFIRM, | ||
EXIT_STDERR, | ||
EXIT_TCPWRAP, | ||
EXIT_PAM, | ||
EXIT_NETWORK, | ||
EXIT_NAMESPACE, | ||
EXIT_NO_NEW_PRIVILEGES, | ||
EXIT_SECCOMP | ||
} ExitStatus; | ||
|
||
typedef enum ExitStatusLevel { | ||
EXIT_STATUS_MINIMAL, | ||
EXIT_STATUS_SYSTEMD, | ||
EXIT_STATUS_LSB, | ||
EXIT_STATUS_FULL = EXIT_STATUS_LSB | ||
} ExitStatusLevel; | ||
|
||
typedef struct ExitStatusSet { | ||
Set *code; | ||
Set *signal; | ||
} ExitStatusSet; | ||
|
||
const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level); | ||
|
||
bool is_clean_exit(int code, int status, ExitStatusSet *success_status); | ||
bool is_clean_exit_lsb(int code, int status, ExitStatusSet *success_status); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ | ||
|
||
#pragma once | ||
|
||
/*** | ||
This file is part of systemd. | ||
Copyright 2010 Lennart Poettering | ||
systemd is free software; you can redistribute it and/or modify it | ||
under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation; either version 2.1 of the License, or | ||
(at your option) any later version. | ||
systemd is distributed in the hope that it will be useful, but | ||
WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with systemd; If not, see <http://www.gnu.org/licenses/>. | ||
***/ | ||
|
||
#include <stdbool.h> | ||
|
||
/* Pretty straightforward hash table implementation. As a minor | ||
* optimization a NULL hashmap object will be treated as empty hashmap | ||
* for all read operations. That way it is not necessary to | ||
* instantiate an object for each Hashmap use. */ | ||
|
||
typedef struct Hashmap Hashmap; | ||
typedef struct _IteratorStruct _IteratorStruct; | ||
typedef _IteratorStruct* Iterator; | ||
|
||
#define ITERATOR_FIRST ((Iterator) 0) | ||
#define ITERATOR_LAST ((Iterator) -1) | ||
|
||
typedef unsigned (*hash_func_t)(const void *p); | ||
typedef int (*compare_func_t)(const void *a, const void *b); | ||
|
||
unsigned string_hash_func(const void *p); | ||
int string_compare_func(const void *a, const void *b); | ||
|
||
unsigned trivial_hash_func(const void *p); | ||
int trivial_compare_func(const void *a, const void *b); | ||
|
||
unsigned uint64_hash_func(const void *p); | ||
int uint64_compare_func(const void *a, const void *b); | ||
|
||
Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func); | ||
void hashmap_free(Hashmap *h); | ||
void hashmap_free_free(Hashmap *h); | ||
Hashmap *hashmap_copy(Hashmap *h); | ||
int hashmap_ensure_allocated(Hashmap **h, hash_func_t hash_func, compare_func_t compare_func); | ||
|
||
int hashmap_put(Hashmap *h, const void *key, void *value); | ||
int hashmap_update(Hashmap *h, const void *key, void *value); | ||
int hashmap_replace(Hashmap *h, const void *key, void *value); | ||
void* hashmap_get(Hashmap *h, const void *key); | ||
void* hashmap_get2(Hashmap *h, const void *key, void **rkey); | ||
bool hashmap_contains(Hashmap *h, const void *key); | ||
void* hashmap_remove(Hashmap *h, const void *key); | ||
void* hashmap_remove_value(Hashmap *h, const void *key, void *value); | ||
int hashmap_remove_and_put(Hashmap *h, const void *old_key, const void *new_key, void *value); | ||
int hashmap_remove_and_replace(Hashmap *h, const void *old_key, const void *new_key, void *value); | ||
|
||
int hashmap_merge(Hashmap *h, Hashmap *other); | ||
void hashmap_move(Hashmap *h, Hashmap *other); | ||
int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key); | ||
|
||
unsigned hashmap_size(Hashmap *h); | ||
bool hashmap_isempty(Hashmap *h); | ||
|
||
void *hashmap_iterate(Hashmap *h, Iterator *i, const void **key); | ||
void *hashmap_iterate_backwards(Hashmap *h, Iterator *i, const void **key); | ||
void *hashmap_iterate_skip(Hashmap *h, const void *key, Iterator *i); | ||
|
||
void hashmap_clear(Hashmap *h); | ||
void hashmap_clear_free(Hashmap *h); | ||
|
||
void *hashmap_steal_first(Hashmap *h); | ||
void *hashmap_steal_first_key(Hashmap *h); | ||
void* hashmap_first(Hashmap *h); | ||
void* hashmap_first_key(Hashmap *h); | ||
void* hashmap_last(Hashmap *h); | ||
|
||
void *hashmap_next(Hashmap *h, const void *key); | ||
|
||
char **hashmap_get_strv(Hashmap *h); | ||
|
||
#define HASHMAP_FOREACH(e, h, i) \ | ||
for ((i) = ITERATOR_FIRST, (e) = hashmap_iterate((h), &(i), NULL); (e); (e) = hashmap_iterate((h), &(i), NULL)) | ||
|
||
#define HASHMAP_FOREACH_KEY(e, k, h, i) \ | ||
for ((i) = ITERATOR_FIRST, (e) = hashmap_iterate((h), &(i), (const void**) &(k)); (e); (e) = hashmap_iterate((h), &(i), (const void**) &(k))) | ||
|
||
#define HASHMAP_FOREACH_BACKWARDS(e, h, i) \ | ||
for ((i) = ITERATOR_LAST, (e) = hashmap_iterate_backwards((h), &(i), NULL); (e); (e) = hashmap_iterate_backwards((h), &(i), NULL)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#ifndef IOPRIO_H | ||
#define IOPRIO_H | ||
|
||
/* This is minimal version of Linux' linux/ioprio.h header file, which | ||
* is licensed GPL2 */ | ||
|
||
#include <unistd.h> | ||
#include <sys/syscall.h> | ||
|
||
/* | ||
* Gives us 8 prio classes with 13-bits of data for each class | ||
*/ | ||
#define IOPRIO_BITS (16) | ||
#define IOPRIO_CLASS_SHIFT (13) | ||
#define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1) | ||
|
||
#define IOPRIO_PRIO_CLASS(mask) ((mask) >> IOPRIO_CLASS_SHIFT) | ||
#define IOPRIO_PRIO_DATA(mask) ((mask) & IOPRIO_PRIO_MASK) | ||
#define IOPRIO_PRIO_VALUE(class, data) (((class) << IOPRIO_CLASS_SHIFT) | data) | ||
|
||
#define ioprio_valid(mask) (IOPRIO_PRIO_CLASS((mask)) != IOPRIO_CLASS_NONE) | ||
|
||
/* | ||
* These are the io priority groups as implemented by CFQ. RT is the realtime | ||
* class, it always gets premium service. BE is the best-effort scheduling | ||
* class, the default for any process. IDLE is the idle scheduling class, it | ||
* is only served when no one else is using the disk. | ||
*/ | ||
enum { | ||
IOPRIO_CLASS_NONE, | ||
IOPRIO_CLASS_RT, | ||
IOPRIO_CLASS_BE, | ||
IOPRIO_CLASS_IDLE, | ||
}; | ||
|
||
/* | ||
* 8 best effort priority levels are supported | ||
*/ | ||
#define IOPRIO_BE_NR (8) | ||
|
||
enum { | ||
IOPRIO_WHO_PROCESS = 1, | ||
IOPRIO_WHO_PGRP, | ||
IOPRIO_WHO_USER, | ||
}; | ||
|
||
static inline int ioprio_set(int which, int who, int ioprio) | ||
{ | ||
return syscall(__NR_ioprio_set, which, who, ioprio); | ||
} | ||
|
||
static inline int ioprio_get(int which, int who) | ||
{ | ||
return syscall(__NR_ioprio_get, which, who); | ||
} | ||
|
||
#endif |
Oops, something went wrong.