• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 struct log_data {
2   char *t, *p;
3 
4   int pri;
5 };
6 
7 struct dmesg_data {
8   long n, s;
9 
10   int use_color;
11   time_t tea;
12 };
13 
14 struct gzip_data {
15   int level;
16 };
17 
18 struct hostname_data {
19   char *F;
20 };
21 
22 struct killall_data {
23   char *s;
24 
25   int signum;
26   pid_t cur_pid;
27   char **names;
28   short *err;
29   struct int_list { struct int_list *next; int val; } *pids;
30 };
31 
32 struct md5sum_data {
33   int sawline;
34 };
35 
36 struct mknod_data {
37   char *Z, *m;
38 };
39 
40 struct mktemp_data {
41   char *p, *tmpdir;
42 };
43 
44 struct mount_data {
45   struct arg_list *o;
46   char *t, *O;
47 
48   unsigned long flags;
49   char *opts;
50   int okuser;
51 };
52 
53 struct pidof_data {
54   char *o;
55 };
56 
57 struct seq_data {
58   char *s, *f;
59 
60   int precision, buflen;
61 };
62 
63 struct umount_data {
64   struct arg_list *t;
65 
66   char *types;
67 };
68 
69 struct ifconfig_data {
70   int sockfd;
71 };
72 
73 struct microcom_data {
74   long s;
75 
76   int fd, stok;
77   struct termios old_stdin, old_fd;
78 };
79 
80 struct netcat_data {
81   char *f, *s, *o, *O;
82   long q, p, W, w;
83 
84   unsigned ofd, olast, opos, ocount[2];
85   char obuf[16];
86 };
87 
88 struct netstat_data {
89   struct num_cache *inodes;
90   int wpad;
91 };
92 
93 struct ping_data {
94   char *I;
95   long w, W, i, s, c, t, m;
96 
97   struct sockaddr *sa;
98   int sock;
99   unsigned long sent, recv, fugit, min, max;
100 };
101 
102 struct tunctl_data {
103   char *u;
104 };
105 
106 struct base64_data {
107   long w;
108 
109   unsigned total;
110   unsigned n;  // number of bits used in encoding. 5 for base32, 6 for base64
111   unsigned align;  // number of bits to align to
112 };
113 
114 struct blkdiscard_data {
115   long o, l;
116 };
117 
118 struct blkid_data {
119   struct arg_list *s;
120   char *o;
121 };
122 
123 struct blockdev_data {
124   long setra, setbsz;
125 };
126 
127 struct chrt_data {
128   long p;
129 };
130 
131 struct dos2unix_data {
132   char *tempfile;
133 };
134 
135 struct fallocate_data {
136   long o, l;
137 };
138 
139 struct fmt_data {
140   long width;
141 
142   int level, pos;
143 };
144 
145 struct free_data {
146   unsigned bits;
147   unsigned long long units;
148   char *buf;
149 };
150 
151 struct getopt_data {
152   struct arg_list *l;
153   char *o, *n;
154 };
155 
156 struct gpiodetect_data {
157   struct double_list *chips;
158   int chip_count;
159 };
160 
161 struct hwclock_data {
162   char *f;
163 };
164 
165 struct i2cdetect_data {
166   long F;
167 };
168 
169 struct ionice_data {
170   long p, n, c;
171 };
172 
173 struct losetup_data {
174   char *j;
175   long o, S;
176 
177   int openflags;
178   dev_t jdev;
179   ino_t jino;
180   char *dir;
181 };
182 
183 struct lsattr_data {
184   long v, p;
185 
186   unsigned add, rm, set;
187   // !add and !rm tell us whether they were used, but `chattr =` is meaningful.
188   int have_set;
189 };
190 
191 struct lsusb_data {
192   char *i;
193   long x, n;
194 
195   void *ids, *class;
196   int count;
197 };
198 
199 struct makedevs_data {
200   char *d;
201 };
202 
203 struct mkswap_data {
204   char *L;
205 };
206 
207 struct modinfo_data {
208   char *F, *k, *b;
209 
210   long mod;
211   int count;
212 };
213 
214 struct nbd_client_data {
215   long b;
216 
217   int nbd;
218 };
219 
220 struct nsenter_data {
221   char *UupnmiC[7];
222   long t;
223 };
224 
225 struct readelf_data {
226   char *x, *p;
227 
228   char *elf, *shstrtab, *f;
229   unsigned long long shoff, phoff, size, shstrtabsz;
230   int bits, endian, shnum, shentsize, phentsize;
231 };
232 
233 struct realpath_data {
234   char *R, *relative_base;
235 };
236 
237 struct rtcwake_data {
238   long t, s;
239   char *m, *d;
240 };
241 
242 struct setfattr_data {
243   char *x, *v, *n;
244 };
245 
246 struct setsid_data {
247   long c;
248 };
249 
250 struct stat_data {
251   char *c;
252 
253   union {
254     struct stat st;
255     struct statfs sf;
256   } stat;
257   char *file, *pattern;
258   int patlen;
259 };
260 
261 struct swapon_data {
262   long p;
263 };
264 
265 struct tac_data {
266   struct double_list *dl;
267 };
268 
269 struct timeout_data {
270   char *s, *k;
271 
272   struct pollfd pfd;
273   sigjmp_buf sj;
274   int fds[2], pid, rc;
275 };
276 
277 struct truncate_data {
278   char *s;
279 
280   long long size;
281   int type;
282 };
283 
284 struct uclampset_data {
285   long M, m, p;
286 };
287 
288 struct watch_data {
289   int n;
290 
291   pid_t pid, oldpid;
292 };
293 
294 struct xxd_data {
295   long s, g, o, l, c;
296 };
297 
298 struct brctl_data {
299     int sockfd;
300 };
301 
302 struct diff_data {
303   long U;
304   struct arg_list *L;
305   char *F, *S, *new_line_format, *old_line_format, *unchanged_line_format;
306 
307   int dir_num, size, is_binary, differ, change, len[2], *offset[2];
308   struct stat st[2];
309   struct {
310     char **list;
311     int nr_elm;
312   } dir[2];
313   struct {
314     FILE *fp;
315     int len;
316   } file[2];
317 };
318 
319 struct expr_data {
320   char **tok, *delete;
321 };
322 
323 struct getfattr_data {
324   char *n;
325 };
326 
327 struct lsof_data {
328   struct arg_list *p;
329 
330   struct stat *sought_files;
331   struct double_list *all_sockets, *files;
332   int last_shown_pid, shown_header;
333 };
334 
335 struct modprobe_data {
336   struct arg_list *dirs;
337 
338   struct arg_list *probes, *dbase[256];
339   char *cmdopts;
340   int nudeps, symreq;
341 };
342 
343 struct more_data {
344   struct termios inf;
345   int cin_fd;
346 };
347 
348 struct stty_data {
349   char *F;
350 
351   int fd, col;
352   unsigned output_cols;
353 };
354 
355 struct tr_data {
356   short *map;
357   int len1, len2;
358 };
359 
360 struct traceroute_data {
361   long max_ttl;
362   long port;
363   long ttl_probes;
364   char *src_ip;
365   long tos;
366   long wait_time;
367   struct arg_list *loose_source;
368   long pause_time;
369   long first_ttl;
370   char *iface;
371 
372   uint32_t gw_list[9];
373   int recv_sock;
374   int snd_sock;
375   unsigned msg_len;
376   char *packet;
377   uint32_t ident;
378   int istraceroute6;
379 };
380 
381 struct vi_data {
382   char *s;
383 
384   char *filename;
385   int vi_mode, tabstop, list;
386   int cur_col, cur_row, scr_row;
387   int drawn_row, drawn_col;
388   int count0, count1, vi_mov_flag;
389   unsigned screen_height, screen_width;
390   char vi_reg, *last_search;
391   struct str_line {
392     int alloc;
393     int len;
394     char *data;
395   } *il;
396   size_t screen, cursor; //offsets
397   //yank buffer
398   struct yank_buf {
399     char reg;
400     int alloc;
401     char* data;
402   } yank;
403 
404   size_t filesize;
405 // mem_block contains RO data that is either original file as mmap
406 // or heap allocated inserted data
407   struct block_list {
408     struct block_list *next, *prev;
409     struct mem_block {
410       size_t size;
411       size_t len;
412       enum alloc_flag {
413         MMAP,  //can be munmap() before exit()
414         HEAP,  //can be free() before exit()
415         STACK, //global or stack perhaps toybuf
416       } alloc;
417       const char *data;
418     } *node;
419   } *text;
420 
421 // slices do not contain actual allocated data but slices of data in mem_block
422 // when file is first opened it has only one slice.
423 // after inserting data into middle new mem_block is allocated for insert data
424 // and 3 slices are created, where first and last slice are pointing to original
425 // mem_block with offsets, and middle slice is pointing to newly allocated block
426 // When deleting, data is not freed but mem_blocks are sliced more such way that
427 // deleted data left between 2 slices
428   struct slice_list {
429     struct slice_list *next, *prev;
430     struct slice {
431       size_t len;
432       const char *data;
433     } *node;
434   } *slices;
435 };
436 
437 struct basename_data {
438   char *s;
439 };
440 
441 struct cal_data {
442   struct tm *now;
443 };
444 
445 struct chgrp_data {
446   uid_t owner;
447   gid_t group;
448   char *owner_name, *group_name;
449   int symfollow;
450 };
451 
452 struct chmod_data {
453   char *mode;
454 };
455 
456 struct cmp_data {
457   long n;
458 
459   int fd;
460   char *name;
461 };
462 
463 struct cp_data {
464   union {
465     // install's options
466     struct {
467       char *g, *o, *m, *t;
468     } i;
469     // cp's options
470     struct {
471       char *t, *preserve;
472     } c;
473   };
474 
475   char *destname;
476   struct stat top;
477   int (*callback)(struct dirtree *try);
478   uid_t uid;
479   gid_t gid;
480   int pflags;
481 };
482 
483 struct cpio_data {
484   char *F, *H, *R;
485 };
486 
487 struct cut_data {
488   char *d, *O;
489   struct arg_list *select[5]; // we treat them the same, so loop through
490 
491   unsigned line;
492   int pairs;
493   regex_t reg;
494 };
495 
496 struct date_data {
497   char *s, *r, *I, *D, *d;
498 
499   unsigned nano;
500 };
501 
502 struct dd_data {
503   // Display fields
504   int show_xfer, show_records;
505   unsigned long long bytes, in_full, in_part, out_full, out_part, start;
506 };
507 
508 struct df_data {
509   struct arg_list *t;
510 
511   int units, width[6];
512 };
513 
514 struct du_data {
515   long d;
516 
517   unsigned long depth, total;
518   dev_t st_dev;
519   void *inodes;
520 };
521 
522 struct env_data {
523   struct arg_list *u;
524   char *e;
525 };
526 
527 struct expand_data {
528   struct arg_list *t;
529 
530   unsigned tabcount, *tab;
531 };
532 
533 struct file_data {
534   int max_name_len;
535   off_t len;
536 };
537 
538 struct find_data {
539   char **filter;
540   struct double_list *argdata;
541   int topdir, xdev, depth;
542   time_t now;
543   long max_bytes;
544   char *start;
545 };
546 
547 struct grep_data {
548   long m, A, B, C;
549   struct arg_list *f, *e, *M, *S, *exclude_dir;
550   char *color;
551 
552   char *purple, *cyan, *red, *green, *grey;
553   struct double_list *reg;
554   int found, tried, delim;
555   struct arg_list **fixed;
556 };
557 
558 struct head_data {
559   long c, n;
560 
561   int file_no;
562 };
563 
564 struct iconv_data {
565   char *f, *t;
566 
567   void *ic;
568 };
569 
570 struct id_data {
571   int is_groups;
572 };
573 
574 struct kill_data {
575   char *s;
576   struct arg_list *o;
577 };
578 
579 struct ln_data {
580   char *t;
581 };
582 
583 struct logger_data {
584   char *p, *t;
585 
586   int priority;
587 };
588 
589 struct ls_data {
590   long w, l, block_size;
591   char *color, *sort;
592 
593   struct dirtree *files, *singledir;
594   unsigned screen_width;
595   int nl_title;
596   char *escmore;
597 };
598 
599 struct mkdir_data {
600   char *m, *Z;
601 };
602 
603 struct mkfifo_data {
604   char *m, *Z;
605 
606   mode_t mode;
607 };
608 
609 struct nice_data {
610   long n;
611 };
612 
613 struct nl_data {
614   char *s, *n, *b;
615   long w, l, v;
616 
617   // Count of consecutive blank lines for -l has to persist between files
618   long lcount, slen;
619 };
620 
621 struct od_data {
622   struct arg_list *t;
623   char *A;
624   long N, w, j;
625 
626   int address_idx;
627   unsigned types, leftover, star;
628   char *buf; // Points to buffers[0] or buffers[1].
629   char *bufs[2]; // Used to detect duplicate lines.
630   off_t pos;
631 };
632 
633 struct paste_data {
634   char *d;
635 
636   int files;
637 };
638 
639 struct patch_data {
640   char *i, *d;
641   long v, p, g, F;
642 
643   void *current_hunk;
644   long oldline, oldlen, newline, newlen, linenum, outnum;
645   int context, state, filein, fileout, filepatch, hunknum;
646   char *tempname;
647 };
648 
649 struct ps_data {
650   union {
651     struct {
652       struct arg_list *G, *g, *U, *u, *t, *s, *p, *O, *o, *P, *k;
653     } ps;
654     struct {
655       long n, m, d, s;
656       struct arg_list *u, *p, *o, *k, *O;
657     } top;
658     struct {
659       char *L;
660       struct arg_list *G, *g, *P, *s, *t, *U, *u;
661       char *d;
662 
663       void *regexes, *snapshot;
664       int signal;
665       pid_t self, match;
666     } pgrep;
667   };
668 
669   struct ps_ptr_len {
670     void *ptr;
671     long len;
672   } gg, GG, pp, PP, ss, tt, uu, UU;
673   struct dirtree *threadparent;
674   unsigned width, height, scroll;
675   dev_t tty;
676   void *fields, *kfields;
677   long long ticks, bits, time;
678   int kcount, forcek, sortpos, pidlen;
679   int (*match_process)(long long *slot);
680   void (*show_process)(void *tb);
681 };
682 
683 struct renice_data {
684   long n;
685 };
686 
687 struct sed_data {
688   char *i;
689   struct arg_list *f, *e;
690 
691   // processed pattern list
692   struct double_list *pattern;
693 
694   char *nextline, *remember, *tarxform;
695   void *restart, *lastregex;
696   long nextlen, rememberlen, count;
697   int fdout, noeol;
698   unsigned xx, tarxlen, xflags;
699   char delim, xftype;
700 };
701 
702 struct sort_data {
703   char *t;
704   struct arg_list *k;
705   char *o, *T, S;
706 
707   void *key_list;
708   unsigned linecount;
709   char **lines, *name;
710 };
711 
712 struct split_data {
713   long n, l, b, a;
714 
715   char *outfile;
716 };
717 
718 struct strings_data {
719   long n;
720   char *t;
721 };
722 
723 struct tail_data {
724   long n, c;
725   char *s;
726 
727   int file_no, last_fd, ss;
728   struct xnotify *not;
729   struct {
730     char *path;
731     int fd;
732     struct dev_ino di;
733   } *F;
734 };
735 
736 struct tar_data {
737   char *f, *C, *I;
738   struct arg_list *T, *X, *xform;
739   long strip;
740   char *to_command, *owner, *group, *mtime, *mode, *sort;
741   struct arg_list *exclude;
742 
743   struct double_list *incl, *excl, *seen;
744   struct string_list *dirs;
745   char *cwd, **xfsed;
746   int fd, ouid, ggid, hlc, warn, sparselen, pid, xfpipe[2];
747   struct dev_ino archive_di;
748   long long *sparse;
749   time_t mtt;
750 
751   // hardlinks seen so far (hlc many)
752   struct {
753     char *arg;
754     struct dev_ino di;
755   } *hlx;
756 
757   // Parsed information about a tar header.
758   struct tar_header {
759     char *name, *link_target, *uname, *gname;
760     long long size, ssize;
761     uid_t uid;
762     gid_t gid;
763     mode_t mode;
764     time_t mtime;
765     dev_t device;
766   } hdr;
767 };
768 
769 struct tee_data {
770   void *outputs;
771   int out;
772 };
773 
774 struct touch_data {
775   char *t, *r, *d;
776 };
777 
778 struct ulimit_data {
779   long P;
780 };
781 
782 struct uniq_data {
783   long w, s, f;
784 
785   long repeats;
786 };
787 
788 struct uudecode_data {
789   char *o;
790 };
791 
792 struct wc_data {
793   unsigned long totals[5];
794 };
795 
796 struct xargs_data {
797   long s, n, P;
798   char *E;
799 
800   long entries, bytes, np;
801   char delim;
802   FILE *tty;
803 };
804 extern union global_union {
805 	struct log_data log;
806 	struct dmesg_data dmesg;
807 	struct gzip_data gzip;
808 	struct hostname_data hostname;
809 	struct killall_data killall;
810 	struct md5sum_data md5sum;
811 	struct mknod_data mknod;
812 	struct mktemp_data mktemp;
813 	struct mount_data mount;
814 	struct pidof_data pidof;
815 	struct seq_data seq;
816 	struct umount_data umount;
817 	struct ifconfig_data ifconfig;
818 	struct microcom_data microcom;
819 	struct netcat_data netcat;
820 	struct netstat_data netstat;
821 	struct ping_data ping;
822 	struct tunctl_data tunctl;
823 	struct base64_data base64;
824 	struct blkdiscard_data blkdiscard;
825 	struct blkid_data blkid;
826 	struct blockdev_data blockdev;
827 	struct chrt_data chrt;
828 	struct dos2unix_data dos2unix;
829 	struct fallocate_data fallocate;
830 	struct fmt_data fmt;
831 	struct free_data free;
832 	struct getopt_data getopt;
833 	struct gpiodetect_data gpiodetect;
834 	struct hwclock_data hwclock;
835 	struct i2cdetect_data i2cdetect;
836 	struct ionice_data ionice;
837 	struct losetup_data losetup;
838 	struct lsattr_data lsattr;
839 	struct lsusb_data lsusb;
840 	struct makedevs_data makedevs;
841 	struct mkswap_data mkswap;
842 	struct modinfo_data modinfo;
843 	struct nbd_client_data nbd_client;
844 	struct nsenter_data nsenter;
845 	struct readelf_data readelf;
846 	struct realpath_data realpath;
847 	struct rtcwake_data rtcwake;
848 	struct setfattr_data setfattr;
849 	struct setsid_data setsid;
850 	struct stat_data stat;
851 	struct swapon_data swapon;
852 	struct tac_data tac;
853 	struct timeout_data timeout;
854 	struct truncate_data truncate;
855 	struct uclampset_data uclampset;
856 	struct watch_data watch;
857 	struct xxd_data xxd;
858 	struct brctl_data brctl;
859 	struct diff_data diff;
860 	struct expr_data expr;
861 	struct getfattr_data getfattr;
862 	struct lsof_data lsof;
863 	struct modprobe_data modprobe;
864 	struct more_data more;
865 	struct stty_data stty;
866 	struct tr_data tr;
867 	struct traceroute_data traceroute;
868 	struct vi_data vi;
869 	struct basename_data basename;
870 	struct cal_data cal;
871 	struct chgrp_data chgrp;
872 	struct chmod_data chmod;
873 	struct cmp_data cmp;
874 	struct cp_data cp;
875 	struct cpio_data cpio;
876 	struct cut_data cut;
877 	struct date_data date;
878 	struct dd_data dd;
879 	struct df_data df;
880 	struct du_data du;
881 	struct env_data env;
882 	struct expand_data expand;
883 	struct file_data file;
884 	struct find_data find;
885 	struct grep_data grep;
886 	struct head_data head;
887 	struct iconv_data iconv;
888 	struct id_data id;
889 	struct kill_data kill;
890 	struct ln_data ln;
891 	struct logger_data logger;
892 	struct ls_data ls;
893 	struct mkdir_data mkdir;
894 	struct mkfifo_data mkfifo;
895 	struct nice_data nice;
896 	struct nl_data nl;
897 	struct od_data od;
898 	struct paste_data paste;
899 	struct patch_data patch;
900 	struct ps_data ps;
901 	struct renice_data renice;
902 	struct sed_data sed;
903 	struct sort_data sort;
904 	struct split_data split;
905 	struct strings_data strings;
906 	struct tail_data tail;
907 	struct tar_data tar;
908 	struct tee_data tee;
909 	struct touch_data touch;
910 	struct ulimit_data ulimit;
911 	struct uniq_data uniq;
912 	struct uudecode_data uudecode;
913 	struct wc_data wc;
914 	struct xargs_data xargs;
915 } this;
916