File: util.c

package info (click to toggle)
fuse3 3.18.1-1
  • links: PTS
  • area: main
  • in suites: sid
  • size: 58,496 kB
  • sloc: ansic: 25,055; perl: 6,044; cpp: 3,960; python: 1,201; sh: 416; javascript: 313; makefile: 59
file content (53 lines) | stat: -rw-r--r-- 779 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

#include "fuse_config.h"

#ifdef HAVE_PTHREAD_SETNAME_NP
#define _GNU_SOURCE
#include <pthread.h>
#endif

#include <errno.h>
#include <stdlib.h>
#include <errno.h>

#ifndef FUSE_USE_VERSION
#define FUSE_USE_VERSION (FUSE_MAKE_VERSION(3, 18))
#endif

#include "util.h"
#include "fuse_log.h"
#include "fuse_lowlevel.h"
#include <stdio.h>

int libfuse_strtol(const char *str, long *res)
{
	char *endptr;
	int base = 10;
	long val;

	errno = 0;

	if (!str)
		return -EINVAL;

	val = strtol(str, &endptr, base);

	if (errno)
	       return -errno;

	if (endptr == str || *endptr != '\0')
		return -EINVAL;

	*res = val;
	return 0;
}

void fuse_set_thread_name(const char *name)
{
#ifdef HAVE_PTHREAD_SETNAME_NP
	pthread_setname_np(pthread_self(), name);
#else
	(void)name;
#endif
}