2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.0 (the 'License'). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
26 cc -I. -DKERNEL_PRIVATE -O -o fs_usage fs_usage.c
29 #define Default_DELAY 1 /* default delay interval */
39 #include <sys/types.h>
40 #include <sys/param.h>
45 #include <bsd/curses.h>
46 #include <sys/ioctl.h>
48 #ifndef KERNEL_PRIVATE
49 #define KERNEL_PRIVATE
50 #include <sys/kdebug.h>
53 #include <sys/kdebug.h>
54 #endif /*KERNEL_PRIVATE*/
56 #include <sys/sysctl.h>
58 #import <mach/clock_types.h>
64 MAXCOLS controls when extra data kicks in.
65 MAX_WIDE_MODE_COLS controls -w mode to get even wider data in path.
66 If NUMPARMS changes to match the kernel, it will automatically
67 get reflected in the -w mode output.
70 #define PATHLENGTH (NUMPARMS*sizeof(long))
72 #define MAX_WIDE_MODE_COLS (PATHLENGTH + 80)
86 char pathname
[PATHLENGTH
+ 1]; /* add room for null terminator */
89 #define MAX_THREADS 512
90 struct th_info th_state
[MAX_THREADS
];
97 int select_pid_mode
= 0; /* Flag set indicates that output is restricted
98 to selected pids or commands */
100 int one_good_pid
= 0; /* Used to fail gracefully when bad pids given */
103 #define DBG_ZERO_FILL_FAULT 1
104 #define DBG_PAGEIN_FAULT 2
105 #define DBG_COW_FAULT 3
106 #define DBG_CACHE_HIT_FAULT 4
108 #define TRACE_DATA_NEWTHREAD 0x07000004
109 #define TRACE_STRING_NEWTHREAD 0x07010004
110 #define TRACE_STRING_EXEC 0x07010008
112 #define MACH_vmfault 0x01300000
113 #define MACH_sched 0x01400000
114 #define MACH_stkhandoff 0x01400008
115 #define VFS_LOOKUP 0x03010090
116 #define BSC_exit 0x040C0004
118 #define MSC_map_fd 0x010c00ac
119 #define BSC_recvmsg 0x040C006C
120 #define BSC_sendmsg 0x040C0070
121 #define BSC_recvfrom 0x040C0074
122 #define BSC_sendto 0x040C0214
124 #define BSC_read 0x040C000C
125 #define BSC_write 0x040C0010
126 #define BSC_open 0x040C0014
127 #define BSC_close 0x040C0018
128 #define BSC_link 0x040C0024
129 #define BSC_unlink 0x040C0028
130 #define BSC_mknod 0x040C0038
131 #define BSC_chmod 0x040C003C
132 #define BSC_chown 0x040C0040
133 #define BSC_access 0x040C0084
134 #define BSC_chflags 0x040C0088
135 #define BSC_fchflags 0x040C008C
136 #define BSC_sync 0x040C0090
137 #define BSC_symlink 0x040C00E4
138 #define BSC_readlink 0x040C00E8
139 #define BSC_fsync 0x040C017C
140 #define BSC_readv 0x040C01E0
141 #define BSC_writev 0x040C01E4
142 #define BSC_fchown 0x040C01EC
143 #define BSC_fchmod 0x040C01F0
144 #define BSC_rename 0x040C0200
145 #define BSC_mkdir 0x040C0220
146 #define BSC_rmdir 0x040C0224
147 #define BSC_statfs 0x040C0274
148 #define BSC_fstatfs 0x040C0278
149 #define BSC_stat 0x040C02F0
150 #define BSC_fstat 0x040C02F4
151 #define BSC_lstat 0x040C02F8
152 #define BSC_pathconf 0x040C02FC
153 #define BSC_fpathconf 0x040C0300
154 #define BSC_getdirentries 0x040C0310
155 #define BSC_mmap 0x040c0314
156 #define BSC_lseek 0x040c031c
157 #define BSC_truncate 0x040C0320
158 #define BSC_ftruncate 0x040C0324
159 #define BSC_statv 0x040C0364
160 #define BSC_lstatv 0x040C0368
161 #define BSC_fstatv 0x040C036C
162 #define BSC_mkcomplex 0x040C0360
163 #define BSC_getattrlist 0x040C0370
164 #define BSC_setattrlist 0x040C0374
165 #define BSC_getdirentriesattr 0x040C0378
166 #define BSC_exchangedata 0x040C037C
167 #define BSC_checkuseraccess 0x040C0380
168 #define BSC_searchfs 0x040C0384
170 // Carbon File Manager support
171 #define FILEMGR_PBGETCATALOGINFO 0x1e000020
172 #define FILEMGR_PBGETCATALOGINFOBULK 0x1e000024
173 #define FILEMGR_PBCREATEFILEUNICODE 0x1e000028
174 #define FILEMGR_PBCREATEDIRECTORYUNICODE 0x1e00002c
175 #define FILEMGR_PBCREATEFORK 0x1e000030
176 #define FILEMGR_PBDELETEFORK 0x1e000034
177 #define FILEMGR_PBITERATEFORK 0x1e000038
178 #define FILEMGR_PBOPENFORK 0x1e00003c
179 #define FILEMGR_PBREADFORK 0x1e000040
180 #define FILEMGR_PBWRITEFORK 0x1e000044
181 #define FILEMGR_PBALLOCATEFORK 0x1e000048
182 #define FILEMGR_PBDELETEOBJECT 0x1e00004c
183 #define FILEMGR_PBEXCHANGEOBJECT 0x1e000050
184 #define FILEMGR_PBGETFORKCBINFO 0x1e000054
185 #define FILEMGR_PBGETVOLUMEINFO 0x1e000058
186 #define FILEMGR_PBMAKEFSREF 0x1e00005c
187 #define FILEMGR_PBMAKEFSREFUNICODE 0x1e000060
188 #define FILEMGR_PBMOVEOBJECT 0x1e000064
189 #define FILEMGR_PBOPENITERATOR 0x1e000068
190 #define FILEMGR_PBRENAMEUNICODE 0x1e00006c
191 #define FILEMGR_PBSETCATALOGINFO 0x1e000070
192 #define FILEMGR_PBSETVOLUMEINFO 0x1e000074
193 #define FILEMGR_FSREFMAKEPATH 0x1e000078
194 #define FILEMGR_FSPATHMAKEREF 0x1e00007c
196 #define FILEMGR_PBGETCATINFO 0x1e010000
197 #define FILEMGR_PBGETCATINFOLITE 0x1e010004
198 #define FILEMGR_PBHGETFINFO 0x1e010008
199 #define FILEMGR_PBXGETVOLINFO 0x1e01000c
200 #define FILEMGR_PBHCREATE 0x1e010010
201 #define FILEMGR_PBHOPENDF 0x1e010014
202 #define FILEMGR_PBHOPENRF 0x1e010018
203 #define FILEMGR_PBHGETDIRACCESS 0x1e01001c
204 #define FILEMGR_PBHSETDIRACCESS 0x1e010020
205 #define FILEMGR_PBHMAPID 0x1e010024
206 #define FILEMGR_PBHMAPNAME 0x1e010028
207 #define FILEMGR_PBCLOSE 0x1e01002c
208 #define FILEMGR_PBFLUSHFILE 0x1e010030
209 #define FILEMGR_PBGETEOF 0x1e010034
210 #define FILEMGR_PBSETEOF 0x1e010038
211 #define FILEMGR_PBGETFPOS 0x1e01003c
212 #define FILEMGR_PBREAD 0x1e010040
213 #define FILEMGR_PBWRITE 0x1e010044
214 #define FILEMGR_PBGETFCBINFO 0x1e010048
215 #define FILEMGR_PBSETFINFO 0x1e01004c
216 #define FILEMGR_PBALLOCATE 0x1e010050
217 #define FILEMGR_PBALLOCCONTIG 0x1e010054
218 #define FILEMGR_PBSETFPOS 0x1e010058
219 #define FILEMGR_PBSETCATINFO 0x1e01005c
220 #define FILEMGR_PBGETVOLPARMS 0x1e010060
221 #define FILEMGR_PBSETVINFO 0x1e010064
222 #define FILEMGR_PBMAKEFSSPEC 0x1e010068
223 #define FILEMGR_PBHGETVINFO 0x1e01006c
224 #define FILEMGR_PBCREATEFILEIDREF 0x1e010070
225 #define FILEMGR_PBDELETEFILEIDREF 0x1e010074
226 #define FILEMGR_PBRESOLVEFILEIDREF 0x1e010078
227 #define FILEMGR_PBFLUSHVOL 0x1e01007c
228 #define FILEMGR_PBHRENAME 0x1e010080
229 #define FILEMGR_PBCATMOVE 0x1e010084
230 #define FILEMGR_PBEXCHANGEFILES 0x1e010088
231 #define FILEMGR_PBHDELETE 0x1e01008c
232 #define FILEMGR_PBDIRCREATE 0x1e010090
233 #define FILEMGR_PBCATSEARCH 0x1e010094
234 #define FILEMGR_PBHSETFLOCK 0x1e010098
235 #define FILEMGR_PBHRSTFLOCK 0x1e01009c
236 #define FILEMGR_PBLOCKRANGE 0x1e0100a0
237 #define FILEMGR_PBUNLOCKRANGE 0x1e0100a4
240 #define FILEMGR_CLASS 0x1e
246 int exclude_pids
= 0;
247 int exclude_default_pids
= 1;
249 struct kinfo_proc
*kp_buffer
= 0;
252 #define SAMPLE_SIZE 60000
254 #define DBG_ZERO_FILL_FAULT 1
255 #define DBG_PAGEIN_FAULT 2
256 #define DBG_COW_FAULT 3
257 #define DBG_CACHE_HIT_FAULT 4
259 #define DBG_FUNC_ALL (DBG_FUNC_START | DBG_FUNC_END)
260 #define DBG_FUNC_MASK 0xfffffffc
262 /* Default divisor */
263 #define DIVISOR 16.6666 /* Trace divisor converts to microseconds */
264 double divisor
= DIVISOR
;
270 kbufinfo_t bufinfo
= {0, 0, 0, 0};
272 int total_threads
= 0;
273 kd_threadmap
*mapptr
= 0;
275 int trace_enabled
= 0;
276 int set_remove_flag
= 1;
288 void leave() /* exit under normal conditions -- INT handler */
293 void set_pidexclude();
298 if (exclude_pids
== 0) {
299 for (i
= 0; i
< num_of_pids
; i
++)
300 set_pidcheck(pids
[i
], 0);
303 for (i
= 0; i
< num_of_pids
; i
++)
304 set_pidexclude(pids
[i
], 0);
320 fprintf(stderr
, "Usage: %s [-e] [-w] [pid | cmd [pid | cmd]....]\n", myname
);
321 fprintf(stderr
, " -e exclude the specified list of pids from the sample\n");
322 fprintf(stderr
, " and exclude fs_usage by default\n");
323 fprintf(stderr
, " -w force wider, detailed, output\n");
324 fprintf(stderr
, " pid selects process(s) to sample\n");
325 fprintf(stderr
, " cmd selects process(s) matching command string to sample\n");
326 fprintf(stderr
, "\n%s will handle a maximum list of %d pids.\n\n", myname
, MAX_PIDS
);
327 fprintf(stderr
, "By default (no options) the following processes are excluded from the output:\n");
328 fprintf(stderr
, "fs_usage, Terminal, telnetd, sshd, rlogind, tcsh, csh, sh\n\n");
338 char *myname
= "fs_usage";
345 void set_pidexclude();
348 if ( geteuid() != 0 ) {
349 printf("'fs_usage' must be run as root...\n");
357 if ((myname
= rindex(argv
[0], '/')) == 0) {
365 while ((ch
= getopt(argc
, argv
, "ew")) != EOF
) {
369 exclude_default_pids
= 0;
373 if (COLS
< MAX_WIDE_MODE_COLS
)
374 COLS
= MAX_WIDE_MODE_COLS
;
384 /* If we process any list of pids/cmds, then turn off the defaults */
386 exclude_default_pids
= 0;
388 while (argc
> 0 && num_of_pids
< (MAX_PIDS
- 1)) {
395 /* Exclude a set of default pids */
396 if (exclude_default_pids
)
398 argtopid("Terminal");
410 if (num_of_pids
< (MAX_PIDS
- 1))
411 pids
[num_of_pids
++] = getpid();
417 for (i
= 0; i
< num_of_pids
; i
++)
420 printf("exclude pid %d\n", pids
[i
]);
422 printf("pid %d\n", pids
[i
]);
426 /* set up signal handlers */
427 signal(SIGINT
, leave
);
428 signal(SIGQUIT
, leave
);
429 signal(SIGTERM
, leave
);
430 signal(SIGWINCH
, sigwinch
);
432 if ((my_buffer
= malloc(SAMPLE_SIZE
* sizeof(kd_buf
))) == (char *)0)
433 quit("can't allocate memory for tracing info\n");
436 set_numbufs(SAMPLE_SIZE
);
439 if (exclude_pids
== 0) {
440 for (i
= 0; i
< num_of_pids
; i
++)
441 set_pidcheck(pids
[i
], 1);
443 for (i
= 0; i
< num_of_pids
; i
++)
444 set_pidexclude(pids
[i
], 1);
447 if (select_pid_mode
&& !one_good_pid
)
450 An attempt to restrict output to a given
451 pid or command has failed. Exit gracefully
474 struct kinfo_proc
*kp
;
479 mib
[2] = KERN_PROC_ALL
;
482 if (sysctl(mib
, 4, NULL
, &bufSize
, NULL
, 0) < 0)
483 quit("trace facility failure, KERN_PROC_ALL\n");
485 if((kp
= (struct kinfo_proc
*)malloc(bufSize
)) == (struct kinfo_proc
*)0)
486 quit("can't allocate memory for proc buffer\n");
488 if (sysctl(mib
, 4, kp
, &bufSize
, NULL
, 0) < 0)
489 quit("trace facility failure, KERN_PROC_ALL\n");
491 kp_nentries
= bufSize
/ sizeof(struct kinfo_proc
);
496 struct th_info
*find_thread(int thread
, int type
) {
499 for (ti
= th_state
; ti
< &th_state
[cur_max
]; ti
++) {
500 if (ti
->thread
== thread
) {
501 if (type
== ti
->type
)
503 if (ti
->in_filemgr
) {
512 return ((struct th_info
*)0);
519 mib
[1] = KERN_KDEBUG
;
520 mib
[2] = KERN_KDENABLE
; /* protocol */
523 mib
[5] = 0; /* no flags */
524 if (sysctl(mib
, 4, NULL
, &needed
, NULL
, 0) < 0)
525 quit("trace facility failure, KERN_KDENABLE\n");
534 set_numbufs(int nbufs
)
537 mib
[1] = KERN_KDEBUG
;
538 mib
[2] = KERN_KDSETBUF
;
541 mib
[5] = 0; /* no flags */
542 if (sysctl(mib
, 4, NULL
, &needed
, NULL
, 0) < 0)
543 quit("trace facility failure, KERN_KDSETBUF\n");
546 mib
[1] = KERN_KDEBUG
;
547 mib
[2] = KERN_KDSETUP
;
550 mib
[5] = 0; /* no flags */
551 if (sysctl(mib
, 3, NULL
, &needed
, NULL
, 0) < 0)
552 quit("trace facility failure, KERN_KDSETUP\n");
556 set_pidcheck(int pid
, int on_off
)
560 kr
.type
= KDBG_TYPENONE
;
563 needed
= sizeof(kd_regtype
);
565 mib
[1] = KERN_KDEBUG
;
566 mib
[2] = KERN_KDPIDTR
;
571 if (sysctl(mib
, 3, &kr
, &needed
, NULL
, 0) < 0) {
573 printf("pid %d does not exist\n", pid
);
581 on_off == 0 turns off pid exclusion
582 on_off == 1 turns on pid exclusion
585 set_pidexclude(int pid
, int on_off
)
591 kr
.type
= KDBG_TYPENONE
;
594 needed
= sizeof(kd_regtype
);
596 mib
[1] = KERN_KDEBUG
;
597 mib
[2] = KERN_KDPIDEX
;
602 if (sysctl(mib
, 3, &kr
, &needed
, NULL
, 0) < 0) {
604 printf("pid %d does not exist\n", pid
);
609 get_bufinfo(kbufinfo_t
*val
)
611 needed
= sizeof (*val
);
613 mib
[1] = KERN_KDEBUG
;
614 mib
[2] = KERN_KDGETBUF
;
617 mib
[5] = 0; /* no flags */
619 if (sysctl(mib
, 3, val
, &needed
, 0, 0) < 0)
620 quit("trace facility failure, KERN_KDGETBUF\n");
632 mib
[1] = KERN_KDEBUG
;
633 mib
[2] = KERN_KDREMOVE
; /* protocol */
636 mib
[5] = 0; /* no flags */
637 if (sysctl(mib
, 3, NULL
, &needed
, NULL
, 0) < 0)
642 quit("the trace facility is currently in use...\n fs_usage, sc_usage, and latency use this feature.\n\n");
644 quit("trace facility failure, KERN_KDREMOVE\n");
652 kr
.type
= KDBG_RANGETYPE
;
655 needed
= sizeof(kd_regtype
);
657 mib
[1] = KERN_KDEBUG
;
658 mib
[2] = KERN_KDSETREG
;
661 mib
[5] = 0; /* no flags */
663 if (sysctl(mib
, 3, &kr
, &needed
, NULL
, 0) < 0)
664 quit("trace facility failure, KERN_KDSETREG\n");
667 mib
[1] = KERN_KDEBUG
;
668 mib
[2] = KERN_KDSETUP
;
671 mib
[5] = 0; /* no flags */
673 if (sysctl(mib
, 3, NULL
, &needed
, NULL
, 0) < 0)
674 quit("trace facility failure, KERN_KDSETUP\n");
683 void read_command_map();
684 void create_map_entry();
686 /* Get kernel buffer information */
687 get_bufinfo(&bufinfo
);
693 needed
= bufinfo
.nkdbufs
* sizeof(kd_buf
);
695 mib
[1] = KERN_KDEBUG
;
696 mib
[2] = KERN_KDREADTR
;
699 mib
[5] = 0; /* no flags */
701 if (sysctl(mib
, 3, my_buffer
, &needed
, NULL
, 0) < 0)
702 quit("trace facility failure, KERN_KDREADTR\n");
705 if (bufinfo
.flags
& KDBG_WRAPPED
) {
706 printf("buffer wrapped count = %d\n", count
);
708 for (i
= 0; i
< cur_max
; i
++) {
709 th_state
[i
].thread
= 0;
710 th_state
[i
].pathptr
= (long *)0;
711 th_state
[i
].pathname
[0] = 0;
719 kd
= (kd_buf
*)my_buffer
;
721 printf("READTR returned %d items\n", count
);
723 for (i
= 0; i
< count
; i
++) {
727 unsigned long long now
;
729 void enter_syscall();
731 void kill_thread_map();
733 thread
= kd
[i
].arg5
& KDBG_THREAD_MASK
;
734 debugid
= kd
[i
].debugid
;
735 type
= kd
[i
].debugid
& DBG_FUNC_MASK
;
739 case TRACE_DATA_NEWTHREAD
:
741 for (n
= 0, ti
= th_state
; ti
< &th_state
[MAX_THREADS
]; ti
++, n
++) {
745 if (ti
== &th_state
[MAX_THREADS
])
751 ti
->child_thread
= kd
[i
].arg1
;
754 case TRACE_STRING_NEWTHREAD
:
755 if ((ti
= find_thread(thread
, 0)) == (struct th_info
*)0)
757 if (ti
->child_thread
== 0)
759 create_map_entry(ti
->child_thread
, (char *)&kd
[i
].arg1
);
761 if (ti
== &th_state
[cur_max
- 1])
763 ti
->child_thread
= 0;
767 case TRACE_STRING_EXEC
:
768 create_map_entry(thread
, (char *)&kd
[i
].arg1
);
772 kill_thread_map(thread
);
776 case MACH_stkhandoff
:
777 if (ti
= find_thread(thread
, 0))
782 if ((ti
= find_thread(thread
, 0)) == (struct th_info
*)0)
786 sargptr
= (long *)&ti
->pathname
[0];
787 memset(&ti
->pathname
[0], 0, (PATHLENGTH
+ 1));
788 *sargptr
++ = kd
[i
].arg2
;
789 *sargptr
++ = kd
[i
].arg3
;
790 *sargptr
++ = kd
[i
].arg4
;
791 ti
->pathptr
= sargptr
;
794 sargptr
= ti
->pathptr
;
797 We don't want to overrun our pathname buffer if the
798 kernel sends us more VFS_LOOKUP entries than we can
802 if ((long *)sargptr
>= (long *)&ti
->pathname
[PATHLENGTH
])
805 *sargptr
++ = kd
[i
].arg1
;
806 *sargptr
++ = kd
[i
].arg2
;
807 *sargptr
++ = kd
[i
].arg3
;
808 *sargptr
++ = kd
[i
].arg4
;
809 ti
->pathptr
= sargptr
;
813 now
= (((unsigned long long)kd
[i
].timestamp
.tv_sec
) << 32) |
814 (unsigned long long)((unsigned int)(kd
[i
].timestamp
.tv_nsec
));
816 if (debugid
& DBG_FUNC_START
) {
820 case FILEMGR_PBGETCATALOGINFO
:
821 p
= "GetCatalogInfo";
823 case FILEMGR_PBGETCATALOGINFOBULK
:
824 p
= "GetCatalogInfoBulk";
826 case FILEMGR_PBCREATEFILEUNICODE
:
827 p
= "CreateFileUnicode";
829 case FILEMGR_PBCREATEDIRECTORYUNICODE
:
830 p
= "CreateDirectoryUnicode";
832 case FILEMGR_PBCREATEFORK
:
835 case FILEMGR_PBDELETEFORK
:
838 case FILEMGR_PBITERATEFORK
:
841 case FILEMGR_PBOPENFORK
:
844 case FILEMGR_PBREADFORK
:
847 case FILEMGR_PBWRITEFORK
:
850 case FILEMGR_PBALLOCATEFORK
:
851 p
= "PBAllocateFork";
853 case FILEMGR_PBDELETEOBJECT
:
854 p
= "PBDeleteObject";
856 case FILEMGR_PBEXCHANGEOBJECT
:
857 p
= "PBExchangeObject";
859 case FILEMGR_PBGETFORKCBINFO
:
860 p
= "PBGetForkCBInfo";
862 case FILEMGR_PBGETVOLUMEINFO
:
863 p
= "PBGetVolumeInfo";
865 case FILEMGR_PBMAKEFSREF
:
868 case FILEMGR_PBMAKEFSREFUNICODE
:
869 p
= "PBMakeFSRefUnicode";
871 case FILEMGR_PBMOVEOBJECT
:
874 case FILEMGR_PBOPENITERATOR
:
875 p
= "PBOpenIterator";
877 case FILEMGR_PBRENAMEUNICODE
:
878 p
= "PBRenameUnicode";
880 case FILEMGR_PBSETCATALOGINFO
:
881 p
= "SetCatalogInfo";
883 case FILEMGR_PBSETVOLUMEINFO
:
886 case FILEMGR_FSREFMAKEPATH
:
889 case FILEMGR_FSPATHMAKEREF
:
893 case FILEMGR_PBGETCATINFO
:
896 case FILEMGR_PBGETCATINFOLITE
:
897 p
= "GetCatInfoLite";
899 case FILEMGR_PBHGETFINFO
:
902 case FILEMGR_PBXGETVOLINFO
:
905 case FILEMGR_PBHCREATE
:
908 case FILEMGR_PBHOPENDF
:
911 case FILEMGR_PBHOPENRF
:
914 case FILEMGR_PBHGETDIRACCESS
:
915 p
= "PBHGetDirAccess";
917 case FILEMGR_PBHSETDIRACCESS
:
918 p
= "PBHSetDirAccess";
920 case FILEMGR_PBHMAPID
:
923 case FILEMGR_PBHMAPNAME
:
926 case FILEMGR_PBCLOSE
:
929 case FILEMGR_PBFLUSHFILE
:
932 case FILEMGR_PBGETEOF
:
935 case FILEMGR_PBSETEOF
:
938 case FILEMGR_PBGETFPOS
:
944 case FILEMGR_PBWRITE
:
947 case FILEMGR_PBGETFCBINFO
:
950 case FILEMGR_PBSETFINFO
:
953 case FILEMGR_PBALLOCATE
:
956 case FILEMGR_PBALLOCCONTIG
:
959 case FILEMGR_PBSETFPOS
:
962 case FILEMGR_PBSETCATINFO
:
965 case FILEMGR_PBGETVOLPARMS
:
968 case FILEMGR_PBSETVINFO
:
971 case FILEMGR_PBMAKEFSSPEC
:
974 case FILEMGR_PBHGETVINFO
:
977 case FILEMGR_PBCREATEFILEIDREF
:
978 p
= "PBCreateFileIDRef";
980 case FILEMGR_PBDELETEFILEIDREF
:
981 p
= "PBDeleteFileIDRef";
983 case FILEMGR_PBRESOLVEFILEIDREF
:
984 p
= "PBResolveFileIDRef";
986 case FILEMGR_PBFLUSHVOL
:
989 case FILEMGR_PBHRENAME
:
992 case FILEMGR_PBCATMOVE
:
995 case FILEMGR_PBEXCHANGEFILES
:
996 p
= "PBExchangeFiles";
998 case FILEMGR_PBHDELETE
:
1001 case FILEMGR_PBDIRCREATE
:
1004 case FILEMGR_PBCATSEARCH
:
1007 case FILEMGR_PBHSETFLOCK
:
1010 case FILEMGR_PBHRSTFLOCK
:
1013 case FILEMGR_PBLOCKRANGE
:
1016 case FILEMGR_PBUNLOCKRANGE
:
1017 p
= "PBUnlockRange";
1023 enter_syscall(thread
, type
, &kd
[i
], p
, (double)now
);
1029 if (kd
[i
].arg2
== DBG_PAGEIN_FAULT
)
1030 exit_syscall("PAGE_IN", thread
, type
, 0, kd
[i
].arg1
, 0, 2, (double)now
);
1032 if (ti
= find_thread(thread
, type
)) {
1033 if (ti
== &th_state
[cur_max
- 1])
1041 exit_syscall("map_fd", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 0, (double)now
);
1045 exit_syscall("mmap", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1049 exit_syscall("recvmsg", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 1, (double)now
);
1053 exit_syscall("sendmsg", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 1, (double)now
);
1057 exit_syscall("recvfrom", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 1, (double)now
);
1061 exit_syscall("sendto", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 1, (double)now
);
1065 exit_syscall("stat", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1069 exit_syscall("open", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 2, 0, (double)now
);
1073 exit_syscall("close", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 0, (double)now
);
1077 exit_syscall("read", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 1, (double)now
);
1081 exit_syscall("write", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 1, (double)now
);
1085 exit_syscall("fstat", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 0, (double)now
);
1089 exit_syscall("lstat", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1093 exit_syscall("link", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1097 exit_syscall("unlink", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1101 exit_syscall("mknod", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1105 exit_syscall("chmod", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1109 exit_syscall("chown", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1113 exit_syscall("access", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1117 exit_syscall("chflags", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1121 exit_syscall("fchflags", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 0, (double)now
);
1125 exit_syscall("sync", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1129 exit_syscall("symlink", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1133 exit_syscall("readlink", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1137 exit_syscall("fsync", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 0, (double)now
);
1141 exit_syscall("readv", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 1, (double)now
);
1145 exit_syscall("writev", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 1, (double)now
);
1149 exit_syscall("fchown", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 0, (double)now
);
1153 exit_syscall("fchmod", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 0, (double)now
);
1157 exit_syscall("rename", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1161 exit_syscall("mkdir", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1165 exit_syscall("rmdir", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1169 exit_syscall("statfs", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1173 exit_syscall("fstatfs", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 0, (double)now
);
1177 exit_syscall("pathconf", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1181 exit_syscall("fpathconf", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 0, (double)now
);
1184 case BSC_getdirentries
:
1185 exit_syscall("getdirentries", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 1, (double)now
);
1189 exit_syscall("lseek", thread
, type
, kd
[i
].arg1
, kd
[i
].arg3
, 1, 5, (double)now
);
1193 exit_syscall("truncate", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1197 exit_syscall("ftruncate", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 3, (double)now
);
1201 exit_syscall("statv", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1205 exit_syscall("lstatv", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1209 exit_syscall("fstatv", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 1, 0, (double)now
);
1213 exit_syscall("mkcomplex", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1216 case BSC_getattrlist
:
1217 exit_syscall("getattrlist", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1220 case BSC_setattrlist
:
1221 exit_syscall("setattrlist", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1224 case BSC_getdirentriesattr
:
1225 exit_syscall("getdirentriesattr", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 1, (double)now
);
1228 case BSC_exchangedata
:
1229 exit_syscall("exchangedata", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1232 case BSC_checkuseraccess
:
1233 exit_syscall("checkuseraccess", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1237 exit_syscall("searchfs", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1240 case FILEMGR_PBGETCATALOGINFO
:
1241 exit_syscall("GetCatalogInfo", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1243 case FILEMGR_PBGETCATALOGINFOBULK
:
1244 exit_syscall("GetCatalogInfoBulk", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1246 case FILEMGR_PBCREATEFILEUNICODE
:
1247 exit_syscall("CreateFileUnicode", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1249 case FILEMGR_PBCREATEDIRECTORYUNICODE
:
1250 exit_syscall("CreateDirectoryUnicode", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1252 case FILEMGR_PBCREATEFORK
:
1253 exit_syscall("PBCreateFork", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1255 case FILEMGR_PBDELETEFORK
:
1256 exit_syscall("PBDeleteFork", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1258 case FILEMGR_PBITERATEFORK
:
1259 exit_syscall("PBIterateFork", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1261 case FILEMGR_PBOPENFORK
:
1262 exit_syscall("PBOpenFork", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1264 case FILEMGR_PBREADFORK
:
1265 exit_syscall("PBReadFork", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1267 case FILEMGR_PBWRITEFORK
:
1268 exit_syscall("PBWriteFork", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1270 case FILEMGR_PBALLOCATEFORK
:
1271 exit_syscall("PBAllocateFork", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1273 case FILEMGR_PBDELETEOBJECT
:
1274 exit_syscall("PBDeleteObject", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1276 case FILEMGR_PBEXCHANGEOBJECT
:
1277 exit_syscall("PBExchangeObject", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1279 case FILEMGR_PBGETFORKCBINFO
:
1280 exit_syscall("PBGetForkCBInfo", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1282 case FILEMGR_PBGETVOLUMEINFO
:
1283 exit_syscall("PBGetVolumeInfo", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1285 case FILEMGR_PBMAKEFSREF
:
1286 exit_syscall("PBMakeFSRef", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1288 case FILEMGR_PBMAKEFSREFUNICODE
:
1289 exit_syscall("PBMakeFSRefUnicode", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1291 case FILEMGR_PBMOVEOBJECT
:
1292 exit_syscall("PBMoveObject", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1294 case FILEMGR_PBOPENITERATOR
:
1295 exit_syscall("PBOpenIterator", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1297 case FILEMGR_PBRENAMEUNICODE
:
1298 exit_syscall("PBRenameUnicode", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1300 case FILEMGR_PBSETCATALOGINFO
:
1301 exit_syscall("PBSetCatalogInfo", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1303 case FILEMGR_PBSETVOLUMEINFO
:
1304 exit_syscall("PBSetVolumeInfo", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1306 case FILEMGR_FSREFMAKEPATH
:
1307 exit_syscall("FSRefMakePath", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1309 case FILEMGR_FSPATHMAKEREF
:
1310 exit_syscall("FSPathMakeRef", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1312 case FILEMGR_PBGETCATINFO
:
1313 exit_syscall("GetCatInfo", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1315 case FILEMGR_PBGETCATINFOLITE
:
1316 exit_syscall("GetCatInfoLite", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1318 case FILEMGR_PBHGETFINFO
:
1319 exit_syscall("PBHGetFInfo", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1321 case FILEMGR_PBXGETVOLINFO
:
1322 exit_syscall("PBXGetVolInfo", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1324 case FILEMGR_PBHCREATE
:
1325 exit_syscall("PBHCreate", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1327 case FILEMGR_PBHOPENDF
:
1328 exit_syscall("PBHOpenDF", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1330 case FILEMGR_PBHOPENRF
:
1331 exit_syscall("PBHOpenRF", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1333 case FILEMGR_PBHGETDIRACCESS
:
1334 exit_syscall("PBHGetDirAccess", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1336 case FILEMGR_PBHSETDIRACCESS
:
1337 exit_syscall("PBHSetDirAccess", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1339 case FILEMGR_PBHMAPID
:
1340 exit_syscall("PBHMapID", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1342 case FILEMGR_PBHMAPNAME
:
1343 exit_syscall("PBHMapName", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1345 case FILEMGR_PBCLOSE
:
1346 exit_syscall("PBClose", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1348 case FILEMGR_PBFLUSHFILE
:
1349 exit_syscall("PBFlushFile", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1351 case FILEMGR_PBGETEOF
:
1352 exit_syscall("PBGetEOF", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1354 case FILEMGR_PBSETEOF
:
1355 exit_syscall("PBSetEOF", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1357 case FILEMGR_PBGETFPOS
:
1358 exit_syscall("PBGetFPos", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1360 case FILEMGR_PBREAD
:
1361 exit_syscall("PBRead", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1363 case FILEMGR_PBWRITE
:
1364 exit_syscall("PBWrite", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1366 case FILEMGR_PBGETFCBINFO
:
1367 exit_syscall("PBGetFCBInfo", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1369 case FILEMGR_PBSETFINFO
:
1370 exit_syscall("PBSetFInfo", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1372 case FILEMGR_PBALLOCATE
:
1373 exit_syscall("PBAllocate", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1375 case FILEMGR_PBALLOCCONTIG
:
1376 exit_syscall("PBAllocContig", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1378 case FILEMGR_PBSETFPOS
:
1379 exit_syscall("PBSetFPos", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1381 case FILEMGR_PBSETCATINFO
:
1382 exit_syscall("PBSetCatInfo", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1384 case FILEMGR_PBGETVOLPARMS
:
1385 exit_syscall("PBGetVolParms", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1387 case FILEMGR_PBSETVINFO
:
1388 exit_syscall("PBSetVInfo", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1390 case FILEMGR_PBMAKEFSSPEC
:
1391 exit_syscall("PBMakeFSSpec", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1393 case FILEMGR_PBHGETVINFO
:
1394 exit_syscall("PBHGetVInfo", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1396 case FILEMGR_PBCREATEFILEIDREF
:
1397 exit_syscall("PBCreateFileIDRef", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1399 case FILEMGR_PBDELETEFILEIDREF
:
1400 exit_syscall("PBDeleteFileIDRef", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1402 case FILEMGR_PBRESOLVEFILEIDREF
:
1403 exit_syscall("PBResolveFileIDRef", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1405 case FILEMGR_PBFLUSHVOL
:
1406 exit_syscall("PBFlushVol", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1408 case FILEMGR_PBHRENAME
:
1409 exit_syscall("PBHRename", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1411 case FILEMGR_PBCATMOVE
:
1412 exit_syscall("PBCatMove", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1414 case FILEMGR_PBEXCHANGEFILES
:
1415 exit_syscall("PBExchangeFiles", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1417 case FILEMGR_PBHDELETE
:
1418 exit_syscall("PBHDelete", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1420 case FILEMGR_PBDIRCREATE
:
1421 exit_syscall("PBDirCreate", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1423 case FILEMGR_PBCATSEARCH
:
1424 exit_syscall("PBCatSearch", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1426 case FILEMGR_PBHSETFLOCK
:
1427 exit_syscall("PBHSetFLock", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1429 case FILEMGR_PBHRSTFLOCK
:
1430 exit_syscall("PBHRstFLock", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1432 case FILEMGR_PBLOCKRANGE
:
1433 exit_syscall("PBLockRange", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1435 case FILEMGR_PBUNLOCKRANGE
:
1436 exit_syscall("PBUnlockRange", thread
, type
, kd
[i
].arg1
, kd
[i
].arg2
, 0, 0, (double)now
);
1446 enter_syscall(int thread
, int type
, kd_buf
*kd
, char *name
, double now
)
1455 kd_threadmap
*find_thread_map();
1501 case BSC_getdirentries
:
1509 case BSC_getattrlist
:
1510 case BSC_setattrlist
:
1511 case BSC_getdirentriesattr
:
1512 case BSC_exchangedata
:
1513 case BSC_checkuseraccess
:
1515 case FILEMGR_PBGETCATALOGINFO
:
1516 case FILEMGR_PBGETCATALOGINFOBULK
:
1517 case FILEMGR_PBCREATEFILEUNICODE
:
1518 case FILEMGR_PBCREATEDIRECTORYUNICODE
:
1519 case FILEMGR_PBCREATEFORK
:
1520 case FILEMGR_PBDELETEFORK
:
1521 case FILEMGR_PBITERATEFORK
:
1522 case FILEMGR_PBOPENFORK
:
1523 case FILEMGR_PBREADFORK
:
1524 case FILEMGR_PBWRITEFORK
:
1525 case FILEMGR_PBALLOCATEFORK
:
1526 case FILEMGR_PBDELETEOBJECT
:
1527 case FILEMGR_PBEXCHANGEOBJECT
:
1528 case FILEMGR_PBGETFORKCBINFO
:
1529 case FILEMGR_PBGETVOLUMEINFO
:
1530 case FILEMGR_PBMAKEFSREF
:
1531 case FILEMGR_PBMAKEFSREFUNICODE
:
1532 case FILEMGR_PBMOVEOBJECT
:
1533 case FILEMGR_PBOPENITERATOR
:
1534 case FILEMGR_PBRENAMEUNICODE
:
1535 case FILEMGR_PBSETCATALOGINFO
:
1536 case FILEMGR_PBSETVOLUMEINFO
:
1537 case FILEMGR_FSREFMAKEPATH
:
1538 case FILEMGR_FSPATHMAKEREF
:
1540 case FILEMGR_PBGETCATINFO
:
1541 case FILEMGR_PBGETCATINFOLITE
:
1542 case FILEMGR_PBHGETFINFO
:
1543 case FILEMGR_PBXGETVOLINFO
:
1544 case FILEMGR_PBHCREATE
:
1545 case FILEMGR_PBHOPENDF
:
1546 case FILEMGR_PBHOPENRF
:
1547 case FILEMGR_PBHGETDIRACCESS
:
1548 case FILEMGR_PBHSETDIRACCESS
:
1549 case FILEMGR_PBHMAPID
:
1550 case FILEMGR_PBHMAPNAME
:
1551 case FILEMGR_PBCLOSE
:
1552 case FILEMGR_PBFLUSHFILE
:
1553 case FILEMGR_PBGETEOF
:
1554 case FILEMGR_PBSETEOF
:
1555 case FILEMGR_PBGETFPOS
:
1556 case FILEMGR_PBREAD
:
1557 case FILEMGR_PBWRITE
:
1558 case FILEMGR_PBGETFCBINFO
:
1559 case FILEMGR_PBSETFINFO
:
1560 case FILEMGR_PBALLOCATE
:
1561 case FILEMGR_PBALLOCCONTIG
:
1562 case FILEMGR_PBSETFPOS
:
1563 case FILEMGR_PBSETCATINFO
:
1564 case FILEMGR_PBGETVOLPARMS
:
1565 case FILEMGR_PBSETVINFO
:
1566 case FILEMGR_PBMAKEFSSPEC
:
1567 case FILEMGR_PBHGETVINFO
:
1568 case FILEMGR_PBCREATEFILEIDREF
:
1569 case FILEMGR_PBDELETEFILEIDREF
:
1570 case FILEMGR_PBRESOLVEFILEIDREF
:
1571 case FILEMGR_PBFLUSHVOL
:
1572 case FILEMGR_PBHRENAME
:
1573 case FILEMGR_PBCATMOVE
:
1574 case FILEMGR_PBEXCHANGEFILES
:
1575 case FILEMGR_PBHDELETE
:
1576 case FILEMGR_PBDIRCREATE
:
1577 case FILEMGR_PBCATSEARCH
:
1578 case FILEMGR_PBHSETFLOCK
:
1579 case FILEMGR_PBHRSTFLOCK
:
1580 case FILEMGR_PBLOCKRANGE
:
1581 case FILEMGR_PBUNLOCKRANGE
:
1584 for (i
= 0, ti
= th_state
; ti
< &th_state
[MAX_THREADS
]; ti
++, i
++) {
1585 if (ti
->thread
== 0)
1588 if (ti
== &th_state
[MAX_THREADS
])
1593 if ((type
>> 24) == FILEMGR_CLASS
) {
1596 l_usecs
= (long long)(now
/ divisor
);
1597 secs
= l_usecs
/ 1000000;
1599 if (bias_secs
== 0) {
1600 curr_time
= time((long *)0);
1601 bias_secs
= curr_time
- secs
;
1603 curr_time
= bias_secs
+ secs
;
1604 sprintf(buf
, "%-8.8s", &(ctime(&curr_time
)[11]));
1605 tsclen
= strlen(buf
);
1607 if (COLS
> MAXCOLS
|| wideflag
) {
1608 usecs
= l_usecs
- (long long)((long long)secs
* 1000000);
1609 sprintf(&buf
[tsclen
], ".%03ld", (long)usecs
/ 1000);
1610 tsclen
= strlen(buf
);
1613 /* Print timestamp column */
1616 map
= find_thread_map(thread
);
1618 sprintf(buf
, " %-25.25s ", name
);
1619 nmclen
= strlen(buf
);
1622 sprintf(buf
, "(%d, 0x%x, 0x%x, 0x%x)", (short)kd
->arg1
, kd
->arg2
, kd
->arg3
, kd
->arg4
);
1623 argsclen
= strlen(buf
);
1626 Calculate white space out to command
1628 if (COLS
> MAXCOLS
|| wideflag
)
1630 clen
= COLS
- (tsclen
+ nmclen
+ argsclen
+ 20);
1633 clen
= COLS
- (tsclen
+ nmclen
+ argsclen
+ 12);
1637 printf(buf
); /* print the kdargs */
1638 memset(buf
, ' ', clen
);
1642 else if ((argsclen
+ clen
) > 0)
1644 /* no room so wipe out the kdargs */
1645 memset(buf
, ' ', (argsclen
+ clen
));
1646 buf
[argsclen
+ clen
] = '\0';
1650 if (COLS
> MAXCOLS
|| wideflag
)
1651 printf("%-20.20s\n", map
->command
);
1653 printf("%-12.12s\n", map
->command
);
1655 printf(" %-24.24s (%5d, %#x, 0x%x, 0x%x)\n", name
, (short)kd
->arg1
, kd
->arg2
, kd
->arg3
, kd
->arg4
);
1659 ti
->thread
= thread
;
1663 ti
->arg1
= kd
->arg1
;
1664 ti
->arg2
= kd
->arg2
;
1665 ti
->arg3
= kd
->arg3
;
1666 ti
->arg4
= kd
->arg4
;
1667 ti
->pathptr
= (long *)0;
1668 ti
->pathname
[0] = 0;
1680 exit_syscall(char *sc_name
, int thread
, int type
, int error
, int retval
,
1681 int has_fd
, int has_ret
, double now
)
1690 kd_threadmap
*find_thread_map();
1695 if ((ti
= find_thread(thread
, type
)) == (struct th_info
*)0)
1697 map
= find_thread_map(thread
);
1698 l_usecs
= (long long)(now
/ divisor
);
1699 secs
= l_usecs
/ 1000000;
1701 if (bias_secs
== 0) {
1702 curr_time
= time((long *)0);
1703 bias_secs
= curr_time
- secs
;
1705 curr_time
= bias_secs
+ secs
;
1706 sprintf(buf
, "%-8.8s", &(ctime(&curr_time
)[11]));
1709 if (COLS
> MAXCOLS
|| wideflag
) {
1711 usecs
= l_usecs
- (long long)((long long)secs
* 1000000);
1712 sprintf(&buf
[clen
], ".%03ld", (long)usecs
/ 1000);
1714 if ((type
>> 24) != FILEMGR_CLASS
) {
1715 if (find_thread(thread
, -1)) {
1716 sprintf(&buf
[clen
], " ");
1724 if (((type
>> 24) == FILEMGR_CLASS
) && (COLS
> MAXCOLS
|| wideflag
))
1725 sprintf(&buf
[clen
], " %-18.18s", sc_name
);
1727 sprintf(&buf
[clen
], " %-15.15s", sc_name
);
1731 if (COLS
> MAXCOLS
|| wideflag
) {
1732 if (has_fd
== 2 && error
== 0)
1733 sprintf(&buf
[clen
], " F=%-3d", retval
);
1734 else if (has_fd
== 1)
1735 sprintf(&buf
[clen
], " F=%-3d", ti
->arg1
);
1736 else if (has_ret
!= 2)
1737 sprintf(&buf
[clen
], " ");
1742 sprintf(&buf
[clen
], "[%3d] ", error
);
1743 else if (has_ret
== 3)
1744 sprintf(&buf
[clen
], "O=0x%8.8x", ti
->arg3
);
1745 else if (has_ret
== 5)
1746 sprintf(&buf
[clen
], "O=0x%8.8x", retval
);
1747 else if (has_ret
== 2)
1748 sprintf(&buf
[clen
], " A=0x%8.8x ", retval
);
1749 else if (has_ret
== 1)
1750 sprintf(&buf
[clen
], " B=0x%-6x", retval
);
1751 else if (has_ret
== 4)
1752 sprintf(&buf
[clen
], "R=0x%-8x", retval
);
1754 sprintf(&buf
[clen
], " ");
1760 Calculate space available to print pathname
1762 if (COLS
> MAXCOLS
|| wideflag
)
1763 clen
= COLS
- (clen
+ 13 + 20);
1765 clen
= COLS
- (clen
+ 13 + 12);
1767 if ((type
>> 24) != FILEMGR_CLASS
&& !nopadding
)
1770 sprintf(&buf
[0], " %s ", ti
->pathname
);
1776 Add null padding if column length
1777 is wider than the pathname length.
1779 memset(&buf
[len
], ' ', clen
- len
);
1783 else if (clen
== len
)
1787 else if ((clen
> 0) && (clen
< len
))
1789 /* This prints the tail end of the pathname */
1790 buf
[len
-clen
] = ' ';
1791 printf(&buf
[len
- clen
]);
1794 usecs
= (unsigned long)(((double)now
- ti
->stime
) / divisor
);
1795 secs
= usecs
/ 1000000;
1796 usecs
-= secs
* 1000000;
1798 if ((type
>> 24) != FILEMGR_CLASS
&& !nopadding
)
1801 printf(" %2ld.%06ld", (long)secs
, (long)usecs
);
1808 if (COLS
> MAXCOLS
|| wideflag
)
1809 printf(" %-20.20s", map
->command
);
1811 printf(" %-12.12s", map
->command
);
1815 if (ti
== &th_state
[cur_max
- 1])
1829 This flag is turned off when calling
1830 quit() due to a set_remove() failure.
1832 if (set_remove_flag
)
1835 printf("fs_usage: ");
1847 unsigned int abs_to_ns_num
;
1848 unsigned int abs_to_ns_denom
;
1849 unsigned int proc_to_abs_num
;
1850 unsigned int proc_to_abs_denom
;
1852 extern void MKGetTimeBaseInfo(unsigned int *, unsigned int *, unsigned int *, unsigned int *, unsigned int *);
1854 MKGetTimeBaseInfo (&delta
, &abs_to_ns_num
, &abs_to_ns_denom
,
1855 &proc_to_abs_num
, &proc_to_abs_denom
);
1857 divisor
= ((double)abs_to_ns_denom
/ (double)abs_to_ns_num
) * 1000;
1861 void read_command_map()
1870 total_threads
= bufinfo
.nkdthreads
;
1871 size
= bufinfo
.nkdthreads
* sizeof(kd_threadmap
);
1875 if (mapptr
= (kd_threadmap
*) malloc(size
))
1876 bzero (mapptr
, size
);
1879 printf("Thread map is not initialized -- this is not fatal\n");
1884 /* Now read the threadmap */
1886 mib
[1] = KERN_KDEBUG
;
1887 mib
[2] = KERN_KDTHRMAP
;
1890 mib
[5] = 0; /* no flags */
1891 if (sysctl(mib
, 3, mapptr
, &size
, NULL
, 0) < 0)
1893 /* This is not fatal -- just means I cant map command strings */
1895 printf("Can't read the thread map -- this is not fatal\n");
1904 void create_map_entry(int thread
, char *command
)
1912 for (i
= 0, map
= 0; !map
&& i
< total_threads
; i
++)
1914 if (mapptr
[i
].thread
== thread
)
1915 map
= &mapptr
[i
]; /* Reuse this entry, the thread has been reassigned */
1918 if (!map
) /* look for invalid entries that I can reuse*/
1920 for (i
= 0, map
= 0; !map
&& i
< total_threads
; i
++)
1922 if (mapptr
[i
].valid
== 0 )
1923 map
= &mapptr
[i
]; /* Reuse this invalid entry */
1929 /* If reach here, then this is a new thread and
1930 * there are no invalid entries to reuse
1931 * Double the size of the thread map table.
1934 n
= total_threads
* 2;
1935 mapptr
= (kd_threadmap
*) realloc(mapptr
, n
* sizeof(kd_threadmap
));
1936 bzero(&mapptr
[total_threads
], total_threads
*sizeof(kd_threadmap
));
1937 map
= &mapptr
[total_threads
];
1942 map
->thread
= thread
;
1944 The trace entry that returns the command name will hold
1945 at most, MAXCOMLEN chars, and in that case, is not
1946 guaranteed to be null terminated.
1948 (void)strncpy (map
->command
, command
, MAXCOMLEN
);
1949 map
->command
[MAXCOMLEN
] = '\0';
1953 kd_threadmap
*find_thread_map(int thread
)
1959 return((kd_threadmap
*)0);
1961 for (i
= 0; i
< total_threads
; i
++)
1964 if (map
->valid
&& (map
->thread
== thread
))
1969 return ((kd_threadmap
*)0);
1974 kill_thread_map(int thread
)
1978 if (map
= find_thread_map(thread
)) {
1981 map
->command
[0] = '\0';
1993 ret
= (int)strtol(str
, &cp
, 10);
1994 if (cp
== str
|| *cp
) {
1995 /* Assume this is a command string and find matching pids */
1999 for (i
=0; i
< kp_nentries
&& num_of_pids
< (MAX_PIDS
- 1); i
++) {
2000 if(kp_buffer
[i
].kp_proc
.p_stat
== 0)
2003 if(!strcmp(str
, kp_buffer
[i
].kp_proc
.p_comm
))
2004 pids
[num_of_pids
++] = kp_buffer
[i
].kp_proc
.p_pid
;
2008 else if (num_of_pids
< (MAX_PIDS
- 1))
2009 pids
[num_of_pids
++] = ret
;