xfs
[Top] [All Lists]

Re: [PATCH v2] xfsprogs/io: add readdir command

To: Mark Tinguely <tinguely@xxxxxxx>
Subject: Re: [PATCH v2] xfsprogs/io: add readdir command
From: Brian Foster <bfoster@xxxxxxxxxx>
Date: Thu, 08 Aug 2013 13:38:12 -0400
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <5203A5B7.4020102@xxxxxxx>
References: <1374669868-14075-1-git-send-email-bfoster@xxxxxxxxxx> <5203A5B7.4020102@xxxxxxx>
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7
On 08/08/2013 10:05 AM, Mark Tinguely wrote:
> On 07/24/13 07:44, Brian Foster wrote:
>> readdir reads the directory entries from an open directory from
>> the provided offset (or 0 if not specified). On completion,
>> readdir prints summary information regarding the number of
>> operations and bytes transferred. Options are available to specify
>> the starting offset, length and verbose mode to dump directory
>> entry information.
>>
>> Signed-off-by: Brian Foster<bfoster@xxxxxxxxxx>
>> ---
>>
>> v2:
>> - Convert from getdents to readdir.
>> - Use configure mechanism for libc readdir() availability (zab).
>> - Add extra dirent fields to verbose output (zab).
>>
> 
> Just started to look at this.
> 

Hi Mark,

Thanks for looking at this...

> Shouldn't there be a "closedir(dir);" to close the directory stream and
> release the directory structure?
> 

According to the man page, closedir() would also close the fd. I gave it
a quick test to be sure and I end up with behavior like this:

xfs_io> open /export/test
xfs_io> readdir
[00000000 [00000004 [00000006 [00000009 [00000200 read 104 bytes from
offset 0
104.000000 bytes, 4 ops, 0.0000 sec (5.220 MiB/sec and 210526.3158 ops/sec)
xfs_io> close
close: Bad file descriptor

That said, I'm not sure what the ramifications of repeated readdir
commands might be (i.e., repeated fdopendir() calls on the same fd).
Perhaps the right thing to do here is dup() file->fd prior to
fdopendir() and then add the closedir().

> Could we get a little info for the xfs_io man page?
> 

Ok.

Brian

> Looks like a nice feature.
> 
> Thanks.
> 
> --Mark.

<Prev in Thread] Current Thread [Next in Thread>