[prev in list] [next in list] [prev in thread] [next in thread]
List: coreutils
Subject: Re: RFC: new cp option: --efficient-sparse=HOW
From: Pádraig_Brady <P () draigBrady ! com>
Date: 2011-02-04 11:08:20
Message-ID: 4D4BDE24.8020504 () draigBrady ! com
[Download RAW message or body]
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)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic