lib/path: make path_set_prefix() independent on cpu_set_t
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
7b41ad363f
commit
d182565be1
|
@ -6,6 +6,10 @@
|
|||
|
||||
/* Returns a pointer to a static buffer which may be destroyed by any later
|
||||
path_* function call. NULL means error and errno will be set. */
|
||||
/* Returns: 0 on success, sets errno on error. */
|
||||
extern int path_set_prefix(const char *)
|
||||
__attribute__((warn_unused_result));
|
||||
|
||||
extern const char *path_get(const char *path, ...)
|
||||
__attribute__ ((__format__ (__printf__, 1, 2)));
|
||||
|
||||
|
@ -31,10 +35,5 @@ extern cpu_set_t *path_read_cpuset(int, const char *path, ...)
|
|||
extern cpu_set_t *path_read_cpulist(int, const char *path, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
|
||||
/* Returns: 0 on success, sets errno on error. */
|
||||
extern int path_set_prefix(const char *)
|
||||
__attribute__((warn_unused_result));
|
||||
|
||||
#endif /* HAVE_CPU_SET_T */
|
||||
|
||||
#endif /* UTIL_LINUX_PATH_H */
|
||||
|
|
29
lib/path.c
29
lib/path.c
|
@ -35,6 +35,20 @@
|
|||
static size_t prefixlen;
|
||||
static char pathbuf[PATH_MAX];
|
||||
|
||||
int
|
||||
path_set_prefix(const char *prefix)
|
||||
{
|
||||
size_t len = strlen(prefix);
|
||||
|
||||
if (len >= sizeof(pathbuf) - 1) {
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
prefixlen = len;
|
||||
strcpy(pathbuf, prefix);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *
|
||||
path_vcreate(const char *path, va_list ap)
|
||||
{
|
||||
|
@ -259,19 +273,4 @@ path_read_cpulist(int maxcpus, const char *path, ...)
|
|||
|
||||
return set;
|
||||
}
|
||||
|
||||
int
|
||||
path_set_prefix(const char *prefix)
|
||||
{
|
||||
size_t len = strlen(prefix);
|
||||
|
||||
if (len >= sizeof(pathbuf) - 1) {
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
prefixlen = len;
|
||||
strcpy(pathbuf, prefix);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* HAVE_CPU_SET_T */
|
||||
|
|
Loading…
Reference in New Issue