paul@226 | 1 | /* |
paul@226 | 2 | * Access a filesystem. |
paul@226 | 3 | * |
paul@226 | 4 | * Copyright (C) 2019 Paul Boddie <paul@boddie.org.uk> |
paul@226 | 5 | * |
paul@226 | 6 | * This program is free software; you can redistribute it and/or |
paul@226 | 7 | * modify it under the terms of the GNU General Public License as |
paul@226 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@226 | 9 | * the License, or (at your option) any later version. |
paul@226 | 10 | * |
paul@226 | 11 | * This program is distributed in the hope that it will be useful, |
paul@226 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@226 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@226 | 14 | * GNU General Public License for more details. |
paul@226 | 15 | * |
paul@226 | 16 | * You should have received a copy of the GNU General Public License |
paul@226 | 17 | * along with this program; if not, write to the Free Software |
paul@226 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@226 | 19 | * Boston, MA 02110-1301, USA |
paul@226 | 20 | */ |
paul@226 | 21 | |
paul@226 | 22 | #include <stdio.h> |
paul@226 | 23 | #include <stdlib.h> |
paul@226 | 24 | #include <string.h> |
paul@226 | 25 | |
paul@226 | 26 | #include <sys/types.h> |
paul@226 | 27 | #include <sys/stat.h> |
paul@226 | 28 | |
paul@226 | 29 | #include <ext2fs/ext2fs.h> |
paul@226 | 30 | |
paul@226 | 31 | #include "file.h" |
paul@226 | 32 | #include "format.h" |
paul@226 | 33 | #include "image.h" |
paul@226 | 34 | #include "path.h" |
paul@226 | 35 | |
paul@226 | 36 | |
paul@226 | 37 | |
paul@226 | 38 | /* Copy buffer size. */ |
paul@226 | 39 | |
paul@226 | 40 | const int BUFSIZE = 4096; |
paul@226 | 41 | |
paul@226 | 42 | |
paul@226 | 43 | |
paul@226 | 44 | /* Show directory entries when iterating. */ |
paul@226 | 45 | |
paul@226 | 46 | static int image_list_dir_proc(struct ext2_dir_entry *dirent, int offset, |
paul@226 | 47 | int blocksize, char *buf, void *priv_data) |
paul@226 | 48 | { |
paul@226 | 49 | ext2_filsys fs = (ext2_filsys) priv_data; |
paul@226 | 50 | struct ext2_inode inode; |
paul@226 | 51 | |
paul@226 | 52 | /* Obtain the inode details for metadata. */ |
paul@226 | 53 | |
paul@226 | 54 | if (ext2fs_read_inode(fs, dirent->inode, &inode)) |
paul@226 | 55 | return DIRENT_ABORT; |
paul@226 | 56 | |
paul@226 | 57 | /* Output details in the style of "ls -l" showing directory, permissions, |
paul@226 | 58 | owner, group and size information. */ |
paul@226 | 59 | |
paul@226 | 60 | printf("%s%s %5d %5d %6d ", |
paul@226 | 61 | _image_isdir(fs, dirent->inode) ? "d" : "-", |
paul@226 | 62 | get_permission_string(inode.i_mode), |
paul@226 | 63 | inode.i_uid, |
paul@226 | 64 | inode.i_gid, |
paul@226 | 65 | EXT2_I_SIZE(&inode)); |
paul@226 | 66 | |
paul@226 | 67 | /* Output the name which is presumably not necessarily null-terminated. */ |
paul@226 | 68 | |
paul@226 | 69 | fwrite(dirent->name, sizeof(char), ext2fs_dirent_name_len(dirent), stdout); |
paul@226 | 70 | fputc((int) '\n', stdout); |
paul@226 | 71 | return 0; |
paul@226 | 72 | } |
paul@226 | 73 | |
paul@226 | 74 | |
paul@226 | 75 | |
paul@226 | 76 | /* Copy a file into the filesystem image. */ |
paul@226 | 77 | |
paul@226 | 78 | int copy_file_in(const char *filename, ext2_filsys fs, ext2_ino_t ino_file, int flags) |
paul@226 | 79 | { |
paul@226 | 80 | int retval = 0; |
paul@226 | 81 | ext2_file_t file; |
paul@226 | 82 | |
paul@226 | 83 | /* Copying details. */ |
paul@226 | 84 | |
paul@226 | 85 | FILE *fp; |
paul@226 | 86 | char buf[BUFSIZE]; |
paul@226 | 87 | size_t got; |
paul@226 | 88 | unsigned int written; |
paul@226 | 89 | |
paul@226 | 90 | /* Open a file in the target directory. */ |
paul@226 | 91 | |
paul@226 | 92 | if (ext2fs_file_open(fs, ino_file, flags, &file)) |
paul@226 | 93 | return 1; |
paul@226 | 94 | |
paul@226 | 95 | /* Open the file in the source directory. */ |
paul@226 | 96 | |
paul@226 | 97 | fp = fopen(filename, "r"); |
paul@226 | 98 | |
paul@226 | 99 | /* Copy the file content. */ |
paul@226 | 100 | |
paul@226 | 101 | if (fp != NULL) |
paul@226 | 102 | { |
paul@226 | 103 | while (got = fread(buf, sizeof(char), BUFSIZE, fp)) |
paul@226 | 104 | { |
paul@226 | 105 | while (got) |
paul@226 | 106 | { |
paul@226 | 107 | if (ext2fs_file_write(file, buf, got, &written)) |
paul@226 | 108 | { |
paul@226 | 109 | retval = 1; |
paul@226 | 110 | goto close_files; |
paul@226 | 111 | } |
paul@226 | 112 | got -= written; |
paul@226 | 113 | } |
paul@226 | 114 | } |
paul@226 | 115 | } |
paul@226 | 116 | |
paul@226 | 117 | close_files: |
paul@226 | 118 | fclose(fp); |
paul@226 | 119 | ext2fs_file_flush(file); |
paul@226 | 120 | ext2fs_file_close(file); |
paul@226 | 121 | |
paul@226 | 122 | return retval; |
paul@226 | 123 | } |
paul@226 | 124 | |
paul@226 | 125 | /* Copy a file out of the filesystem image. */ |
paul@226 | 126 | |
paul@226 | 127 | int copy_file_out(const char *target, const char *filename, int target_is_file, |
paul@226 | 128 | ext2_filsys fs, ext2_ino_t ino_file) |
paul@226 | 129 | { |
paul@226 | 130 | int retval = 0; |
paul@226 | 131 | ext2_file_t file; |
paul@226 | 132 | |
paul@226 | 133 | /* Copying details. */ |
paul@226 | 134 | |
paul@226 | 135 | FILE *fp; |
paul@226 | 136 | char buf[BUFSIZE]; |
paul@226 | 137 | unsigned int got; |
paul@226 | 138 | size_t written; |
paul@226 | 139 | |
paul@226 | 140 | /* Open the file in the source directory. */ |
paul@226 | 141 | |
paul@226 | 142 | if (ext2fs_file_open(fs, ino_file, 0, &file)) |
paul@226 | 143 | return 1; |
paul@226 | 144 | |
paul@226 | 145 | /* Open a file in the target directory. */ |
paul@226 | 146 | |
paul@226 | 147 | if (target_is_file) |
paul@226 | 148 | fp = fopen(target, "w"); |
paul@226 | 149 | else |
paul@226 | 150 | fp = open_file_in_dir(target, path_basename(filename), "w"); |
paul@226 | 151 | |
paul@226 | 152 | /* Copy the file content. */ |
paul@226 | 153 | |
paul@226 | 154 | if (fp != NULL) |
paul@226 | 155 | { |
paul@226 | 156 | do |
paul@226 | 157 | { |
paul@226 | 158 | if (ext2fs_file_read(file, buf, BUFSIZE, &got)) |
paul@226 | 159 | { |
paul@226 | 160 | retval = 1; |
paul@226 | 161 | goto close_files; |
paul@226 | 162 | } |
paul@226 | 163 | |
paul@226 | 164 | while (got) |
paul@226 | 165 | { |
paul@226 | 166 | written = fwrite(buf, sizeof(char), got, fp); |
paul@226 | 167 | got -= written; |
paul@226 | 168 | } |
paul@226 | 169 | |
paul@226 | 170 | } while (got); |
paul@226 | 171 | } |
paul@226 | 172 | |
paul@226 | 173 | close_files: |
paul@226 | 174 | fclose(fp); |
paul@226 | 175 | ext2fs_file_close(file); |
paul@226 | 176 | |
paul@226 | 177 | return retval; |
paul@226 | 178 | } |
paul@226 | 179 | |
paul@226 | 180 | |
paul@226 | 181 | |
paul@226 | 182 | /* Copy source files from the external environment into the filesystem image. */ |
paul@226 | 183 | |
paul@226 | 184 | int copy_in(ext2_filsys fs, int argc, char *argv[]) |
paul@226 | 185 | { |
paul@226 | 186 | errcode_t retval; |
paul@226 | 187 | |
paul@226 | 188 | /* Target filename details. */ |
paul@226 | 189 | |
paul@226 | 190 | const char *target = argv[argc - 1]; |
paul@226 | 191 | const char *target_remaining = argv[argc - 1]; |
paul@226 | 192 | const char *basename; |
paul@226 | 193 | int target_is_file; |
paul@226 | 194 | |
paul@226 | 195 | /* Target file and directory details. */ |
paul@226 | 196 | |
paul@226 | 197 | int target_is_new; |
paul@226 | 198 | ext2_ino_t ino_file, ino_target; |
paul@226 | 199 | int flags; |
paul@226 | 200 | |
paul@226 | 201 | /* Source file details. */ |
paul@226 | 202 | |
paul@226 | 203 | struct stat st; |
paul@226 | 204 | int i; |
paul@226 | 205 | |
paul@226 | 206 | /* Locate the target and test whether it is a file or a directory. */ |
paul@226 | 207 | |
paul@226 | 208 | if (image_find_path(fs, &target_remaining, &ino_target)) |
paul@226 | 209 | { |
paul@226 | 210 | /* Only a non-existent file in an existing directory is permitted. */ |
paul@226 | 211 | |
paul@226 | 212 | if (!_image_isdir(fs, ino_target) || !path_is_leafname(target_remaining)) |
paul@226 | 213 | { |
paul@226 | 214 | printf("Target %s not found.\n", target); |
paul@226 | 215 | return 1; |
paul@226 | 216 | } |
paul@226 | 217 | |
paul@226 | 218 | target_is_file = 1; |
paul@226 | 219 | target_is_new = 1; |
paul@226 | 220 | } |
paul@226 | 221 | else |
paul@226 | 222 | { |
paul@226 | 223 | target_is_file = _image_isfile(fs, ino_target); |
paul@226 | 224 | target_is_new = 0; |
paul@226 | 225 | } |
paul@226 | 226 | |
paul@226 | 227 | /* Only permit a target file when one source file is given. */ |
paul@226 | 228 | |
paul@226 | 229 | if (target_is_file) |
paul@226 | 230 | { |
paul@226 | 231 | if (argc > 2) |
paul@226 | 232 | { |
paul@226 | 233 | printf("Target %s can only be a file when copying a single file.\n", target); |
paul@226 | 234 | return 1; |
paul@226 | 235 | } |
paul@226 | 236 | } |
paul@226 | 237 | else if (!_image_isdir(fs, ino_target)) |
paul@226 | 238 | { |
paul@226 | 239 | printf("Target %s is not a directory.\n", target); |
paul@226 | 240 | return 1; |
paul@226 | 241 | } |
paul@226 | 242 | |
paul@226 | 243 | /* Copy each source object to the target directory. */ |
paul@226 | 244 | |
paul@226 | 245 | for (i = 0; i < argc - 1; i++) |
paul@226 | 246 | { |
paul@226 | 247 | if (target_is_file) |
paul@226 | 248 | basename = target_remaining; |
paul@226 | 249 | else |
paul@226 | 250 | { |
paul@226 | 251 | basename = path_basename(argv[i]); |
paul@226 | 252 | target_is_new = image_find_file(fs, target, basename, &ino_file); |
paul@226 | 253 | } |
paul@226 | 254 | |
paul@226 | 255 | /* Directories are created with the same metadata. */ |
paul@226 | 256 | |
paul@226 | 257 | if (isdir(argv[i])) |
paul@226 | 258 | { |
paul@226 | 259 | if (!target_is_new) |
paul@226 | 260 | { |
paul@226 | 261 | printf("Target %s cannot be created since it already exists.\n", target); |
paul@226 | 262 | return 1; |
paul@226 | 263 | } |
paul@226 | 264 | |
paul@226 | 265 | /* Obtain the metadata. */ |
paul@226 | 266 | |
paul@226 | 267 | if (lstat(argv[i], &st)) |
paul@226 | 268 | return 1; |
paul@226 | 269 | |
paul@226 | 270 | retval = image_make_dir(fs, ino_target, basename, st.st_mode, |
paul@226 | 271 | st.st_uid, st.st_gid, &ino_file); |
paul@226 | 272 | |
paul@226 | 273 | if (retval) |
paul@226 | 274 | { |
paul@226 | 275 | printf("Failed to create directory %s (%d).\n", argv[i], retval); |
paul@226 | 276 | return 1; |
paul@226 | 277 | } |
paul@226 | 278 | } |
paul@226 | 279 | |
paul@226 | 280 | /* Files are copied. */ |
paul@226 | 281 | |
paul@226 | 282 | else if (isfile(argv[i])) |
paul@226 | 283 | { |
paul@226 | 284 | flags = EXT2_FILE_WRITE; |
paul@226 | 285 | |
paul@226 | 286 | /* Obtain the inode for the target file. */ |
paul@226 | 287 | |
paul@226 | 288 | if (target_is_new) |
paul@226 | 289 | { |
paul@226 | 290 | /* Populate the inode details. */ |
paul@226 | 291 | |
paul@226 | 292 | if (lstat(argv[i], &st)) |
paul@226 | 293 | return 1; |
paul@226 | 294 | |
paul@226 | 295 | retval = image_create_file(fs, ino_target, basename, st.st_mode, |
paul@226 | 296 | st.st_uid, st.st_gid, &ino_file); |
paul@226 | 297 | if (retval) |
paul@226 | 298 | { |
paul@226 | 299 | printf("Failed to create file %s (%d).\n", argv[i], retval); |
paul@226 | 300 | return 1; |
paul@226 | 301 | } |
paul@226 | 302 | |
paul@226 | 303 | flags |= EXT2_FILE_CREATE; |
paul@226 | 304 | } |
paul@226 | 305 | |
paul@226 | 306 | /* NOTE: Overwrite/update metadata where appropriate. */ |
paul@226 | 307 | |
paul@226 | 308 | if (copy_file_in(argv[i], fs, ino_file, flags)) |
paul@226 | 309 | { |
paul@226 | 310 | printf("Failed to write to %s.\n", argv[i]); |
paul@226 | 311 | return 1; |
paul@226 | 312 | } |
paul@226 | 313 | } |
paul@226 | 314 | } |
paul@226 | 315 | |
paul@226 | 316 | return 0; |
paul@226 | 317 | } |
paul@226 | 318 | |
paul@226 | 319 | /* Copy source files out of the filesystem image into the external environment. */ |
paul@226 | 320 | |
paul@226 | 321 | int copy_out(ext2_filsys fs, int argc, char *argv[]) |
paul@226 | 322 | { |
paul@226 | 323 | /* Target filename details. */ |
paul@226 | 324 | |
paul@226 | 325 | char *target = argv[argc - 1]; |
paul@226 | 326 | int target_is_file; |
paul@226 | 327 | |
paul@226 | 328 | /* Target file and directory details. */ |
paul@226 | 329 | |
paul@226 | 330 | ext2_file_t file; |
paul@226 | 331 | ext2_ino_t ino_file; |
paul@226 | 332 | |
paul@226 | 333 | /* Source file details. */ |
paul@226 | 334 | |
paul@226 | 335 | const char *path; |
paul@226 | 336 | int i; |
paul@226 | 337 | |
paul@226 | 338 | /* Locate the target and test whether it is a directory. */ |
paul@226 | 339 | |
paul@226 | 340 | if (!isdir(target)) |
paul@226 | 341 | { |
paul@226 | 342 | /* Only a new or existing file in an existing directory is permitted. */ |
paul@226 | 343 | |
paul@226 | 344 | if (isfile(target) || isdir_dirname(target)) |
paul@226 | 345 | target_is_file = 1; |
paul@226 | 346 | else |
paul@226 | 347 | { |
paul@226 | 348 | printf("Target %s is not a directory.\n", target); |
paul@226 | 349 | return 1; |
paul@226 | 350 | } |
paul@226 | 351 | |
paul@226 | 352 | /* Only permit a target file when one source file is given. */ |
paul@226 | 353 | |
paul@226 | 354 | if (argc > 2) |
paul@226 | 355 | { |
paul@226 | 356 | printf("Target %s can only be a file when copying a single file.\n", target); |
paul@226 | 357 | return 1; |
paul@226 | 358 | } |
paul@226 | 359 | } |
paul@226 | 360 | else |
paul@226 | 361 | target_is_file = 0; |
paul@226 | 362 | |
paul@226 | 363 | /* For each source filename, test whether it references a file. */ |
paul@226 | 364 | |
paul@226 | 365 | for (i = 0; i < argc - 1; i++) |
paul@226 | 366 | { |
paul@226 | 367 | if (!image_isfile(fs, argv[i])) |
paul@226 | 368 | { |
paul@226 | 369 | printf("Source %s is not a file.\n", argv[i]); |
paul@226 | 370 | return 1; |
paul@226 | 371 | } |
paul@226 | 372 | } |
paul@226 | 373 | |
paul@226 | 374 | /* Copy each source file to the target directory. */ |
paul@226 | 375 | |
paul@226 | 376 | for (i = 0; i < argc - 1; i++) |
paul@226 | 377 | { |
paul@226 | 378 | path = argv[i]; |
paul@226 | 379 | |
paul@226 | 380 | if (image_find_path(fs, &path, &ino_file)) |
paul@226 | 381 | return 1; |
paul@226 | 382 | |
paul@226 | 383 | if (copy_file_out(target, argv[i], target_is_file, fs, ino_file)) |
paul@226 | 384 | { |
paul@226 | 385 | printf("Failed to read from %s.\n", argv[i]); |
paul@226 | 386 | return 1; |
paul@226 | 387 | } |
paul@226 | 388 | |
paul@226 | 389 | /* NOTE: Overwrite/update metadata where appropriate. */ |
paul@226 | 390 | } |
paul@226 | 391 | |
paul@226 | 392 | return 0; |
paul@226 | 393 | } |
paul@226 | 394 | |
paul@226 | 395 | /* List directories in the filesystem image. */ |
paul@226 | 396 | |
paul@226 | 397 | int list_dirs(ext2_filsys fs, int argc, char *argv[]) |
paul@226 | 398 | { |
paul@226 | 399 | int i; |
paul@226 | 400 | const char *path; |
paul@226 | 401 | |
paul@226 | 402 | for (i = 0; i < argc; i++) |
paul@226 | 403 | { |
paul@226 | 404 | path = argv[i]; |
paul@226 | 405 | |
paul@226 | 406 | /* List the directory contents. */ |
paul@226 | 407 | |
paul@226 | 408 | puts(path); |
paul@226 | 409 | |
paul@226 | 410 | if (image_list_dir(fs, path, image_list_dir_proc, fs)) |
paul@226 | 411 | return 1; |
paul@226 | 412 | } |
paul@226 | 413 | |
paul@226 | 414 | return 0; |
paul@226 | 415 | } |
paul@226 | 416 | |
paul@226 | 417 | /* Make directories in the filesystem image. */ |
paul@226 | 418 | |
paul@226 | 419 | int make_dirs(ext2_filsys fs, int argc, char *argv[]) |
paul@226 | 420 | { |
paul@226 | 421 | int i; |
paul@226 | 422 | char *path_end; |
paul@226 | 423 | const char *path; |
paul@226 | 424 | ext2_ino_t ino; |
paul@226 | 425 | |
paul@226 | 426 | /* Make each directory component in the given pathname. */ |
paul@226 | 427 | |
paul@226 | 428 | for (i = 0; i < argc; i++) |
paul@226 | 429 | { |
paul@226 | 430 | path = argv[i]; |
paul@226 | 431 | if (!*path) |
paul@226 | 432 | continue; |
paul@226 | 433 | |
paul@226 | 434 | /* Search for the remaining components. */ |
paul@226 | 435 | |
paul@226 | 436 | if (!image_find_path(fs, &path, &ino)) |
paul@226 | 437 | continue; |
paul@226 | 438 | |
paul@226 | 439 | /* From the first unrecognised component, make the remaining |
paul@226 | 440 | directories. */ |
paul@226 | 441 | |
paul@226 | 442 | if (image_make_dirs(fs, &path, ino, 0777, 0, 0)) |
paul@226 | 443 | return 1; |
paul@226 | 444 | } |
paul@226 | 445 | |
paul@226 | 446 | return 0; |
paul@226 | 447 | } |
paul@226 | 448 | |
paul@226 | 449 | int main(int argc, char *argv[]) |
paul@226 | 450 | { |
paul@226 | 451 | int flags = EXT2_FLAG_RW; // | EXT2_FLAG_SOFTSUPP_FEATURES | EXT2_FLAG_64BITS; |
paul@226 | 452 | char *fsname, *operation, *filename; |
paul@226 | 453 | ext2_filsys fs = NULL; |
paul@226 | 454 | errcode_t retval; |
paul@226 | 455 | int exitcode = 0; |
paul@226 | 456 | |
paul@226 | 457 | if (argc < 4) |
paul@226 | 458 | { |
paul@226 | 459 | printf("Usage: %s <device or image file> <operation> <filename>...\n", argv[0]); |
paul@226 | 460 | return 1; |
paul@226 | 461 | } |
paul@226 | 462 | |
paul@226 | 463 | fsname = argv[1]; |
paul@226 | 464 | |
paul@226 | 465 | /* Open the filesystem image using the POSIX file access mechanism. */ |
paul@226 | 466 | |
paul@226 | 467 | retval = ext2fs_open(fsname, flags, 0, 0, unix_io_manager, &fs); |
paul@226 | 468 | if (retval) |
paul@226 | 469 | { |
paul@226 | 470 | printf("Could not open filesystem using %s\n", fsname); |
paul@226 | 471 | return 1; |
paul@226 | 472 | } |
paul@226 | 473 | |
paul@226 | 474 | //fs->default_bitmap_type = EXT2FS_BMAP64_RBTREE; |
paul@226 | 475 | |
paul@226 | 476 | retval = ext2fs_read_bitmaps(fs); |
paul@226 | 477 | if (retval) |
paul@226 | 478 | { |
paul@226 | 479 | printf("Could not read bitmaps from %s\n", fsname); |
paul@226 | 480 | return 1; |
paul@226 | 481 | } |
paul@226 | 482 | |
paul@226 | 483 | /* Perform the requested operation. */ |
paul@226 | 484 | |
paul@226 | 485 | operation = argv[2]; |
paul@226 | 486 | |
paul@226 | 487 | if (!strcmp(operation, "--copy-out")) |
paul@226 | 488 | { |
paul@226 | 489 | exitcode = copy_out(fs, argc - 3, &argv[3]); |
paul@226 | 490 | } |
paul@226 | 491 | else if (!strcmp(operation, "--copy-in")) |
paul@226 | 492 | { |
paul@226 | 493 | exitcode = copy_in(fs, argc - 3, &argv[3]); |
paul@226 | 494 | } |
paul@226 | 495 | else if (!strcmp(operation, "--list-dirs")) |
paul@226 | 496 | { |
paul@226 | 497 | exitcode = list_dirs(fs, argc - 3, &argv[3]); |
paul@226 | 498 | } |
paul@226 | 499 | else if (!strcmp(operation, "--make-dirs")) |
paul@226 | 500 | { |
paul@226 | 501 | exitcode = make_dirs(fs, argc - 3, &argv[3]); |
paul@226 | 502 | } |
paul@226 | 503 | else |
paul@226 | 504 | { |
paul@226 | 505 | printf("Operation %s is not recognised.\n", operation); |
paul@226 | 506 | exitcode = 1; |
paul@226 | 507 | } |
paul@226 | 508 | |
paul@226 | 509 | /* Close the filesystem image. */ |
paul@226 | 510 | |
paul@226 | 511 | retval = ext2fs_flush(fs); |
paul@226 | 512 | if (retval) |
paul@226 | 513 | { |
paul@226 | 514 | printf("Error flushing filesystem in %s\n", fsname); |
paul@226 | 515 | exitcode = 1; |
paul@226 | 516 | } |
paul@226 | 517 | |
paul@226 | 518 | retval = ext2fs_close(fs); |
paul@226 | 519 | if (retval) |
paul@226 | 520 | { |
paul@226 | 521 | printf("Error closing filesystem in %s\n", fsname); |
paul@226 | 522 | exitcode = 1; |
paul@226 | 523 | } |
paul@226 | 524 | |
paul@226 | 525 | ext2fs_free(fs); |
paul@226 | 526 | return exitcode; |
paul@226 | 527 | } |