1.1 --- a/libe2access/host/test_listing.c Wed Feb 16 01:25:39 2022 +0100
1.2 +++ b/libe2access/host/test_listing.c Wed Feb 16 17:55:47 2022 +0100
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Test filesystem listing concurrency limitations.
1.6 *
1.7 - * Copyright (C) 2019, 2021 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2019, 2021, 2022 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -32,6 +32,7 @@
1.13 #include "format.h"
1.14 #include "image.h"
1.15 #include "path.h"
1.16 +#include "utils.h"
1.17
1.18
1.19
1.20 @@ -40,33 +41,17 @@
1.21 static int image_list_dir_proc(struct ext2_dir_entry *dirent, int offset,
1.22 int blocksize, char *buf, void *priv_data)
1.23 {
1.24 - ext2_filsys fs = (ext2_filsys) priv_data;
1.25 + struct utils_list_dir_data *data = (struct utils_list_dir_data *) priv_data;
1.26 + ext2_filsys fs = (ext2_filsys) data->fs;
1.27 struct ext2_inode inode;
1.28 ext2_file_t file;
1.29 __u64 size;
1.30 char *to_remove[] = {"file0061", "file0062", "file0063", "file0125", "file0126", "file0127", 0};
1.31 char **f;
1.32
1.33 - /* Obtain the inode details for metadata. */
1.34 -
1.35 - if (ext2fs_read_inode(fs, dirent->inode, &inode))
1.36 - return DIRENT_ABORT;
1.37 -
1.38 - /* Output details in the style of "ls -l" showing directory, permissions,
1.39 - owner, group and size information. */
1.40 + /* Call the formatting utility function. */
1.41
1.42 - printf("%06d: %s%s %5d %5d %6d ",
1.43 - offset,
1.44 - _image_isdir(fs, dirent->inode) ? "d" : "-",
1.45 - get_permission_string(inode.i_mode),
1.46 - inode.i_uid,
1.47 - inode.i_gid,
1.48 - EXT2_I_SIZE(&inode));
1.49 -
1.50 - /* Output the name which is presumably not necessarily null-terminated. */
1.51 -
1.52 - fwrite(dirent->name, sizeof(char), ext2fs_dirent_name_len(dirent), stdout);
1.53 - fputc((int) '\n', stdout);
1.54 + utils_list_dir_proc(dirent, offset, blocksize, buf, priv_data);
1.55
1.56 /* Remove files at an awkward point in time. */
1.57
1.58 @@ -93,6 +78,7 @@
1.59 ext2_ino_t ino;
1.60 ext2_file_t file;
1.61 int i;
1.62 + struct utils_list_dir_data list_dir_data;
1.63
1.64 if (argc < 2)
1.65 {
1.66 @@ -145,8 +131,11 @@
1.67 ext2fs_file_close(file);
1.68 }
1.69
1.70 - image_list_dir(fs, "", image_list_dir_proc, fs);
1.71 - image_list_dir(fs, "", image_list_dir_proc, fs);
1.72 + list_dir_data.fs = fs;
1.73 + list_dir_data.filename = NULL;
1.74 +
1.75 + image_list_dir(fs, "", image_list_dir_proc, &list_dir_data);
1.76 + image_list_dir(fs, "", image_list_dir_proc, &list_dir_data);
1.77
1.78 /* Close the filesystem image. */
1.79