MCPcopy Create free account
hub / github.com/F-Stack/f-stack / setclasscpumask

Function setclasscpumask

tools/libutil/login_class.c:321–349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

319
320
321void
322setclasscpumask(login_cap_t *lc)
323{
324 const char *maskstr;
325 cpuset_t maskset;
326 cpusetid_t setid;
327
328 maskstr = login_getcapstr(lc, "cpumask", NULL, NULL);
329 CPU_ZERO(&maskset);
330 if (maskstr == NULL)
331 return;
332 if (strcasecmp("default", maskstr) == 0)
333 return;
334 if (!list2cpuset(maskstr, &maskset)) {
335 syslog(LOG_WARNING,
336 "list2cpuset(%s) invalid mask specification", maskstr);
337 return;
338 }
339
340 if (cpuset(&setid) != 0) {
341 syslog(LOG_ERR, "cpuset(): %s", strerror(errno));
342 return;
343 }
344
345 if (cpuset_setaffinity(CPU_LEVEL_CPUSET, CPU_WHICH_PID, -1,
346 sizeof(maskset), &maskset) != 0)
347 syslog(LOG_ERR, "cpuset_setaffinity(%s): %s", maskstr,
348 strerror(errno));
349}
350
351
352/*

Callers 1

setlogincontextFunction · 0.85

Calls 4

login_getcapstrFunction · 0.85
strcasecmpFunction · 0.85
list2cpusetFunction · 0.85
cpusetClass · 0.50

Tested by

no test coverage detected