anothertest
anothertest

Reputation: 979

Why is the difference between oldolduname and uname?

Why is the difference between oldolduname and uname?

I have been reading the man pages and I don't get the subtlety.

Upvotes: 3

Views: 541

Answers (2)

Barmar
Barmar

Reputation: 782315

uname is the function called by user code.

It calls one of the kernel functions sys_newuname, sys_uname, or sys_olduname, depending on the version of the Linux kernel. The difference between these is the lengths of the name fields (9 characters in sys_olduname, 65 characters in the other two), and sys_newuname adds an additional domainname field to the structure.

Upvotes: 2

nos
nos

Reputation: 229284

First of all, if you call uname from userspace, you do not need to care about the difference, and there should be no need to use olduname or oldolduname. From userspace, you use struct utsname and you call the uname() function.

From the man page:

Over time, increases in the size of the utsname structure have led to three successive versions of uname(): sys_olduname() (slot __NR_oldolduname), sys_uname() (slot __NR_olduname), and sys_newuname() (slot __NR_uname). The first one used length 9 for all fields; the second used 65; the third also uses 65 but adds the domainname field. The glibc uname() wrapper function hides these details from applications, invoking the most recent version of the system call provided by the kernel.

So, throughout history the sizes and content of struct utsname has changed slightly, and the kernel has kept 3 different versions around to keep compatibility with userspace, you can see the different versions that the kernel handles here: http://lxr.free-electrons.com/source/include/linux/utsname.h?v=2.6.38#L24 . However glibc, or any C library on linux hides all this from you.

Upvotes: 3

Related Questions