Mercurial > hg > toybox
annotate toys/toylist.h @ 147:ec6e13b2495d
Patch from Charlie Shepherd: Implement touch, set the default in Config.in to
y, and remove the length argument (and all talk of changing the length of
files).
author | Rob Landley <rob@landley.net> |
---|---|
date | Wed, 31 Oct 2007 01:13:36 -0500 |
parents | 99e651512aa4 |
children | 714f4c051594 |
rev | line source |
---|---|
21
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
1 /* vi: set ts=4 :*/ |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
2 /* Toybox infrastructure. |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
3 * |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
4 * Copyright 2006 Rob Landley <rob@landley.net> |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
5 */ |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
6 |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
7 |
88
021fe1a818c3
Small cleanup to prepare for cross-compile friendly make install.
Rob Landley <rob@landley.net>
parents:
82
diff
changeset
|
8 // Provide function declarations and structs. Note that main.c #includes this |
021fe1a818c3
Small cleanup to prepare for cross-compile friendly make install.
Rob Landley <rob@landley.net>
parents:
82
diff
changeset
|
9 // file twice (with different macros) to populate toy_list[]. |
21
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
10 |
88
021fe1a818c3
Small cleanup to prepare for cross-compile friendly make install.
Rob Landley <rob@landley.net>
parents:
82
diff
changeset
|
11 #ifndef NEWTOY |
25
eb46bb5626cb
New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents:
21
diff
changeset
|
12 #define NEWTOY(name, opts, flags) int name##_main(void); |
eb46bb5626cb
New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents:
21
diff
changeset
|
13 #define OLDTOY(name, oldname, opts, flags) |
21
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
14 |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
15 struct df_data { |
33 | 16 struct arg_list *fstype; |
53
41d55b5d49fd
Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
35
diff
changeset
|
17 |
21
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
18 long units; |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
19 }; |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
20 |
146
99e651512aa4
Get toysh.c to start using the option parsing logic, and some minor cleanup.
Rob Landley <rob@landley.net>
parents:
139
diff
changeset
|
21 // Still to go: "E:jJ:L:m:O:" |
99e651512aa4
Get toysh.c to start using the option parsing logic, and some minor cleanup.
Rob Landley <rob@landley.net>
parents:
139
diff
changeset
|
22 #define MKE2FS_OPTSTRING "<1>2g:Fnqm#N#i#b#" |
99e651512aa4
Get toysh.c to start using the option parsing logic, and some minor cleanup.
Rob Landley <rob@landley.net>
parents:
139
diff
changeset
|
23 |
53
41d55b5d49fd
Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
35
diff
changeset
|
24 struct mke2fs_data { |
113 | 25 // Command line arguments. |
53
41d55b5d49fd
Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
35
diff
changeset
|
26 long blocksize; |
41d55b5d49fd
Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
35
diff
changeset
|
27 long bytes_per_inode; |
113 | 28 long inodes; // Total inodes in filesystem. |
29 long reserved_percent; // Integer precent of space to reserve for root. | |
30 char *gendir; // Where to read dirtree from. | |
31 | |
32 // Internal data. | |
33 struct dirtree *dt; // Tree of files to copy into the new filesystem. | |
34 unsigned treeblocks; // Blocks used by dt | |
35 unsigned treeinodes; // Inodes used by dt | |
53
41d55b5d49fd
Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
35
diff
changeset
|
36 |
113 | 37 unsigned blocks; // Total blocks in the filesystem. |
38 unsigned freeblocks; // Free blocks in the filesystem. | |
39 unsigned inodespg; // Inodes per group | |
40 unsigned groups; // Total number of block groups. | |
41 unsigned blockbits; // Bits per block. (Also blocks per group.) | |
42 | |
43 // For gene2fs | |
44 unsigned nextblock; // Next data block to allocate | |
45 unsigned nextgroup; // Next group we'll be allocating from | |
46 int fsfd; // File descriptor of filesystem (to output to). | |
47 | |
82 | 48 struct ext2_superblock sb; |
53
41d55b5d49fd
Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
35
diff
changeset
|
49 }; |
41d55b5d49fd
Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
35
diff
changeset
|
50 |
118 | 51 struct sleep_data { |
52 long seconds; | |
53 }; | |
54 | |
100
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
99
diff
changeset
|
55 struct touch_data { |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
99
diff
changeset
|
56 char *ref_file; |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
99
diff
changeset
|
57 char *time; |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
99
diff
changeset
|
58 }; |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
99
diff
changeset
|
59 |
146
99e651512aa4
Get toysh.c to start using the option parsing logic, and some minor cleanup.
Rob Landley <rob@landley.net>
parents:
139
diff
changeset
|
60 struct toysh_data { |
99e651512aa4
Get toysh.c to start using the option parsing logic, and some minor cleanup.
Rob Landley <rob@landley.net>
parents:
139
diff
changeset
|
61 char *command; |
99e651512aa4
Get toysh.c to start using the option parsing logic, and some minor cleanup.
Rob Landley <rob@landley.net>
parents:
139
diff
changeset
|
62 }; |
53
41d55b5d49fd
Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
35
diff
changeset
|
63 |
93
cc0a6789f92a
Trim a redundant definition that confuses older compilers. (Regression testing
Rob Landley <rob@landley.net>
parents:
92
diff
changeset
|
64 extern union toy_union { |
21
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
65 struct df_data df; |
53
41d55b5d49fd
Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
35
diff
changeset
|
66 struct mke2fs_data mke2fs; |
146
99e651512aa4
Get toysh.c to start using the option parsing logic, and some minor cleanup.
Rob Landley <rob@landley.net>
parents:
139
diff
changeset
|
67 struct sleep_data sleep; |
99e651512aa4
Get toysh.c to start using the option parsing logic, and some minor cleanup.
Rob Landley <rob@landley.net>
parents:
139
diff
changeset
|
68 struct touch_data touch; |
99e651512aa4
Get toysh.c to start using the option parsing logic, and some minor cleanup.
Rob Landley <rob@landley.net>
parents:
139
diff
changeset
|
69 struct toysh_data toysh; |
21
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
70 } toy; |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
71 |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
72 #define TOYFLAG_USR (1<<0) |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
73 #define TOYFLAG_BIN (1<<1) |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
74 #define TOYFLAG_SBIN (1<<2) |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
75 #define TOYMASK_LOCATION ((1<<4)-1) |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
76 |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
77 #define TOYFLAG_NOFORK (1<<4) |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
78 |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
79 extern struct toy_list { |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
80 char *name; |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
81 int (*toy_main)(void); |
25
eb46bb5626cb
New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents:
21
diff
changeset
|
82 char *options; |
21
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
83 int flags; |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
84 } toy_list[]; |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
85 |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
86 #endif |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
87 |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
88 // List of all the applets toybox can provide. |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
89 |
53
41d55b5d49fd
Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
35
diff
changeset
|
90 // This one is out of order on purpose: it's the first element in the array. |
21
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
91 |
25
eb46bb5626cb
New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents:
21
diff
changeset
|
92 NEWTOY(toybox, NULL, 0) |
21
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
93 |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
94 // The rest of these are alphabetical, for binary search. |
6475d6c46066
Add pwd. Consolidate toy list information under toylist.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
95 |
54
60a7fb8ddeb4
Add a quick and dirt bzcat (stdin to stdout only for the moment) to test
Rob Landley <rob@landley.net>
parents:
53
diff
changeset
|
96 USE_BZCAT(NEWTOY(bzcat, "", TOYFLAG_USR|TOYFLAG_BIN)) |
66 | 97 USE_CATV(NEWTOY(catv, "vte", TOYFLAG_USR|TOYFLAG_BIN)) |
98 USE_COUNT(NEWTOY(count, "", TOYFLAG_USR|TOYFLAG_BIN)) | |
25
eb46bb5626cb
New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents:
21
diff
changeset
|
99 USE_TOYSH(NEWTOY(cd, NULL, TOYFLAG_NOFORK)) |
32
993eab821bd5
More work on option parsing. "df -t tmpfs" actually seems to work now.
Rob Landley <rob@landley.net>
parents:
25
diff
changeset
|
100 USE_DF(NEWTOY(df, "Pkt*a", TOYFLAG_USR|TOYFLAG_SBIN)) |
92
154070b2b28d
Toybox option parsing must stop at the first non-option argument.
Rob Landley <rob@landley.net>
parents:
88
diff
changeset
|
101 USE_ECHO(NEWTOY(echo, "+en", TOYFLAG_BIN)) |
25
eb46bb5626cb
New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents:
21
diff
changeset
|
102 USE_TOYSH(NEWTOY(exit, NULL, TOYFLAG_NOFORK)) |
116 | 103 USE_FALSE(NEWTOY(false, NULL, TOYFLAG_BIN)) |
139
fb0745eec453
Add "help" command. (Building help/help.h requires python, but I'll ship
Rob Landley <rob@landley.net>
parents:
118
diff
changeset
|
104 USE_HELLO(NEWTOY(hello, NULL, TOYFLAG_USR|TOYFLAG_BIN)) |
fb0745eec453
Add "help" command. (Building help/help.h requires python, but I'll ship
Rob Landley <rob@landley.net>
parents:
118
diff
changeset
|
105 USE_HELP(NEWTOY(help, "<1", TOYFLAG_BIN)) |
53
41d55b5d49fd
Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
35
diff
changeset
|
106 USE_MKE2FS(NEWTOY(mke2fs, MKE2FS_OPTSTRING, TOYFLAG_SBIN)) |
106
422df21290d7
Fix oneit: <1 is only parsed at the start of the argument list.
Rob Landley <rob@landley.net>
parents:
104
diff
changeset
|
107 USE_ONEIT(NEWTOY(oneit, "+<1p", TOYFLAG_SBIN)) |
25
eb46bb5626cb
New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents:
21
diff
changeset
|
108 USE_PWD(NEWTOY(pwd, NULL, TOYFLAG_BIN)) |
115
19b5567f0a1b
Add readlink, xreadlink(), and change xrealloc() to not fight the stupid
Rob Landley <rob@landley.net>
parents:
114
diff
changeset
|
109 USE_READLINK(NEWTOY(readlink, "<1f", TOYFLAG_BIN)) |
25
eb46bb5626cb
New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents:
21
diff
changeset
|
110 USE_TOYSH(OLDTOY(sh, toysh, "c:i", TOYFLAG_BIN)) |
118 | 111 USE_SLEEP(NEWTOY(sleep, "<1", TOYFLAG_BIN)) |
114
ce6956dfc0cf
Add sync and an incomplete version of mdev.
Rob Landley <rob@landley.net>
parents:
113
diff
changeset
|
112 USE_SYNC(NEWTOY(sync, NULL, TOYFLAG_BIN)) |
147
ec6e13b2495d
Patch from Charlie Shepherd: Implement touch, set the default in Config.in to
Rob Landley <rob@landley.net>
parents:
146
diff
changeset
|
113 USE_TOUCH(NEWTOY(touch, "t:r:mca", TOYFLAG_BIN)) |
25
eb46bb5626cb
New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents:
21
diff
changeset
|
114 USE_TOYSH(NEWTOY(toysh, "c:i", TOYFLAG_BIN)) |
116 | 115 USE_TRUE(NEWTOY(true, NULL, TOYFLAG_BIN)) |
25
eb46bb5626cb
New option parsing infrastructure (doesn't use getopt). Hook it up to
Rob Landley <rob@landley.net>
parents:
21
diff
changeset
|
116 USE_WHICH(NEWTOY(which, "a", TOYFLAG_USR|TOYFLAG_BIN)) |
74 | 117 USE_YES(NEWTOY(yes, "", TOYFLAG_USR|TOYFLAG_BIN)) |