Skip to content

Add SMB2 and CIFS detection and decide when to use server-side copy #31

@antirotor

Description

@antirotor

Use statfs on linux (and something similar on windows?) to get the information about filesystem and enable server-side copy when available.

libc = ctypes.CDLL(ctypes.util.find_library("c"), use_errno=True)


class statfs_t(ctypes.Structure):
    """statfs(2) result structure (simplified; enough for f_type)."""
    _fields_ = [
        ("f_type",    ctypes.c_long),
        ("f_bsize",   ctypes.c_long),
        ("f_blocks",  ctypes.c_long),
        ("f_bfree",   ctypes.c_long),
        ("f_bavail",  ctypes.c_long),
        ("f_files",   ctypes.c_long),
        ("f_ffree",   ctypes.c_long),
        ("f_fsid",    ctypes.c_int * 2),
        ("f_namelen", ctypes.c_long),
        ("padding",   ctypes.c_char * 1024),
    ]

_FS_TYPES = {
    0xFF534D42: "CIFS",
    0xFE534D42: "SMB2",
    0xEF53: "EXT2/3/4",
    0x6969: "NFS",
    0x01021994: "TMPFS",
    0x58465342: "XFS",
}

Maybe find a way to cache the results?

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions