Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 12 additions & 25 deletions src/checkpath/checkpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,33 +42,20 @@ typedef enum {
inode_fifo = 3,
} inode_t;

#define opts(opt, opt_long) \
opt(d, directory, no_argument, "Create a directory if not exists") \
opt(D, directory-truncate, no_argument, "Create/empty directory") \
opt(f, file, no_argument, "Create a file if not exists") \
opt(F, file-truncate, no_argument, "Truncate file") \
opt(p, pipe, no_argument, "Create a named pipe (FIFO) if not exists") \
opt(m, mode, required_argument, "Mode to check") \
opt(o, owner, required_argument, "Owner to check (user:group)") \
opt(s, symlinks, no_argument, "follow symbolic links (irrelevant on linux)") \
opt(W, writable, no_argument, "Check whether the path is writable or not")
cmdline_opts(opts)

const char *applet = NULL;
const char *extraopts ="path1 [path2] [...]";
const char getoptstring[] = "dDfFpm:o:sW" getoptstring_COMMON;
const struct option longopts[] = {
{ "directory", 0, NULL, 'd'},
{ "directory-truncate", 0, NULL, 'D'},
{ "file", 0, NULL, 'f'},
{ "file-truncate", 0, NULL, 'F'},
{ "pipe", 0, NULL, 'p'},
{ "mode", 1, NULL, 'm'},
{ "owner", 1, NULL, 'o'},
{ "symlinks", 0, NULL, 's'},
{ "writable", 0, NULL, 'W'},
longopts_COMMON
};
const char * const longopts_help[] = {
"Create a directory if not exists",
"Create/empty directory",
"Create a file if not exists",
"Truncate file",
"Create a named pipe (FIFO) if not exists",
"Mode to check",
"Owner to check (user:group)",
"follow symbolic links (irrelevant on linux)",
"Check whether the path is writable or not",
longopts_help_COMMON
};
const char *usagestring = NULL;

static int get_dirfd(char *path, bool symlinks)
Expand Down
30 changes: 9 additions & 21 deletions src/fstabinfo/fstabinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,28 +68,16 @@ extern char **environ;

const char *applet = NULL;
const char *extraopts = NULL;
const char getoptstring[] = "MRbmop:t:" getoptstring_COMMON;
const struct option longopts[] = {
{ "mount", 0, NULL, 'M' },
{ "remount", 0, NULL, 'R' },
{ "blockdevice", 0, NULL, 'b' },
{ "mountargs", 0, NULL, 'm' },
{ "options", 0, NULL, 'o' },
{ "passno", 1, NULL, 'p' },
{ "fstype", 1, NULL, 't' },
longopts_COMMON
};
const char * const longopts_help[] = {
"Mounts the filesystem from the mountpoint",
"Remounts the filesystem based on the information in fstab",
"Extract the block device",
"Show arguments needed to mount the entry",
"Extract the options field",
"Extract or query the pass number field",
"List entries with matching file system type",
longopts_help_COMMON
};
const char *usagestring = NULL;
#define opts(opt, opt_long) \
opt(M, mount, no_argument, "Mounts the filesystem from the mountpoint") \
opt(R, remount, no_argument, "Remounts the filesystem based on the information in fstab") \
opt(b, blockdevice, no_argument, "Extract the block device") \
opt(m, mountargs, no_argument, "Show arguments needed to mount the entry") \
opt(o, options, no_argument, "Extract the options field") \
opt(p, passno, required_argument, "Extract or query the pass number field") \
opt(t, fstype, required_argument, "List entries with matching file system type")
cmdline_opts(opts)

#ifdef HAVE_GETMNTENT
static struct mntent *
Expand Down
16 changes: 5 additions & 11 deletions src/kill_all/kill_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,13 @@

const char *applet = NULL;
const char *extraopts = "[signal number]";
const char getoptstring[] = "do:" getoptstring_COMMON;
const struct option longopts[] = {
{ "dry-run", 0, NULL, 'd' },
{ "omit", 1, NULL, 'o' },
longopts_COMMON
};
const char * const longopts_help[] = {
"print what would be done",
"omit this pid (can be repeated)",
longopts_help_COMMON
};
const char *usagestring = NULL;

