public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* Determining if writing to a jffs2 partition will fail
@ 2003-12-20 14:34 Jonas Holmberg
  0 siblings, 0 replies; only message in thread
From: Jonas Holmberg @ 2003-12-20 14:34 UTC (permalink / raw)
  To: linux-mtd

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-12-20 14:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-20 14:34 Determining if writing to a jffs2 partition will fail Jonas Holmberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox