summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1c18b9e)
Will be used to force readdir in several getdents calls.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
static uint64_t d_off_history[HISTORY_LEN];
static uint64_t d_ino_history[HISTORY_LEN];
static uint64_t d_off_history[HISTORY_LEN];
static uint64_t d_ino_history[HISTORY_LEN];
-int
-main(int argc, char *argv[])
+ fprintf(stderr, "usage: t_dir_offset2: <dir> [bufsize]\n");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char *argv[])
+{
+ int fd;
+ int nread, bufsize = BUF_SIZE;
struct linux_dirent64 *d;
int bpos, total, i;
off_t lret;
int retval = EXIT_SUCCESS;
struct linux_dirent64 *d;
int bpos, total, i;
off_t lret;
int retval = EXIT_SUCCESS;
+ if (argc > 2) {
+ bufsize = atoi(argv[2]);
+ if (!bufsize)
+ usage();
+ if (bufsize > BUF_SIZE)
+ bufsize = BUF_SIZE;
+ } else if (argc < 2) {
+ usage();
+ }
+
fd = open(argv[1], O_RDONLY | O_DIRECTORY);
if (fd < 0) {
perror("open");
fd = open(argv[1], O_RDONLY | O_DIRECTORY);
if (fd < 0) {
perror("open");
- nread = syscall(SYS_getdents64, fd, buf, BUF_SIZE);
+ nread = syscall(SYS_getdents64, fd, buf, bufsize);
if (nread == -1) {
perror("getdents");
exit(EXIT_FAILURE);
if (nread == -1) {
perror("getdents");
exit(EXIT_FAILURE);
- nread = syscall(SYS_getdents64, fd, buf, BUF_SIZE);
+ nread = syscall(SYS_getdents64, fd, buf, bufsize);
if (nread == -1) {
perror("getdents");
exit(EXIT_FAILURE);
if (nread == -1) {
perror("getdents");
exit(EXIT_FAILURE);