#define opts(opt, opt_long) \
opt(d, dry-run, no_argument, "print what would be done") \
opt(o, omit, required_argument, "omit this pid (can be repeated)")
cmdline_opts(opts)

static int mount_proc(void)
{
pid_t rc;
Expand Down
48 changes: 15 additions & 33 deletions src/mountinfo/mountinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,40 +49,22 @@
const char *applet = NULL;
const char *procmounts = "/proc/mounts";
const char *extraopts = "[mount1] [mount2] ...";
const char getoptstring[] = "f:F:n:N:o:O:p:P:iste:E:" getoptstring_COMMON;
const struct option longopts[] = {
{ "fstype-regex", 1, NULL, 'f'},
{ "skip-fstype-regex", 1, NULL, 'F'},
{ "node-regex", 1, NULL, 'n'},
{ "skip-node-regex", 1, NULL, 'N'},
{ "options-regex", 1, NULL, 'o'},
{ "skip-options-regex", 1, NULL, 'O'},
{ "point-regex", 1, NULL, 'p'},
{ "skip-point-regex", 1, NULL, 'P'},
{ "options", 0, NULL, 'i'},
{ "fstype", 0, NULL, 's'},
{ "node", 0, NULL, 't'},
{ "netdev", 0, NULL, 'e'},
{ "nonetdev", 0, NULL, 'E'},
longopts_COMMON
};
const char * const longopts_help[] = {
"fstype regex to find",
"fstype regex to skip",
"node regex to find",
"node regex to skip",
"options regex to find",
"options regex to skip",
"point regex to find",
"point regex to skip",
"print options",
"print fstype",
"print node",
"is it a network device",
"is it not a network device",
longopts_help_COMMON
};
const char *usagestring = NULL;
#define opts(opt, opt_long) \
opt(f, fstype-regex, required_argument, "fstype regex to find") \
opt(F, skip-fstype-regex, required_argument, "fstype regex to skip") \
opt(n, node-regex, required_argument, "node regex to find") \
opt(N, skip-node-regex, required_argument, "node regex to skip") \
opt(o, options-regex, required_argument, "options regex to find") \
opt(O, skip-options-regex, required_argument, "options regex to skip") \
opt(p, point-regex, required_argument, "point regex to find") \
opt(P, skip-point-regex, required_argument, "point regex to skip") \
opt(i, options, no_argument, "print options") \
opt(s, fstype, no_argument, "print fstype") \
opt(t, node, no_argument, "print node") \
opt(e, netdev, no_argument, "is it a network device") \
opt(E, nonetdev, no_argument, "is it not a network device")
cmdline_opts(opts)

typedef enum {
mount_from,
Expand Down
30 changes: 10 additions & 20 deletions src/openrc-run/openrc-run.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,17 @@
#define WARN_TIMEOUT 10 /* warn about this every N seconds */

const char *applet = NULL;
const char *extraopts = "stop | start | restart | status | describe | zap";
const char getoptstring[] = "dDsSvl:Z" getoptstring_COMMON;
const struct option longopts[] = {
{ "debug", 0, NULL, 'd'},
{ "dry-run", 0, NULL, 'Z'},
{ "ifstarted", 0, NULL, 's'},
{ "ifstopped", 0, NULL, 'S'},
{ "nodeps", 0, NULL, 'D'},
{ "lockfd", 1, NULL, 'l'},
longopts_COMMON
};
const char *const longopts_help[] = {
"set xtrace when running the script",
"show what would be done",
"only run commands when started",
"only run commands when stopped",
"ignore dependencies",
"fd of the exclusive lock from rc",
longopts_help_COMMON
};
const char *usagestring = NULL;
const char *extraopts = "stop | start | restart | status | describe | zap";
#define opts(opt, opt_long) \
opt(d, debug, no_argument, "set xtrace when running the script") \
opt(Z, dry-run, no_argument, "show what would be done") \
opt(s, ifstarted, no_argument, "only run commands when started") \
opt(S, ifstopped, no_argument, "only run commands when stopped") \
opt(D, nodeps, no_argument, "ignore dependencies") \
opt(l, lockfd, required_argument, "fd of the exclusive lock from rc") \
opt(U, user, no_argument, "Run in user mode")
cmdline_opts(opts)

static char *service, *runlevel, *ibsave, *prefix;
static RC_DEPTREE *deptree;
Expand Down
40 changes: 13 additions & 27 deletions src/openrc-shutdown/openrc-shutdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,33 +44,19 @@

const char *applet = NULL;
const char *extraopts = NULL;
const char getoptstring[] = "cdDfFHKpRrsw" getoptstring_COMMON;
const struct option longopts[] = {
{ "cancel", no_argument, NULL, 'c'},
{ "no-write", no_argument, NULL, 'd'},
{ "dry-run", no_argument, NULL, 'D'},
{ "halt", no_argument, NULL, 'H'},
{ "kexec", no_argument, NULL, 'K'},
{ "poweroff", no_argument, NULL, 'p'},
{ "reexec", no_argument, NULL, 'R'},
{ "reboot", no_argument, NULL, 'r'},
{ "single", no_argument, NULL, 's'},
{ "write-only", no_argument, NULL, 'w'},
longopts_COMMON
};
const char * const longopts_help[] = {
"cancel a pending shutdown",
"do not write wtmp record",
"print actions instead of executing them",
"halt the system",
"reboot the system using kexec",
"power off the system",
"re-execute init (use after upgrading)",
"reboot the system",
"single user mode",
"write wtmp boot record and exit",
longopts_help_COMMON
};
#define opts(opt, opt_long) \
opt(c, cancel, no_argument, "cancel a pending shutdown") \
opt(d, no-write, no_argument, "do not write wtmp record") \
opt(D, dry-run, no_argument, "print actions instead of executing them") \
opt(H, halt, no_argument, "halt the system") \
opt(K, kexec, no_argument, "reboot the system using kexec") \
opt(p, poweroff, no_argument, "power off the system") \
opt(R, reexec, no_argument, "re-execute init (use after upgrading)") \
opt(r, reboot, no_argument, "reboot the system") \
opt(s, single, no_argument, "single user mode") \
opt(w, write-only, no_argument, "write wtmp boot record and exit")
cmdline_opts(opts)

const char *usagestring = ""
"Usage: openrc-shutdown -c | --cancel\n"
" or: openrc-shutdown -R | --reexec\n"
Expand Down
27 changes: 10 additions & 17 deletions src/openrc/rc.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,17 @@
#include "_usage.h"
#include "helpers.h"

#define opts(opt, opt_long) \
opt(n, no-stop, no_argument, "do not stop any services") \
opt(o, override, required_argument, "override the next runlevel to change into\n" \
"when leaving single user or boot runlevels") \
opt(s, service, required_argument, "runs the service specified with the rest of the arguments") \
opt(S, sys, no_argument, "output the RC system type, if any") \
opt(U, user, no_argument, "Run in user mode")
cmdline_opts(opts)

const char *extraopts = NULL;
const char getoptstring[] = "a:no:s:S" getoptstring_COMMON;
const struct option longopts[] = {
{ "no-stop", 0, NULL, 'n' },
{ "override", 1, NULL, 'o' },
{ "service", 1, NULL, 's' },
{ "sys", 0, NULL, 'S' },
longopts_COMMON
};
const char * const longopts_help[] = {
"do not stop any services",
"override the next runlevel to change into\nwhen leaving single user or boot runlevels",
"runs the service specified with the rest\nof the arguments",
"output the RC system type, if any",
longopts_help_COMMON
};
const char *usagestring = ""
"Usage: openrc [options] [<runlevel>]";
const char *usagestring = "Usage: openrc [options] [<runlevel>]";

#define INITSH RC_LIBEXECDIR "/sh/init.sh"
#define INITEARLYSH RC_LIBEXECDIR "/sh/init-early.sh"
Expand Down
31 changes: 10 additions & 21 deletions src/rc-depend/rc-depend.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,16 @@

const char *applet = NULL;
const char *extraopts = NULL;
const char getoptstring[] = "aot:suTF:" getoptstring_COMMON;
const struct option longopts[] = {
{ "starting", 0, NULL, 'a'},
{ "stopping", 0, NULL, 'o'},
{ "type", 1, NULL, 't'},
{ "notrace", 0, NULL, 'T'},
{ "strict", 0, NULL, 's'},
{ "update", 0, NULL, 'u'},
{ "deptree-file", 1, NULL, 'F'},
longopts_COMMON
};
const char * const longopts_help[] = {
"Order services as if runlevel is starting",
"Order services as if runlevel is stopping",
"Type(s) of dependency to list",
"Don't trace service dependencies",
"Only use what is in the runlevels",
"Force an update of the dependency tree",
"File to load cached deptree from",
longopts_help_COMMON
};
#define opts(opt, opt_long) \
opt(a, starting, no_argument, "Order services as if runlevel is starting") \
opt(o, stopping, no_argument, "Order services as if runlevel is stopping") \
opt(t, type, required_argument, "Type(s) of dependency to list") \
opt(T, notrace, no_argument, "Don't trace service dependencies") \
opt(s, strict, no_argument, "Only use what is in the runlevels") \
opt(u, update, no_argument, "Force an update of the dependency tree") \
opt(F, deptree-file, required_argument, "File to load cached deptree from") \
opt(U, user, no_argument, "Run in user mode")
cmdline_opts(opts)
const char *usagestring = NULL;

int main(int argc, char **argv)
Expand Down
47 changes: 16 additions & 31 deletions src/rc-service/rc-service.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,22 @@

const char *applet = NULL;
const char *extraopts = NULL;
const char getoptstring[] = "cdDe:ilr:INsSZ" getoptstring_COMMON;
const struct option longopts[] = {
{ "debug", 0, NULL, 'd' },
{ "nodeps", 0, NULL, 'D' },
{ "exists", 1, NULL, 'e' },
{ "ifcrashed", 0, NULL, 'c' },
{ "ifexists", 0, NULL, 'i' },
{ "ifinactive", 0, NULL, 'I' },
{ "ifnotstarted", 0, NULL, 'N' },
{ "ifstarted", 0, NULL, 's' },
{ "ifstopped", 0, NULL, 'S' },
{ "list", 0, NULL, 'l' },
{ "resolve", 1, NULL, 'r' },
{ "dry-run", 0, NULL, 'Z' },
longopts_COMMON
};
const char * const longopts_help[] = {
"set xtrace when running the command",
"ignore dependencies",
"tests if the service exists or not",
"if the service is crashed run the command",
"if the service exists run the command",
"if the service is inactive run the command",
"if the service is not started run the command",
"if the service is started run the command",
"if the service is stopped run the command",
"list all available services",
"resolve the service name to an init script",
"dry run (show what would happen)",
longopts_help_COMMON
};
#define opts(opt, opt_long) \
opt(d, debug, no_argument, "set xtrace when running the command") \
opt(D, nodeps, no_argument, "ignore dependencies") \
opt(e, exists, required_argument, "tests if the service exists or not") \
opt(c, ifcrashed, no_argument, "if the service is crashed run the command") \
opt(i, ifexists, no_argument, "if the service exists run the command") \
opt(I, ifinactive, no_argument, "if the service is inactive run the command") \
opt(N, ifnotstarted, no_argument, "if the service is not started run the command") \
opt(s, ifstarted, no_argument, "if the service is started run the command") \
opt(S, ifstopped, no_argument, "if the service is stopped run the command") \
opt(l, list, no_argument, "list all available services") \
opt(r, resolve, required_argument, "resolve the service name to an init script") \
opt(Z, dry-run, no_argument, "dry run (show what would happen)") \
opt(U, user, no_argument, "Run in user mode")
cmdline_opts(opts)

const char *usagestring = ""
"Usage: rc-service [options] [-i] <service> <cmd>...\n"
" or: rc-service [options] -e <service>\n"
Expand Down
Loading