• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: fcntl(fd,F_SETSIZE,?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fcntl(fd,F_SETSIZE,?)


  • Subject: Re: fcntl(fd,F_SETSIZE,?)
  • From: James Bucanek <email@hidden>
  • Date: Fri, 12 Oct 2012 09:49:32 -0700

Shantonu Sen <mailto:email@hidden> wrote (Friday, October 12, 2012 12:28 AM -0700):

fcntl(F_SETSIZE) is not designed for this purpose. Among other things, it can cause you to expose sensitive data if your program crashes and later someone else opens the file (and sees the disk blocks that weren't zero-ed out).

I understand the reason why the zeros are written, and when I skirt around security for convenience/performance I usually offer it as a user configurable option.

It also requires privileges.

For this task, my process is almost always running as root.

It sounds like what you want is fcntl(F_PREALLOCATE). Even then, it's unclear to me why you are seeing minute-long zero filling. HFS+ is optimized to not incur this zero-fill while you have the file open. Are you calling ftruncate(2) and then closing the file and then opening it again before writing it? Are you not using HFS+? Each filesystem implements (or doesn't) these fcntls differently.

This wasn't, specifically, for HFS+. This was an experiment to find an alternative to pre-allocation, since the pre-allocation on some filesystems (AFS specifically) is broken.

I have one step, which is preformed regularly, where my program creates several sizable files with the intent of filling them with recovery information if something goes wrong. I don't to wait until the problem occurs to create the files, because their might not be enough disk space available to create the recovery files. On AFS particularly, if you open a file and set its EOF (in Carbon) it stops to write zeros before returning. Over a slow network, like WiFi, this is a huge waste of time and bandwidth. And since pre-allocation on AFS is also broken, I was looking for a general purpose alternative that would work on all/most filesystems.

James
--
James Bucanek


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: fcntl(fd,F_SETSIZE,?)
      • From: Ken Hornstein <email@hidden>
References: 
 >Re: fcntl(fd,F_SETSIZE,?) (From: Shantonu Sen <email@hidden>)

  • Prev by Date: Re: fcntl(fd,F_SETSIZE,?)
  • Next by Date: Re: fcntl(fd,F_SETSIZE,?)
  • Previous by thread: Re: fcntl(fd,F_SETSIZE,?)
  • Next by thread: Re: fcntl(fd,F_SETSIZE,?)
  • Index(es):
    • Date
    • Thread