Lines Matching refs:file

52 		struct perf_data_file *file = &files[i];  in perf_data__create_dir()  local
54 ret = asprintf(&file->path, "%s/data.%d", data->path, i); in perf_data__create_dir()
58 ret = open(file->path, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR); in perf_data__create_dir()
62 file->fd = ret; in perf_data__create_dir()
99 struct perf_data_file *file; in perf_data__open_dir() local
112 file = realloc(files, (nr + 1) * sizeof(*files)); in perf_data__open_dir()
113 if (!file) in perf_data__open_dir()
116 files = file; in perf_data__open_dir()
117 file = &files[nr++]; in perf_data__open_dir()
119 file->path = strdup(path); in perf_data__open_dir()
120 if (!file->path) in perf_data__open_dir()
123 ret = open(file->path, O_RDONLY); in perf_data__open_dir()
127 file->fd = ret; in perf_data__open_dir()
128 file->size = st.st_size; in perf_data__open_dir()
151 struct perf_data_file *file = &data->dir.files[i]; in perf_data__update_dir() local
154 if (fstat(file->fd, &st)) in perf_data__update_dir()
157 file->size = st.st_size; in perf_data__update_dir()
183 data->file.fptr = fdopen(fd, mode); in check_pipe()
185 if (data->file.fptr == NULL) { in check_pipe()
186 data->file.fd = fd; in check_pipe()
190 data->file.fd = fd; in check_pipe()
248 fd = open(data->file.path, flags); in open_file_read()
252 pr_err("failed to open %s: %s", data->file.path, in open_file_read()
254 if (err == ENOENT && !strcmp(data->file.path, "perf.data")) in open_file_read()
265 data->file.path); in open_file_read()
271 data->file.path); in open_file_read()
275 data->file.size = st.st_size; in open_file_read()
288 fd = open(data->file.path, O_CREAT|O_RDWR|O_TRUNC|O_CLOEXEC, in open_file_write()
292 pr_err("failed to open %s : %s\n", data->file.path, in open_file_write()
306 zfree(&data->file.path); in open_file()
310 data->file.fd = fd; in open_file()
316 data->file.path = strdup(data->path); in open_file_dup()
317 if (!data->file.path) in open_file_dup()
331 if (asprintf(&data->file.path, "%s/data", data->path) < 0) in open_dir()
373 zfree(&data->file.path); in perf_data__close()
376 fclose(data->file.fptr); in perf_data__close()
378 close(data->file.fd); in perf_data__close()
384 if (fread(buf, size, 1, data->file.fptr) == 1) in perf_data__read()
386 return feof(data->file.fptr) ? 0 : -1; in perf_data__read()
388 return readn(data->file.fd, buf, size); in perf_data__read()
391 ssize_t perf_data_file__write(struct perf_data_file *file, in perf_data_file__write() argument
394 return writen(file->fd, buf, size); in perf_data_file__write()
401 if (fwrite(buf, size, 1, data->file.fptr) == 1) in perf_data__write()
405 return perf_data_file__write(&data->file, buf, size); in perf_data__write()
431 close(data->file.fd); in perf_data__switch()
436 if (lseek(data->file.fd, pos, SEEK_SET) == (off_t)-1) { in perf_data__switch()
443 ret = data->file.fd; in perf_data__switch()
450 u64 size = data->file.size; in perf_data__size()
457 struct perf_data_file *file = &data->dir.files[i]; in perf_data__size() local
459 size += file->size; in perf_data__size()
501 FILE *file; in is_perf_data() local
504 file = fopen(path, "r"); in is_perf_data()
505 if (!file) in is_perf_data()
508 if (fread(&magic, 1, 8, file) < 8) in is_perf_data()
513 fclose(file); in is_perf_data()