paul@278 | 1 | /* |
paul@278 | 2 | * List objects in a filesystem. |
paul@278 | 3 | * |
paul@278 | 4 | * Copyright (C) 2019, 2022 Paul Boddie <paul@boddie.org.uk> |
paul@278 | 5 | * |
paul@278 | 6 | * This program is free software; you can redistribute it and/or |
paul@278 | 7 | * modify it under the terms of the GNU General Public License as |
paul@278 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@278 | 9 | * the License, or (at your option) any later version. |
paul@278 | 10 | * |
paul@278 | 11 | * This program is distributed in the hope that it will be useful, |
paul@278 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@278 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@278 | 14 | * GNU General Public License for more details. |
paul@278 | 15 | * |
paul@278 | 16 | * You should have received a copy of the GNU General Public License |
paul@278 | 17 | * along with this program; if not, write to the Free Software |
paul@278 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@278 | 19 | * Boston, MA 02110-1301, USA |
paul@278 | 20 | */ |
paul@278 | 21 | |
paul@278 | 22 | #include <stdio.h> |
paul@278 | 23 | |
paul@278 | 24 | #include <ext2fs/ext2fs.h> |
paul@278 | 25 | |
paul@278 | 26 | #include "format.h" |
paul@278 | 27 | #include "image.h" |
paul@278 | 28 | #include "session.h" |
paul@278 | 29 | #include "utils.h" |
paul@278 | 30 | |
paul@278 | 31 | |
paul@278 | 32 | |
paul@278 | 33 | /* List objects in the filesystem image. */ |
paul@278 | 34 | |
paul@278 | 35 | int list(ext2_filsys fs, int argc, char *argv[]) |
paul@278 | 36 | { |
paul@278 | 37 | int i; |
paul@278 | 38 | char *path; |
paul@278 | 39 | |
paul@278 | 40 | for (i = 0; i < argc; i++) |
paul@278 | 41 | { |
paul@278 | 42 | path = argv[i]; |
paul@278 | 43 | |
paul@278 | 44 | /* Emit each object. */ |
paul@278 | 45 | |
paul@278 | 46 | puts(path); |
paul@278 | 47 | |
paul@278 | 48 | /* List individual files or directories. */ |
paul@278 | 49 | |
paul@278 | 50 | if (utils_list_dir(fs, path)) |
paul@278 | 51 | { |
paul@278 | 52 | fprintf(stderr, "Failed to list object: %s\n", path); |
paul@278 | 53 | return 1; |
paul@278 | 54 | } |
paul@278 | 55 | } |
paul@278 | 56 | |
paul@278 | 57 | return 0; |
paul@278 | 58 | } |
paul@278 | 59 | |
paul@278 | 60 | /* vim: tabstop=4 expandtab shiftwidth=4 |
paul@278 | 61 | */ |