/* * sysctl - sysctl set/get helpers * Subject to the GPL, version 2. */ #include #include #include #include #include #include #include "built_in.h" #include "sysctl.h" int sysctl_set_int(const char *file, int value) { char path[PATH_MAX]; char str[64]; ssize_t ret; int fd; strncpy(path, SYSCTL_PROC_PATH, PATH_MAX); strncat(path, file, PATH_MAX - sizeof(SYSCTL_PROC_PATH) - 1); fd = open(path, O_WRONLY); if (unlikely(fd < 0)) return -1; ret = snprintf(str, 63, "%d", value); if (ret < 0) { close(fd); return -1; } ret = write(fd, str, strlen(str)); close(fd); return ret <= 0 ? -1 : 0; } int sysctl_get_int(const char *file, int *value) { char path[PATH_MAX]; char str[64]; ssize_t ret; int fd; strncpy(path, SYSCTL_PROC_PATH, PATH_MAX); strncat(path, file, PATH_MAX - sizeof(SYSCTL_PROC_PATH) - 1); fd = open(path, O_RDONLY); if (fd < 0) return -1; ret = read(fd, str, sizeof(str)); if (ret > 0) { *value = atoi(str); ret = 0; } else { ret = -1; } close(fd); return ret; } maclite-cleanup'>emaclite-cleanup net-next plumbingsTobias Klauser
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2016-09-02 15:55:15 +1000
committerDave Airlie <airlied@redhat.com>2016-09-02 15:55:15 +1000
commit603f2c9f45c6620afd65b60ec084c1ea7c36b2ec (patch)
tree5c22eed9f236ce5bd2f7f8ab32812198ec198f19
parent5322942527156178874eec3d3108a4fae148d87d (diff)
parent552416c146fadc67cd9b53ef7adf88d3381c43a6 (diff)
Merge tag 'drm-vc4-fixes-2016-08-29' of https://github.com/anholt/linux into drm-fixes
This pull request brings in fixes for VC4 3D in 4.8, most of which are covered by testcases. * tag 'drm-vc4-fixes-2016-08-29' of https://github.com/anholt/linux: drm/vc4: Fix oops when userspace hands in a bad BO. drm/vc4: Fix overflow mem unreferencing when the binner runs dry. drm/vc4: Free hang state before destroying BO cache. drm/vc4: Fix handling of a pm_runtime_get_sync() success case. drm/vc4: Use drm_malloc_ab to fix large rendering jobs. drm/vc4: Use drm_free_large() on handles to match its allocation.