libfuse
util.c
1
2#include "fuse_config.h"
3
4#ifdef HAVE_PTHREAD_SETNAME_NP
5#define _GNU_SOURCE
6#include <pthread.h>
7#endif
8
9#include <errno.h>
10#include <stdlib.h>
11#include <errno.h>
12
13#ifndef FUSE_USE_VERSION
14#define FUSE_USE_VERSION (FUSE_MAKE_VERSION(3, 18))
15#endif
16
17#include "util.h"
18#include "fuse_log.h"
19#include "fuse_lowlevel.h"
20#include <stdio.h>
21
22int libfuse_strtol(const char *str, long *res)
23{
24 char *endptr;
25 int base = 10;
26 long val;
27
28 errno = 0;
29
30 if (!str)
31 return -EINVAL;
32
33 val = strtol(str, &endptr, base);
34
35 if (errno)
36 return -errno;
37
38 if (endptr == str || *endptr != '\0')
39 return -EINVAL;
40
41 *res = val;
42 return 0;
43}
44
45void fuse_set_thread_name(const char *name)
46{
47#ifdef HAVE_PTHREAD_SETNAME_NP
48 pthread_setname_np(pthread_self(), name);
49#else
50 (void)name;
51#endif
52}
53