linux-sysprog · beginner · ~15 min
Compare namespace identifiers.
Each namespace is identified by the inode number of its /proc/<pid>/ns/* file; two processes share a namespace exactly when those ids match.
Implement int same_namespace(unsigned long a, unsigned long b) that returns 1 if the two namespace ids are equal, else 0.
a, b: namespace inode ids (unsigned).1 if a == b, else 0.
same_namespace(4026531835, 4026531835) -> 1
same_namespace(4026531835, 4026532000) -> 0
a, b: namespace inode ids (unsigned long).
1 if the ids are equal, else 0.
int same_namespace(unsigned long a, unsigned long b) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.