main.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:rbd2qcow2 作者: socketpair 项目源码 文件源码
def do_fallocate(filename: str, size: int):
    log.debug('Fallocating %s for size %d.', filename, size)
    fd = os.open(filename, os.O_RDWR)
    try:
        # os.posix_fallocate:
        # 1. does not support FALLOC_FL_KEEP_SIZE
        # 2. has bug: http://bugs.python.org/issue31106
        # 3. will emulate instead of raising of error if operation is not
        #    supported (see libc docs on posix_fallocate)
        fallocate(fd, FALLOC_FL_KEEP_SIZE, 0, size)
    except OSError as err:
        if err.errno != errno.EOPNOTSUPP:
            raise
        log.warning('Fallocate is not supported on your FS. Skipped.')
    finally:
        os.close(fd)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号