mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
smaller fixes in linux code
This commit is contained in:
parent
cc66553761
commit
238c732feb
3 changed files with 35 additions and 14 deletions
|
@ -30,14 +30,17 @@
|
|||
*/
|
||||
int kernel_is_rt();
|
||||
|
||||
/** Check if kernel command line contains "isolcpus=" option.
|
||||
/** Get kernel cmdline parameter
|
||||
*
|
||||
* See https://www.kernel.org/doc/Documentation/kernel-parameters.txt
|
||||
*
|
||||
* @retval 0 Kernel has isolated cores.
|
||||
* @reval <>0 Kernel has no isolated cores.
|
||||
* @param param The cmdline parameter to look for.
|
||||
* @param buf The string buffer to which the parameter value will be copied to.
|
||||
* @param len The length of the buffer \p value
|
||||
* @retval 0 Parameter \p key was found and value was copied to \p value
|
||||
* @reval <>0 Kernel was not booted with parameter \p key
|
||||
*/
|
||||
int kernel_has_cmdline(const char *substr);
|
||||
int kernel_get_cmdline_param(const char *param, char *buf, size_t len);
|
||||
|
||||
/** Check if kernel is version is sufficient
|
||||
*
|
||||
|
|
|
@ -89,7 +89,6 @@ int kernel_module_loaded(const char *module)
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int kernel_has_version(int maj, int min)
|
||||
{
|
||||
struct utsname uts;
|
||||
|
@ -110,20 +109,42 @@ int kernel_is_rt()
|
|||
return access(SYSFS_PATH "/kernel/realtime", R_OK);
|
||||
}
|
||||
|
||||
int kernel_has_cmdline(const char *substr)
|
||||
int kernel_get_cmdline_param(const char *param, char *buf, size_t len)
|
||||
{
|
||||
char cmd[512];
|
||||
int ret;
|
||||
char cmdline[512];
|
||||
|
||||
FILE *f = fopen(PROCFS_PATH "/cmdline", "r");
|
||||
if (!f)
|
||||
return -1;
|
||||
|
||||
if (!fgets(cmd, sizeof(cmd), f))
|
||||
return -1;
|
||||
|
||||
if (!fgets(cmdline, sizeof(cmdline), f))
|
||||
goto out;
|
||||
|
||||
char *tok = strtok(cmdline, " \t");
|
||||
do {
|
||||
char key[128], value[128];
|
||||
|
||||
ret = sscanf(tok, "%127[^=]=%127s", key, value);
|
||||
if (ret >= 1) {
|
||||
if (ret >= 2)
|
||||
debug(30, "Found kernel param: %s=%s", key, value);
|
||||
else
|
||||
debug(30, "Found kernel param: %s", key);
|
||||
|
||||
if (strcmp(param, key) == 0) {
|
||||
if (ret >= 2 && buf)
|
||||
strncpy(buf, value, len);
|
||||
|
||||
return 0; /* found */
|
||||
}
|
||||
}
|
||||
} while((tok = strtok(NULL, " \t")));
|
||||
|
||||
out:
|
||||
fclose(f);
|
||||
|
||||
return strstr(cmd, substr) ? 0 : -1;
|
||||
return -1; /* not found or error */
|
||||
}
|
||||
|
||||
int kernel_get_cacheline_size()
|
||||
|
|
|
@ -568,9 +568,6 @@ void * vfio_map_dma(struct vfio_container *c, size_t size, size_t pgsize, uint64
|
|||
|
||||
pgbits = 8 * sizeof(unsigned long long) - __builtin_clzll((unsigned long long) pgsize) - 1;
|
||||
|
||||
debug(3, "pgsize = %#zx", pgsize);
|
||||
debug(3, "defpgsize = %#zx", defpgsize);
|
||||
|
||||
flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT;
|
||||
if (pgsize != defpgsize) /* Map as Hugepages */
|
||||
flags |= MAP_HUGETLB | (pgbits << MAP_HUGE_SHIFT);
|
||||
|
|
Loading…
Add table
Reference in a new issue