coreutils
[Top][All Lists]
Advanced

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

Re: RFC: new cp option: --efficient-sparse=HOW


From: Pádraig Brady
Subject: Re: RFC: new cp option: --efficient-sparse=HOW
Date: Fri, 04 Feb 2011 11:08:20 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3

On 03/02/11 20:29, Jim Meyering wrote:
> Does anyone know how to determine if a file system (say the one with ".")
> supports the FIEMAP ioctl, but without compiling/running a C program?
> I.e., via perl or python?  I've written a tiny C program that works
> and a Perl one that is supposed to be identical (at least the buffer
> arg has identical content), yet does not work.
> The goal is to make the tests more robust by replacing the kludgey
> FS-name-based test with an actual syscall-based test.

This python snippet seems to work.
A caveat with using '.' rather than a file,
is that ext3 returns "not supported" for directories.

cheers,
Pádraig.

import struct, fcntl, sys, os

def sizeof(t): return struct.calcsize(t)
IOCPARM_MASK = 0x7f
IOC_OUT = 0x40000000
IOC_IN = 0x80000000
IOC_INOUT = (IOC_IN|IOC_OUT)
def _IOWR(x,y,t): return (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y)
struct_fiemap = '=qqllll'
FS_IOC_FIEMAP = _IOWR (ord ('f'), 11, struct_fiemap)

buf = struct.pack (struct_fiemap, 0,~0,0,0,0,0)

try:
    fd = os.open (len (sys.argv) == 2 and sys.argv[1] or '.', os.O_RDONLY)
    fcntl.ioctl (fd, FS_IOC_FIEMAP, buf)
except:
    sys.exit (1)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]