Lines Matching full:fd

71 static int read_fd(int fd, char *dst, int len)  in read_fd()  argument
77 r = read(fd, dst+size, len); in read_fd()
90 static int read_compressed(int fd, char *dst, int len) in read_compressed() argument
96 return read_fd(fd, dst, len); in read_compressed()
99 static int do_lseek(int fd, int offset, int whence) in do_lseek() argument
104 return lseek64(fd, offset, whence); in do_lseek()
107 static int read_file_string(int fd, char *dst, int len) in read_file_string() argument
113 r = read_compressed(fd, dst+size, 1); in read_file_string()
128 static int read_file_bytes(int fd, char *dst, int len) in read_file_bytes() argument
132 ret = read_compressed(fd, dst, len); in read_file_bytes()
136 static void read_dump_string(int fd, int size, enum dump_items id) in read_dump_string() argument
143 if (read_file_bytes(fd, buf, lsize)) in read_dump_string()
153 static int read_file_number(int fd, void *digit, int size) in read_file_number() argument
161 if (read_file_bytes(fd, buf, size)) in read_file_number()
193 static void dump_initial_format(int fd) in dump_initial_format() argument
202 if (read_file_bytes(fd, buf, sizeof(magic))) in dump_initial_format()
208 if (read_file_bytes(fd, buf, strlen(TRACING_STR))) in dump_initial_format()
215 if (read_file_string(fd, buf, DUMP_SIZE)) in dump_initial_format()
226 if (read_file_bytes(fd, buf, 1)) in dump_initial_format()
234 if (read_file_bytes(fd, buf, 1)) in dump_initial_format()
238 if (read_file_number(fd, &val4, 4)) in dump_initial_format()
243 static void dump_compress(int fd) in dump_compress() argument
252 if (read_file_string(fd, zname, DUMP_SIZE)) in dump_compress()
255 if (read_file_string(fd, zver, DUMP_SIZE)) in dump_compress()
262 compress = tracecmd_compress_alloc(zname, zver, fd, tep, NULL); in dump_compress()
268 static void dump_header_page(int fd) in dump_header_page() argument
276 if (read_file_bytes(fd, buf, strlen(HEAD_PAGE_STR) + 1)) in dump_header_page()
281 if (read_file_number(fd, &size, 8)) in dump_header_page()
286 read_dump_string(fd, size, HEAD_PAGE); in dump_header_page()
289 static void dump_header_event(int fd) in dump_header_event() argument
297 if (read_file_bytes(fd, buf, strlen(HEAD_PAGE_EVENT) + 1)) in dump_header_event()
302 if (read_file_number(fd, &size, 8)) in dump_header_event()
307 read_dump_string(fd, size, HEAD_EVENT); in dump_header_event()
332 static void dump_ftrace_events_format(int fd) in dump_ftrace_events_format() argument
338 if (read_file_number(fd, &count, 4)) in dump_ftrace_events_format()
344 if (read_file_number(fd, &size, 8)) in dump_ftrace_events_format()
346 read_dump_string(fd, size, FTRACE_FORMAT); in dump_ftrace_events_format()
351 static void dump_events_format(int fd) in dump_events_format() argument
360 if (read_file_number(fd, &systems, 4)) in dump_events_format()
367 if (read_file_string(fd, buf, DUMP_SIZE)) in dump_events_format()
369 if (read_file_number(fd, &events, 4)) in dump_events_format()
374 if (read_file_number(fd, &size, 8)) in dump_events_format()
377 read_dump_string(fd, size, EVENT_FORMAT); in dump_events_format()
384 static void dump_kallsyms(int fd) in dump_kallsyms() argument
390 if (read_file_number(fd, &size, 4)) in dump_kallsyms()
395 read_dump_string(fd, size, KALLSYMS); in dump_kallsyms()
398 static void dump_printk(int fd) in dump_printk() argument
404 if (read_file_number(fd, &size, 4)) in dump_printk()
409 read_dump_string(fd, size, TRACE_PRINTK); in dump_printk()
412 static void dump_cmdlines(int fd) in dump_cmdlines() argument
418 if (read_file_number(fd, &size, 8)) in dump_cmdlines()
423 read_dump_string(fd, size, CMDLINES); in dump_cmdlines()
426 static void dump_cpus_count(int fd) in dump_cpus_count() argument
428 if (read_file_number(fd, &trace_cpus, 4)) in dump_cpus_count()
434 static void dump_option_string(int fd, int size, char *desc) in dump_option_string() argument
438 read_dump_string(fd, size, OPTIONS); in dump_option_string()
441 static void dump_section_header(int fd, enum dump_items v, unsigned short *flags) in dump_section_header() argument
449 offset = lseek64(fd, 0, SEEK_CUR); in dump_section_header()
450 if (read_file_number(fd, &id, 2)) in dump_section_header()
453 if (read_file_number(fd, &fl, 2)) in dump_section_header()
456 if (read_file_number(fd, &desc_id, 4)) in dump_section_header()
463 if (read_file_number(fd, &size, 8)) in dump_section_header()
473 static void dump_option_buffer(int fd, unsigned short option, int size) in dump_option_buffer() argument
490 if (read_file_number(fd, &offset, 8)) in dump_option_buffer()
493 if (read_file_string(fd, name, DUMP_SIZE)) in dump_option_buffer()
503 current = lseek64(fd, 0, SEEK_CUR); in dump_option_buffer()
504 if (lseek64(fd, offset, SEEK_SET) == (off_t)-1) in dump_option_buffer()
507 dump_section_header(fd, FLYRECORD, &flags); in dump_option_buffer()
509 if (lseek64(fd, current, SEEK_SET) == (off_t)-1) in dump_option_buffer()
516 if (read_file_string(fd, clock, DUMP_SIZE)) in dump_option_buffer()
521 if (read_file_number(fd, &page_size, 4)) in dump_option_buffer()
525 if (read_file_number(fd, &cpus, 4)) in dump_option_buffer()
530 if (read_file_number(fd, &id, 4)) in dump_option_buffer()
533 if (read_file_number(fd, &offset, 8)) in dump_option_buffer()
536 if (read_file_number(fd, &data_size, 8)) in dump_option_buffer()
552 static void dump_option_int(int fd, int size, char *desc) in dump_option_int() argument
557 read_file_number(fd, &val, size); in dump_option_int()
561 static void dump_option_xlong(int fd, int size, char *desc) in dump_option_xlong() argument
566 read_file_number(fd, &val, size); in dump_option_xlong()
578 static void dump_option_timeshift(int fd, int size) in dump_option_timeshift() argument
598 read_file_number(fd, &trace_id, 8); in dump_option_timeshift()
601 read_file_number(fd, &flags, 4); in dump_option_timeshift()
604 read_file_number(fd, &cpus, 4); in dump_option_timeshift()
613 read_file_number(fd, &cpus_data[j].count, 4); in dump_option_timeshift()
626 read_file_number(fd, cpus_data[j].times + i, 8); in dump_option_timeshift()
632 read_file_number(fd, cpus_data[j].offsets + i, 8); in dump_option_timeshift()
638 read_file_number(fd, cpus_data[j].scalings + i, 8); in dump_option_timeshift()
650 read_file_number(fd, cpus_data[j].frac + i, 8); in dump_option_timeshift()
676 void dump_option_guest(int fd, int size) in dump_option_guest() argument
697 if (read_file_bytes(fd, buf, size)) in dump_option_guest()
735 void dump_option_tsc2nsec(int fd, int size) in dump_option_tsc2nsec() argument
742 if (read_file_number(fd, &mult, 4)) in dump_option_tsc2nsec()
744 if (read_file_number(fd, &shift, 4)) in dump_option_tsc2nsec()
746 if (read_file_number(fd, &offset, 8)) in dump_option_tsc2nsec()
751 static void dump_option_section(int fd, unsigned int size, in dump_option_section() argument
764 if (read_file_number(fd, &sec->offset, 8)) in dump_option_section()
770 static void dump_sections(int fd, int count) in dump_sections() argument
776 if (lseek64(fd, sec->offset, SEEK_SET) == (off_t)-1) in dump_sections()
779 dump_section_header(fd, sec->verbosity, &flags); in dump_sections()
786 dump_header_page(fd); in dump_sections()
787 dump_header_event(fd); in dump_sections()
790 dump_ftrace_events_format(fd); in dump_sections()
793 dump_events_format(fd); in dump_sections()
796 dump_kallsyms(fd); in dump_sections()
799 dump_printk(fd); in dump_sections()
802 dump_cmdlines(fd); in dump_sections()
811 static int dump_options_read(int fd);
813 static int dump_option_done(int fd, int size) in dump_option_done() argument
822 if (read_file_number(fd, &offset, 8)) in dump_option_done()
829 if (lseek64(fd, offset, SEEK_SET) == (off_t)-1) in dump_option_done()
834 return dump_options_read(fd); in dump_option_done()
837 static int dump_options_read(int fd) in dump_options_read() argument
845 dump_section_header(fd, OPTIONS, &flags); in dump_options_read()
851 if (read_file_number(fd, &option, 2)) in dump_options_read()
855 if (read_file_number(fd, &size, 4)) in dump_options_read()
861 dump_option_string(fd, size, "DATE"); in dump_options_read()
864 dump_option_string(fd, size, "CPUSTAT"); in dump_options_read()
868 dump_option_buffer(fd, option, size); in dump_options_read()
872 read_dump_string(fd, size, OPTIONS | CLOCK); in dump_options_read()
876 dump_option_string(fd, size, "UNAME"); in dump_options_read()
879 dump_option_string(fd, size, "HOOK"); in dump_options_read()
882 dump_option_string(fd, size, "OFFSET"); in dump_options_read()
885 dump_option_int(fd, size, "CPUCOUNT"); in dump_options_read()
888 dump_option_string(fd, size, "VERSION"); in dump_options_read()
891 dump_option_string(fd, size, "PROCMAPS"); in dump_options_read()
894 dump_option_xlong(fd, size, "TRACEID"); in dump_options_read()
897 dump_option_timeshift(fd, size); in dump_options_read()
900 dump_option_guest(fd, size); in dump_options_read()
903 dump_option_tsc2nsec(fd, size); in dump_options_read()
906 dump_option_section(fd, size, option, "HEADERS", HEAD_PAGE | HEAD_EVENT); in dump_options_read()
909 dump_option_section(fd, size, option, "FTRACE EVENTS", FTRACE_FORMAT); in dump_options_read()
912 dump_option_section(fd, size, option, in dump_options_read()
916 dump_option_section(fd, size, option, "KALLSYMS", KALLSYMS); in dump_options_read()
919 dump_option_section(fd, size, option, "PRINTK", TRACE_PRINTK); in dump_options_read()
922 dump_option_section(fd, size, option, "CMDLINES", CMDLINES); in dump_options_read()
926 count += dump_option_done(fd, size); in dump_options_read()
931 do_lseek(fd, size, SEEK_CUR); in dump_options_read()
939 static void dump_options(int fd) in dump_options() argument
943 count = dump_options_read(fd); in dump_options()
947 static void dump_latency(int fd) in dump_latency() argument
952 static void dump_clock(int fd) in dump_clock() argument
962 if (read_file_number(fd, &size, 8)) in dump_clock()
968 if (read_file_bytes(fd, clock, size)) in dump_clock()
975 static void dump_flyrecord(int fd) in dump_flyrecord() argument
984 if (read_file_number(fd, &cpu_offset, 8)) in dump_flyrecord()
986 if (read_file_number(fd, &cpu_size, 8)) in dump_flyrecord()
991 dump_clock(fd); in dump_flyrecord()
994 static void dump_therest(int fd) in dump_therest() argument
999 if (read_file_bytes(fd, str, 10)) in dump_therest()
1003 dump_options(fd); in dump_therest()
1005 dump_latency(fd); in dump_therest()
1007 dump_flyrecord(fd); in dump_therest()
1009 lseek64(fd, -10, SEEK_CUR); in dump_therest()
1015 static void dump_v6_file(int fd) in dump_v6_file() argument
1017 dump_header_page(fd); in dump_v6_file()
1018 dump_header_event(fd); in dump_v6_file()
1019 dump_ftrace_events_format(fd); in dump_v6_file()
1020 dump_events_format(fd); in dump_v6_file()
1021 dump_kallsyms(fd); in dump_v6_file()
1022 dump_printk(fd); in dump_v6_file()
1023 dump_cmdlines(fd); in dump_v6_file()
1024 dump_cpus_count(fd); in dump_v6_file()
1025 dump_therest(fd); in dump_v6_file()
1028 static int read_metadata_strings(int fd, unsigned long long size) in read_metadata_strings() argument
1039 ret = read_file_bytes(fd, meta_strings + meta_strings_size, size); in read_metadata_strings()
1056 static void get_meta_strings(int fd) in get_meta_strings() argument
1063 offset = lseek64(fd, 0, SEEK_CUR); in get_meta_strings()
1065 if (read_file_number(fd, &id, 2)) in get_meta_strings()
1067 if (read_file_number(fd, &fl, 2)) in get_meta_strings()
1069 if (read_file_number(fd, &desc_id, 4)) in get_meta_strings()
1071 if (read_file_number(fd, &size, 8)) in get_meta_strings()
1075 read_file_number(fd, &csize, 4); in get_meta_strings()
1076 read_file_number(fd, &rsize, 4); in get_meta_strings()
1077 lseek64(fd, -8, SEEK_CUR); in get_meta_strings()
1083 read_metadata_strings(fd, rsize); in get_meta_strings()
1086 if (lseek64(fd, size, SEEK_CUR) == (off_t)-1) in get_meta_strings()
1091 if (lseek64(fd, offset, SEEK_SET) == (off_t)-1) in get_meta_strings()
1095 static int walk_v7_sections(int fd) in walk_v7_sections() argument
1105 offset = lseek64(fd, 0, SEEK_CUR); in walk_v7_sections()
1107 soffset = lseek64(fd, 0, SEEK_CUR); in walk_v7_sections()
1108 if (read_file_number(fd, &id, 2)) in walk_v7_sections()
1111 if (read_file_number(fd, &fl, 2)) in walk_v7_sections()
1114 if (read_file_number(fd, &desc_id, 4)) in walk_v7_sections()
1121 if (read_file_number(fd, &size, 8)) in walk_v7_sections()
1136 if (read_file_number(fd, &csize, 4)) in walk_v7_sections()
1139 if (read_file_number(fd, &rsize, 4)) in walk_v7_sections()
1152 if (lseek64(fd, size, SEEK_CUR) == (off_t)-1) in walk_v7_sections()
1156 if (lseek64(fd, offset, SEEK_SET) == (off_t)-1) in walk_v7_sections()
1162 static void dump_v7_file(int fd) in dump_v7_file() argument
1167 if (read_file_number(fd, &offset, 8)) in dump_v7_file()
1170 get_meta_strings(fd); in dump_v7_file()
1171 sections = walk_v7_sections(fd); in dump_v7_file()
1173 if (lseek64(fd, offset, SEEK_SET) == (off_t)-1) in dump_v7_file()
1176 dump_options(fd); in dump_v7_file()
1177 dump_sections(fd, sections); in dump_v7_file()
1193 int fd; in dump_file() local
1199 fd = open(file, O_RDONLY); in dump_file()
1200 if (fd < 0) in dump_file()
1205 dump_initial_format(fd); in dump_file()
1206 dump_compress(fd); in dump_file()
1208 dump_v6_file(fd); in dump_file()
1210 dump_v7_file(fd); in dump_file()
1214 close(fd); in dump_file()