[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting file extensions [linux fs]

On 28Mar2019 01:12, Paulo da Silva <p_s_d_a_s_i_l_v_a_ns at> wrote:
>?s 23:09 de 27/03/19, Cameron Simpson escreveu:
>> On 27Mar2019 21:49, Paulo da Silva <p_s_d_a_s_i_l_v_a_ns at> wrote:
>> The filefrag manual entry says it works by calling one of 2 ioctls. You
>> can do that from Python with the ioctl() function in the standard fcntl
>> module. I haven't tried to do this, but the results should be basicly as
>> fast as filefrag itself.
>> You'll need to decode the result the ioctl returns of course.
>Thanks Cameron, I'll take a look at that.

Oh, just tangential to this.

If you were doing this ad hoc, yes calling the filefrag executable is 
very expensive. But if you are always doing a large batch of filenames 

  filefrag lots of filenames here ...

and reading from its output can be very effective, because the expense 
of the executable is amortized over all the files - the per file cost is 
much reduced. And it saves you working out how to use the ioctls from 
Python :-)

You'll learn more from going the ioctl route though, and it gives you 
complete control if you need it.

Cameron Simpson <cs at>