struct new_utsname {

char sysname[65]; char nodename[65]; char release[65]; char version[65]; char machine[65]; char domainname[65];

The individual strings store the name of the system (Linux...), the kernel release, the machine name, and so on. The current values can be determined using the uname tool, but are also visible in


[email protected]> cat /proc/sys/kernel/ostype Linux [email protected]> cat /proc/sys/kernel/osrelease 2.6.24

The initial settings are stored in init_uts_ns: init/version.c struct uts_namespace init_uts_ns = {

.sysname = UTS_SYSNAME, .nodename = UTS_NODENAME, .release = UTS_RELEASE, .version = UTS_VERSION,

.machine = UTS_MACHINE, .domainname = UTS_DOMAINNAME,

The pre-processor constants are defined on various places across the kernel. uts_release is, for instance, set in <utsrelease.h>, which is dynamically generated at build time by the top-level Makefile.

Notice that some parts of the UTS structure cannot be changed. For instance, it would not make sense to exchange sysname by anything else than Linux. It is, however, possible to change the machine name, for example.

How does the kernel go about creating a new UTS namespace? This falls under the responsibility of the function copy_utsname. The function is called when a process is forked and the flag clone_newuts specifies that a new UTS namespace is to be established. In this case, a copy of the previous instance of uts_namespace is generated, and a corresponding pointer is installed into the nsproxy instance of the current task. Nothing more is required! Since the kernel makes sure to always operate on the task-specific uts_namespace instance whenever a UTS value is read or set, changes for the current process will not be reflected in the parent, and changes in the parent will also not propagate toward the children.

The User Namespace

The user namespace is handled similarly in terms of data structure management: When a new user namespace is requested, a copy of the current user namespace is generated and associated with the nsproxy instance of the current task. However, the representation of a user namespace itself is slightly more complex:

Continue reading here: Info

Was this article helpful?

0 0