summaryrefslogtreecommitdiff
path: root/src/basic
AgeCommit message (Collapse)Author
2015-10-05missing.h : add bridge paramsSusant Sahani
2015-10-01logind: remove warn_melody() logicLennart Poettering
The internal speaker is usually not available on modern latops that support suspend, and even if it is available in the hardware, most distributions turned support for it off in the kernel. And even if it is enabled, it's probably still a bad idea to make use of it for the suspend-failures. If anything a proper sound should be played. Long story short, let's remove support of this anachronism.
2015-10-01Merge pull request #1426 from poettering/log-syntaxDaniel Mack
logging fixes and more
2015-09-30Merge pull request #1419 from keszybz/shell-completionLennart Poettering
Shell completion tweaks
2015-09-30tree-wide: remove a number of invocations of strerror() and replace by %mLennart Poettering
Let's clean up our tree a bit, and reduce invocations of the thread-unsafe strerror() by replacing it with printf()'s %m specifier.
2015-09-30basic: split out cpu set specific APIs into cpu-set-util.[ch]Lennart Poettering
2015-09-30util: there cannot be trailing garbage when parsing cpu setsLennart Poettering
extract_first() already skips trailing whitespace, hence no reason to explicitly check for it.
2015-09-30util: rename parse_cpu_set() to parse_cpu_set_and_warn()Lennart Poettering
It's pretty untypical for our parsing functions to log on their own. Clarify in the name that this one does.
2015-09-30log: move log_invalid_utf8() to log.hLennart Poettering
Also, make sure it follows the same scheme as log_syntax() does in its behaviour.
2015-09-30tree-wide: clean up log_syntax() usageLennart Poettering
- Rely everywhere that we use abs() on the error code passed in anyway, thus don't need to explicitly negate what we pass in - Never attach synthetic error number information to log messages. Only log about errors we *receive* with the error number we got there, don't log any synthetic error, that don#t even propagate, but just eat up. - Be more careful with attaching exactly the error we get, instead of errno or unrelated errors randomly. - Fix one occasion where the error number and line number got swapped. - Make sure we never tape over OOM issues, or inability to resolve specifiers
2015-09-30Merge pull request #1415 from aakoskin/bootchart-v2Daniel Mack
[v2] bootchart: don't fail if "model name" is missing from cpuinfo
2015-09-30log: properly return -EINVAL from log_set_max_level_from_string()Lennart Poettering
If we just return the value we got from log_level_from_string() on failure we'll return -1, which is not a proper error code. log_set_target_from_string() did get this right already, hence let's fix this here too.
2015-09-30fileio: make get_status_field() more genericAaro Koskinen
All users of get_status_field() expect the field pattern to occur in the beginning of a line, and the delimiter is ':'. Hardcode this into the function, and also skip any whitespace before ':' to support fields in files like /proc/cpuinfo. Add support for returning the full field value (currently stops on first whitespace). Rename the function so it's easier to ensure all callers switch to new semantics.
2015-09-29Merge pull request #1408 from poettering/systemctl-and-moreDaniel Mack
Systemctl and more
2015-09-29systemctl: move strv_skip_first() out of systemctl.cLennart Poettering
Make it generic, call it strv_skip() and move it to strv.[ch]
2015-09-29core: rework crash handlingLennart Poettering
This introduces a new systemd.crash_reboot=1 kernel command line option that triggers a reboot after crashing. This also cleans up crash VT handling. Specifically, it cleans up the configuration setting, to be between 1..63 or a boolean. This is to replace the previous logic where "-1" meant disabled. We continue to accept that setting, but only document the boolean syntax instead. This also brings the documentation of the default settings in sync with what actually happens. The CrashChVT= configuration file setting is renamed to CrashChangeVT=, following our usual logic of not abbreviating unnecessarily. The old setting stays support for compat reasons. Fixes #1300
2015-09-29selinux: add _cleanup_ concepts to SELinux label allocationLennart Poettering
2015-09-29Merge pull request #1407 from dvdhrm/prioqLennart Poettering
prioq: drop stability guarantee
2015-09-29util: introduce common version() implementation and use it everywhereLennart Poettering
This also allows us to drop build.h from a ton of files, hence do so. Since we touched the #includes of those files, let's order them properly according to CODING_STYLE.
2015-09-29util: unify implementation of NOP signal handlerLennart Poettering
This is highly complex code after all, we really should make sure to only keep one implementation of this extremely difficult function around.
2015-09-29strv: add strv_free_free() to strv.c and make use of itLennart Poettering
Let's teach it a new trick, and make it return NULL.
2015-09-29tree-wide: port more code to use send_one_fd() and receive_one_fd()Lennart Poettering
Also, make it slightly more powerful, by accepting a flags argument, and make it safe for handling if more than one cmsg attribute happens to be attached.
2015-09-29prioq: never shuffle identical entriesDavid Herrmann
Skip shuffling identical entries in shuffle_up(), just like we already do in shuffle_down().
2015-09-29prioq: add introduction commentDavid Herrmann
Add comment to prioq.c explaining what it does. And more importantly, mention that we implement a Heap. It's more than annoying having to figure out what the code actually does, without ever mentioning the word 'heap'.
2015-09-28Move all unit states to basic/ and extend systemctl --state=helpZbigniew Jędrzejewski-Szmek
2015-09-28Move UnitActiveState to basic/Zbigniew Jędrzejewski-Szmek
Preparation to allow systemctl to query the list of unit states.
2015-09-24util: refactor cpu_set parsing into its own functionFilipe Brandenburger
Use the new code in config_parse_cpu_affinity2. Tested by modifying CPUAffinity=... setting in /etc/systemd/system.conf and reloading the daemon, then checking ^Cpus_allowed in /proc/1/status to confirm the correct CPU mask is in place.
2015-09-24s390: add personality supportHendrik Brueckner
Introduce personality support for Linux on z Systems to run particular services with a 64-bit or 31-bit personality.
2015-09-23Merge pull request #1365 from floppym/kcmpLennart Poettering
Add fallback for kcmp() in case __NR_kcmp is undefined
2015-09-23Add fallback for kcmp() in case __NR_kcmp is undefinedMike Gilbert
IA64 is missing this syscall as of linux-4.2. This works around it until the necessary kernel patch gets merged.
2015-09-23mising: add __NR_memfd_create syscall number for s390Hendrik Brueckner
2015-09-22Merge pull request #1335 from poettering/some-fixesDaniel Mack
A variety of mostly unrelated fixes
2015-09-22util: drop UID_IS_INVALID() in favour of uid_is_valid()Lennart Poettering
No need to keep both functions, settle on uid_is_valid() for everything.
2015-09-22util.h: order includes, as suggested by CODING_STYLELennart Poettering
Of course, because Linux is broken we cannot actually really order it, and must keep linux/fs.h after sys/mount.h... Yay for Linux!
2015-09-22util: clean-ups to enum parsersLennart Poettering
Never log when we fail due to OOM when translating enums, let the caller do that. Translating basic types like enums should be something where the caller logs, not the translatior functions. Return -1 when NULL is passed to all enum parser functions. The non-fallback versions of the enum translator calls already handle NULL as failure, instead of hitting an assert, and we should do this here, too.
2015-09-22util: minor cleanups for loop_read() and friendsLennart Poettering
When 0 bytes are to be written, make sure to go into read() at least once, in order to validate the parameters, such as the passed fd. Return error on huge values, add a couple of asserts and casts where appropriate.
2015-09-22cgtop: underline table headerLennart Poettering
Let's underline the header line of the table shown by cgtop, how it is customary for tables. In order to do this, let's introduce new ANSI underline macros, and clean up the existing ones as side effect.
2015-09-22util: add safe_closedir() similar to safe_fclose()Lennart Poettering
2015-09-22copy: make copy_bytes() return whether we hit EOF or notLennart Poettering
2015-09-22copy: be more careful when trying to reflinkLennart Poettering
2015-09-22util: introduce {send,receive}_one_fd()David Herrmann
Introduce two new helpers that send/receive a single fd via a unix transport. Also make nspawn use them instead of hard-coding it. Based on a patch by Krzesimir Nowak.
2015-09-16Merge pull request #1269 from zonque/netclsLennart Poettering
cgroup: add support for net_cls controllers
2015-09-16basic: nicer xsprintf and xstrftime assert messagesMichal Schmidt
It's nicer if the assertion failure message from a bad use of xsprintf actually mentions xsprintf instead of the expression the macro is implemented as. The assert_message_se macro was added in the previous commit as an internal helper, but it can also be used for customizing assertion failure messages like in this case. Example: char buf[10]; xsprintf(buf, "This is a %s message.\n", "long"); Before: Assertion '(size_t) snprintf(buf, ELEMENTSOF(buf), "This is a %s message.\n", "long") < ELEMENTSOF(buf)' failed at foo.c:6, function main(). Aborting. After: Assertion 'xsprintf: buf[] must be big enough' failed at foo.c:6, function main(). Aborting.
2015-09-16basic: nicer assert messagesMichal Schmidt
Make sure the assert expression is not macro-expanded before stringification. This makes several assertion failure messages more readable. As an example: assert(streq("foo", "bar")); I'd rather see this: Assertion 'streq("foo", "bar")' failed at foo.c:5, function main(). Aborting. ...than this, though awesome, incomprehensible truncated mess: Assertion '(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (( "foo")) && __builtin_constant_p (("bar")) && (__s1_len = strlen (("foo")), __s2_ len = strlen (("bar")), (!((size_t)(const void *)((("foo")) + 1) - (size_t)(cons t void *)(("foo")) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((("bar") ) + 1) - (size_t)(const void *)(("bar")) == 1) || __s2_len >= 4)) ? __builtin_st rcmp (("foo"), ("bar")) : (__builtin_constant_p (("foo")) && ((size_t)(const voi d *)((("foo")) + 1) - (size_t)(const void *)(("foo")) == 1) && (__s1_len = strle n (("foo")), __s1_len < 4) ? (__builtin_constant_p (("bar")) && ((size_t)(const void *)((("bar")) + 1) - (size_t)(const void *)(("bar")) == 1) ? __builtin_strcm p (("foo"), ("bar")) : (__extension__ ({ const unsigned char *__s2 = (const unsi gned char *) (const char *) (("bar")); int __result = (((const unsigned char *) (const char *) (("foo")))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __ result = (((const unsigned char *) (const char *) (("foo")))[1] - __s2[1]); if ( __s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const cha r *) (("foo")))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = ((( const unsigned char *) (const char *) (("foo")))[3] - __s2[3]); } } __result; }) )) : (__builtin_constant_p (("bar")) && ((size_t)(const void *)((("bar")) + 1) - (size_t)(const void *)(("bar")) == 1) && (__s2_len = strlen (("bar")), __s2_len < 4) ? (__builtin_constant_p (("foo")) && ((size_t)(const void *)((("foo")) + 1 ) - (size_t)(const void *)(("foo")) == 1) ? __builtin_strcmp (("foo"), ("bar")) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (cons t char *) (("foo")); int __result = (((const unsigned char *) (const char *) ((" bar")))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (("bar")))[1] - __s2[1]); if (__s2_len > 1 && __ result == 0) { __result = (((const unsigned char *) (const char *) (("bar")))[2] - __s2[2]); if (__s2_len > 2 && __result == 0)
2015-09-16basic: make sure argument of ELEMENTSOF is an arrayMichal Schmidt
Using ELEMENTSOF on a pointer will result in a compilation error.
2015-09-16cgroup: add support for net_cls controllersDaniel Mack
Add a new config directive called NetClass= to CGroup enabled units. Allowed values are positive numbers for fix assignments and "auto" for picking a free value automatically, for which we need to keep track of dynamically assigned net class IDs of units. Introduce a hash table for this, and also record the last ID that was given out, so the allocator can start its search for the next 'hole' from there. This could eventually be optimized with something like an irb. The class IDs up to 65536 are considered reserved and won't be assigned automatically by systemd. This barrier can be made a config directive in the future. Values set in unit files are stored in the CGroupContext of the unit and considered read-only. The actually assigned number (which may have been chosen dynamically) is stored in the unit itself and is guaranteed to remain stable as long as the unit is active. In the CGroup controller, set the configured CGroup net class to net_cls.classid. Multiple unit may share the same net class ID, and those which do are linked together.
2015-09-11core: refactor cpu shares/blockio weight cgroup logicLennart Poettering
Let's stop using the "unsigned long" type for weights/shares, and let's just use uint64_t for this, as that's what we expose on the bus. Unify parsers, and always validate the range for these fields. Correct the default blockio weight to 500, since that's what the kernel actually uses. When parsing the weight/shares settings from unit files accept the empty string as a way to reset the weight/shares value. When getting it via the bus, uniformly map (uint64_t) -1 to unset. Open up StartupCPUShares= and StartupBlockIOWeight= to transient units.
2015-09-11util: remove ring.[ch] + pty.[ch] and testsLennart Poettering
This was used by consoled, which was removed, let's remove this too now.
2015-09-10Merge pull request #1239 from poettering/cgroup-pidsDaniel Mack
core: add support for the "pids" cgroup controller
2015-09-10core: add support for the "pids" cgroup controllerLennart Poettering
This adds support for the new "pids" cgroup controller of 4.3 kernels. It allows accounting the number of tasks in a cgroup and enforcing limits on it. This adds two new setting TasksAccounting= and TasksMax= to each unit, as well as a gloabl option DefaultTasksAccounting=. This also updated "cgtop" to optionally make use of the new kernel-provided accounting. systemctl has been updated to show the number of tasks for each service if it is available. This patch also adds correct support for undoing memory limits for units using a MemoryLimit=infinity syntax. We do the same for TasksMax= now and hence keep things in sync here.