Skip to main content

Module to expose posix_fallocate(3), posix_fadvise(3) and fallocate(2)

Project description

https://travis-ci.org/trbs/fallocate.svg?branch=master:target:https://travis-ci.org/trbs/fallocate

fallocate exposes an interface to fallocate(2), posix_fallocate(3) and posix_fadvise(3).

Under Mac OS X the fallocate() method will use the apple equivalent of fallocate(2). Note that this might not be exactly the same.

When using the wrapper functions around the fallocate(2) call the arguments given to the function are slightly different then the c call.

This module has the arguments like:

fallocate(fd, offset, length, mode=0)

While in C the function looks like:

fallocate(fd, mode, offset, length)

The main reason for this is that the mode argument tends not to be used much and thus having the default as a keyword argument is much easier then having to specify 0 everytime.

Usage

Funcation: fallocate(fd, offset, len, [mode=0])

Calls fallocate() on the file object or file descriptor. This allows the caller to directly manipulate the allocated disk space for the file referred to by fd for the byte range starting at offset and continuing for len bytes.

mode is only available in Linux.

It should always be 0 unless one of the two following possible flags are specified

FALLOC_FL_KEEP_SIZE  - do not grow file, default is extend size
FALLOC_FL_PUNCH_HOLE - punches a hole in file, de-allocates range

Example:

# preallocate using fallocate a 1kb file
with open("/tmp/test.file", "w+b") as f:
    fallocate(f, 0, 1024)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fallocate-1.5.0.tar.gz (10.0 kB view details)

Uploaded Source

File details

Details for the file fallocate-1.5.0.tar.gz.

File metadata

  • Download URL: fallocate-1.5.0.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for fallocate-1.5.0.tar.gz
Algorithm Hash digest
SHA256 3b0abae33f704bad8a07d70255b95d9c89a92098c3b0c5e0578ccf4753b7efa9
MD5 b3caf783a03708e31874468d65c2d958
BLAKE2b-256 775337338e0fc7a766e619380db3cdc55f62a5fe81684f2d0ffcc3f67a4d5b87

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page