Tobin C. Harding [Fri, 17 Aug 2018 04:40:45 +0000 (14:40 +1000)]
CODING_STYLE: Update section header format
Currently for section headings we use fourth level markdown heading
level (####). We do not have levels two or three.
We can use standard incremental levels for heading adornments i.e
1) =========
2) ##
3) ###
ect.
Since this document is likely referenced by maintainers when guiding new
contributors it can save maintainer time to be able to quickly reference
a section in the coding stlye guide. If we add numbers to each heading
(like the kernel stlye guide) then maintainers can say:
Nice patch, please see section 3 of the coding style guide and ...
So, this patch makes two changes
- Use incremental level heading adornments
- Add a number to each section heading
Tobin C. Harding [Fri, 17 Aug 2018 03:55:47 +0000 (13:55 +1000)]
CODING_STLYE: Remove sections implied by 'kernel style'
We explicitly state that LXC uses coding style based on Linux kernel
style. It is redundant to then document obvious, and well known, kernel
style rules. Identifier names certainly fall into this category as does
usage of braces.
Remove sections implied by 'kernel style'. Naming conventions and brace
placement conventions.
Tobin C. Harding [Thu, 16 Aug 2018 23:38:48 +0000 (09:38 +1000)]
CODING_STLYE: Simplify explanation for use of 'extern'
Current explanation of rules around usage of 'extern' are overly
verbose. It is not necessary to state that functions should be declared
in header files, the compiler already enforces this. These rules are
simple, they are better described with simple statements. An example is
not necessary for such simple rules and serves only to make the document
longer.
Use two simple statements describing the rules that govern function
declaration and the usage of the 'extern' keyword.
Tobin C. Harding [Fri, 17 Aug 2018 03:46:16 +0000 (13:46 +1000)]
CODING_STYLE: Mention kernel style in introduction
Currently the coding style guide does not mention that we use kernel
coding style as a base style for LXC. We have just linked to
CODING_STLYE.md from CONTRIBUTING (which mentions use of kernel coding
style). We can increase documentation congruence and completeness by
mentioning kernel coding style guide in the introduction to our style
guide.
Add heading and introduction to coding style guide informing readers
that we follow kernel coding style as a base before explaining our style
additions.
Tobin C. Harding [Thu, 16 Aug 2018 23:19:32 +0000 (09:19 +1000)]
CONTRIBUTING: Direct readers to CODING_STYLE.md
Currently the 'Coding Style' section mentions only the kernel coding
style. We have additions on top on this outlined in CODING_STYLE.md.
We should direct readers to this document as well as the kernel docs.
Direct readers to CODING_STLYE.md in the 'Coding Style' section.
Tobin C. Harding [Fri, 17 Aug 2018 04:29:15 +0000 (14:29 +1000)]
CONTRIBUTING: Link to latest online kernel docs
Currently we link to a URL for v4.10 of the kernel docs. Since we
already mention the kernel tree we should link to the _latest_ kernel
docs online instead of a fixed past version.
Link to latest online kernel docs tracking the mainline instead of past
fixed version.
Tobin C. Harding [Fri, 17 Aug 2018 04:16:47 +0000 (14:16 +1000)]
CONTRIBUTING: Update reference to kernel coding style
Kernel coding style guide filename is stale, this file has been renamed
in the kernel tree. While this file still exists we should use the new
filename.
Update reference to kernel coding style guide to use the new file name.
Add a thread-safe and uniform way to retrieve errno values in programs that are
shipped as part of LXC but are not expected to have access to the logging
system.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Add a thread-safe and uniform way to retrieve errno values in programs that are
shipped as part of LXC but are not expected to have access to the logging
system.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Tobin C. Harding [Wed, 15 Aug 2018 23:43:02 +0000 (09:43 +1000)]
usernsexec: Make err out vebose for unshare error
Currently if lxc-usernsexec is run on a kernel without user namespaces
enabled the error message is
unshare: Invalid argument
read pipe: Success
This error message 'Invalid argument' does not point at the root cause
of the error. We can help the user out by giving a more detailed error
message and also not using perror() if errno==0.
Improve error message by
- Printing unshare flags
- Printing suggested cause of failure (user namespace not enabled)
- Print error message with fprintf() if errno==0 (EOF)
sleep() is not thread-safe but nanosleep() is. Since no resources are allocated
in lxc_wait() it is safe to call nanosleep() without cancellation handlers.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
When we check whether an open file description lock has been taken on a file we
need to set the l_pid field to 0 otherwise the kernel will send back EINVAL.
Additionally, the kernel will not do pid translation and simply set the l_pid
value to -1.
Unprivileged's incompatibility with type=none docs
Unprivileged containers are not compatible with sharing the
host namespace due to an inability to mount sysfs. Add docs
in lxc.container.conf to document that out.
We don't want to link caps.{c,h} against utils.{c,h} for the sake of our static
builds init.lxc.static. This means lxc_write_nointr() will not be available. So
handle it EINTR.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
We don't want to link log.{c,h} against utils.{c,h} for the sake of our static
builds init.lxc.static. This means lxc_write_nointr() will not be available. So
handle it EINTR.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>