public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Jonas Holmberg <jonas.holmberg@axis.com>
To: linux-mtd@lists.infradead.org
Subject: Determining if writing to a jffs2 partition will fail
Date: Sat, 20 Dec 2003 15:34:04 +0100	[thread overview]
Message-ID: <20031220143403.GA23544@axis.com> (raw)

Is there any reliable way to determine if a regular file can be 
written to a jffs2 partition without getting ENOSPC? I don't want to 
write the file to jffs2 and then find out that the fs was full, 
because other processes might fail to write to the fs during that 
test (if the fs gets full).

The best I have come up with is:

1. gzip the file (on tmpfs)
2. do statfs on jffs2 the get available space
3. test if the gzipped file would fit in jffs2 without making 
   available space go below one eraseblock (64KiB on my NOR flash).

If it succeeds I would be almost shure the gunzipped file could be 
written to jffs2 without getting ENOSPC, but gzip will of course not 
compress the file to exacly the same size as jffs2 will. And 
statfs won't always tell the truth. I could of course send SIGHUP 
to the gc-thread, wait some and try again.

This doesn't feel like a good solution though, does anyone know of any 
better way?

/Jonas

                 reply	other threads:[~2003-12-20 14:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031220143403.GA23544@axis.com \
    --to=jonas.holmberg@axis.com \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox