Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #23197

Re: image as an FS: HOWTO?

From Nobody <nobody@nowhere.com>
Subject Re: image as an FS: HOWTO?
Date 2012-07-08 03:42 +0100
Message-Id <pan.2012.07.08.02.42.19.833000@nowhere.com>
Newsgroups comp.lang.c
References <86629z971t.fsf@gray.siamics.net>
Organization Zen Internet

Show all headers | View raw


On Sat, 07 Jul 2012 17:53:02 +0700, Ivan Shmakov wrote:

> 	Then, the immutable data file could be pretty much any kind of
> 	an archive, as long as it supports quick name-to-file lookup (so
> 	Tar won't fit, but ISO-9660 or even Zip probably will.)
> 
> 	Do I understand it correctly that for such a scheme to work, I
> 	need to "shadow" all the common filesystem functions, either
> 	stream-based, such as fopen (), or filehandle-based, such as
> 	open (), to access the "image" instead (should the filename in
> 	question begin with a specific prefix)?

For Linux or BSD, you can use (respectively) fopencookie or funopen to
create user-defined streams which will work with anything that uses stdio
(i.e. you can pass the resulting FILE* to library functions which know
nothing of your implementation). Unfortunately, I don't know of anything
similar for Windows.

You can't reliably implement descriptor-based I/O, as that involves the
kernel (e.g. inheritance of descriptors by child processes).

> 	I guess that I won't be able to run a binary contained within
> 	such an "image" on the common systems of today?

Maybe. On Unix, you can get a close approximation to execve() simply by
making the correct mmap/munmap calls, assuming that you don't need to
support setuid/setgid binaries. However, this requires that the files
within the archive are aligned to page boundaries.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

image as an FS: HOWTO? Ivan Shmakov <oneingray@gmail.com> - 2012-07-07 17:53 +0700
  Re: image as an FS: HOWTO? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-07-07 04:34 -0700
  Re: image as an FS: HOWTO? Nobody <nobody@nowhere.com> - 2012-07-08 03:42 +0100
  Re: image as an FS: HOWTO? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-07-10 21:20 +0000

csiph-web