1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/fsaccess/fsaccess.c Mon Mar 07 23:54:48 2022 +0100
1.3 @@ -0,0 +1,104 @@
1.4 +/*
1.5 + * Access a filesystem.
1.6 + *
1.7 + * Copyright (C) 2019, 2022 Paul Boddie <paul@boddie.org.uk>
1.8 + *
1.9 + * This program is free software; you can redistribute it and/or
1.10 + * modify it under the terms of the GNU General Public License as
1.11 + * published by the Free Software Foundation; either version 2 of
1.12 + * the License, or (at your option) any later version.
1.13 + *
1.14 + * This program is distributed in the hope that it will be useful,
1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 + * GNU General Public License for more details.
1.18 + *
1.19 + * You should have received a copy of the GNU General Public License
1.20 + * along with this program; if not, write to the Free Software
1.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
1.22 + * Boston, MA 02110-1301, USA
1.23 + */
1.24 +
1.25 +#include <stdio.h>
1.26 +
1.27 +#include "ops.h"
1.28 +
1.29 +
1.30 +
1.31 +/* Help message. */
1.32 +
1.33 +char help_text[] = "\
1.34 +Usage: %s [ <options> ] <operation> <filename>...\n\
1.35 +\n\
1.36 +File ownership options:\n\
1.37 +\n\
1.38 + -g GID Set group identifier for new files\n\
1.39 + -u UID Set user identifier for new files\n\
1.40 +\n\
1.41 +File permission options:\n\
1.42 +\n\
1.43 + -m MASK Set mode/permissions mask for new directories\n\
1.44 +\n\
1.45 +Transfer operations:\n\
1.46 +\n\
1.47 + copy-in Copy files into a directory within the image\n\
1.48 + copy-out Copy files from the image into a directory\n\
1.49 +\n\
1.50 +Image operations:\n\
1.51 +\n\
1.52 + ls List files and directories within the image\n\
1.53 + mkdir Make directories within the image\n\
1.54 + rm Remove non-directory objects from the image\n\
1.55 + rmdir Remove directories from the image\n\
1.56 + stat Show statistics for files and directories\n\
1.57 +\n\
1.58 +Script operations:\n\
1.59 +\n\
1.60 + script Read operations from a script file\n\
1.61 +";
1.62 +
1.63 +/* Operations exposed by the program. */
1.64 +
1.65 +struct operation operations[] = {
1.66 +#if 0
1.67 + {"copy-in", copy_in},
1.68 + {"copy-out", copy_out},
1.69 +#endif
1.70 + {"ls", list_objects},
1.71 +#if 0
1.72 + {"mkdir", make_dirs},
1.73 + {"rm", remove_non_dirs},
1.74 + {"rmdir", remove_dirs},
1.75 + {"script", run_script},
1.76 + {"stat", stat_objects},
1.77 +#endif
1.78 + {NULL, NULL},
1.79 + };
1.80 +
1.81 +/* Main program. */
1.82 +
1.83 +int main(int argc, char *argv[])
1.84 +{
1.85 + /* Program argument details. */
1.86 +
1.87 + char **args;
1.88 + int num_args;
1.89 + enum op_results op_result;
1.90 +
1.91 + args = &argv[1];
1.92 + num_args = argc - 1;
1.93 +
1.94 + if (num_args < 2)
1.95 + {
1.96 + fprintf(stderr, help_text, argv[0]);
1.97 + return 1;
1.98 + }
1.99 +
1.100 + /* Perform the requested operation. */
1.101 +
1.102 + op_result = run_operation(args[0], num_args - 1, &args[1]);
1.103 + return handle_op_result(args[0], op_result);
1.104 +}
1.105 +
1.106 +/* vim: tabstop=4 expandtab shiftwidth=4
1.107 +*/