Back to index

numactl  2.0.8~rc4
Functions
sysfs.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

hidden char * sysfs_read (char *name)
hidden int sysfs_node_read (struct bitmask *mask, char *fmt,...)

Function Documentation

hidden int sysfs_node_read ( struct bitmask mask,
char *  fmt,
  ... 
)

Definition at line 34 of file sysfs.c.

{
       int n;
       va_list ap;
       char *p, *fn, *m, *end;
       int num;

       va_start(ap, fmt);
       n = vasprintf(&fn, fmt, ap);
       va_end(ap);
       if (n < 0)
              return -1;
       p = sysfs_read(fn);
       free(fn);
       if (!p)
              return -1;

       m = p;
       do {
              num = strtol(m, &end, 0);
              if (m == end)
                     return -1;
              if (num < 0)
                     return -2;
              if (num >= numa_num_task_nodes())
                     return -1;
              numa_bitmask_setbit(mask, num);

              /* Continuation not supported by kernel yet. */
              m = end;
              while (isspace(*m) || *m == ',')
                     m++;
       } while (isdigit(*m));
       free(p);
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

hidden char* sysfs_read ( char *  name)

Definition at line 14 of file sysfs.c.

{
       char *buf;
       int n;
       int fd;

       fd = open(name, O_RDONLY);
       buf = malloc(SYSFS_BLOCK);
       if (!buf)
              return NULL;
       n = read(fd, buf, SYSFS_BLOCK - 1);
       close(fd);
       if (n <= 0) {
              free(buf);
              return NULL;
       }
       buf[n] = 0;
       return buf;
}

Here is the caller graph for this function: