library: rework namespace calls
Functions related to namespaces were half-in half-out of the
procps library and didn't fit the standard naming scheme.
While struct { long ns[x]} is a bit clunky, its the only way
to "lock in" x. The alternative is to use ns_* variables.
This work was needed before pgrep could be converted.
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "proc/readproc.h"
|
||||
#include "nsutils.h"
|
||||
|
||||
/* we need to fill in only namespace information */
|
||||
int ns_read(pid_t pid, proc_t *ns_task)
|
||||
{
|
||||
struct stat st;
|
||||
char buff[50];
|
||||
int i, rc = 0;
|
||||
|
||||
for (i = 0; i < NUM_NS; i++) {
|
||||
snprintf(buff, sizeof(buff), "/proc/%i/ns/%s", pid,
|
||||
get_ns_name(i));
|
||||
if (stat(buff, &st)) {
|
||||
if (errno != ENOENT)
|
||||
rc = errno;
|
||||
ns_task->ns[i] = 0;
|
||||
continue;
|
||||
}
|
||||
ns_task->ns[i] = st.st_ino;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "nsutils.h"
|
||||
|
||||
const char *get_ns_name(int id)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("Hello, World!\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user