diff options
Diffstat (limited to 'tools/perf/util/util.c')
-rw-r--r-- | tools/perf/util/util.c | 66 |
1 files changed, 7 insertions, 59 deletions
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 28a0a89..6d17b18 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -1,7 +1,7 @@ #include "../perf.h" #include "util.h" #include <sys/mman.h> -#ifdef HAVE_BACKTRACE_SUPPORT +#ifdef BACKTRACE_SUPPORT #include <execinfo.h> #endif #include <stdio.h> @@ -55,20 +55,17 @@ int mkdir_p(char *path, mode_t mode) return (stat(path, &st) && mkdir(path, mode)) ? -1 : 0; } -static int slow_copyfile(const char *from, const char *to, mode_t mode) +static int slow_copyfile(const char *from, const char *to) { - int err = -1; + int err = 0; char *line = NULL; size_t n; FILE *from_fp = fopen(from, "r"), *to_fp; - mode_t old_umask; if (from_fp == NULL) goto out; - old_umask = umask(mode ^ 0777); to_fp = fopen(to, "w"); - umask(old_umask); if (to_fp == NULL) goto out_fclose_from; @@ -85,7 +82,7 @@ out: return err; } -int copyfile_mode(const char *from, const char *to, mode_t mode) +int copyfile(const char *from, const char *to) { int fromfd, tofd; struct stat st; @@ -96,13 +93,13 @@ int copyfile_mode(const char *from, const char *to, mode_t mode) goto out; if (st.st_size == 0) /* /proc? do it slowly... */ - return slow_copyfile(from, to, mode); + return slow_copyfile(from, to); fromfd = open(from, O_RDONLY); if (fromfd < 0) goto out; - tofd = creat(to, mode); + tofd = creat(to, 0755); if (tofd < 0) goto out_close_from; @@ -124,11 +121,6 @@ out: return err; } -int copyfile(const char *from, const char *to) -{ - return copyfile_mode(from, to, 0755); -} - unsigned long convert_unit(unsigned long value, char *unit) { *unit = ' '; @@ -212,7 +204,7 @@ int hex2u64(const char *ptr, u64 *long_val) } /* Obtain a backtrace and print it to stdout. */ -#ifdef HAVE_BACKTRACE_SUPPORT +#ifdef BACKTRACE_SUPPORT void dump_stack(void) { void *array[16]; @@ -369,47 +361,3 @@ int parse_nsec_time(const char *str, u64 *ptime) *ptime = time_sec * NSEC_PER_SEC + time_nsec; return 0; } - -unsigned long parse_tag_value(const char *str, struct parse_tag *tags) -{ - struct parse_tag *i = tags; - - while (i->tag) { - char *s; - - s = strchr(str, i->tag); - if (s) { - unsigned long int value; - char *endptr; - - value = strtoul(str, &endptr, 10); - if (s != endptr) - break; - - if (value > ULONG_MAX / i->mult) - break; - value *= i->mult; - return value; - } - i++; - } - - return (unsigned long) -1; -} - -int filename__read_int(const char *filename, int *value) -{ - char line[64]; - int fd = open(filename, O_RDONLY), err = -1; - - if (fd < 0) - return -1; - - if (read(fd, line, sizeof(line)) > 0) { - *value = atoi(line); - err = 0; - } - - close(fd); - return err; -} |