Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7538587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:09:30+00:00 2026-05-30T07:09:30+00:00

I am trying to fallocate a tempfile, but unfortunately the following code returns -1

  • 0

I am trying to fallocate a tempfile, but unfortunately the following code returns -1 (failure):

import ctypes, tempfile
from ctypes import *

t_file=tempfile.NamedTemporaryFile(delete=True, dir=".", prefix="temp_file_")

libc=cdll.LoadLibrary("libc.so.6")
libc.fallocate(t_file.fileno(), c_int(0), c_longlong(0), c_longlong(102400))

However, I can do fine with the following from command line

hdparm --fallocate 10 ./temp_file_foo

which should do the same. If it matters, this is done on an ext4 filesystem.

A separate question I have is whether libc.fallocate writes zeros to the disk, or does it mark the blocks as uninitialized?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:09:32+00:00Added an answer on May 30, 2026 at 7:09 am

    Sounds like you’re on a 32-bit system, where the fallocate system call takes a (32-bit) integer by default. Some systems will also have a 64-bit counterpart in fallocate64, which takes a 64-bit offset and length. Try that instead.

    Note that native 64-bit systems only have fallocate, but it takes 64-bit arguments.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to implement the following structure from c to use NSArray in objective-c: In
Trying to make a MySQL-based application support MS SQL, I ran into the following
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation
I am trying to allocate memory using sun.misc.Unsafe.allocateMemory() and access it in native code.
Let's say i'm trying to allocate 100 bytes, but since I don't have 100
Possible Duplicate: invalid conversion from void*' to char*' when using malloc? I'm trying to
I'm trying to allocate memory for a array of structures, but after it is
I'm trying to allocate and initialize an array inside a function, but I can't
Getting the following error, which I understand and have seen before. But one thing
i am trying to allocate shared memory by using a constant parameter but getting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.