home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.linux
- Path: sparky!uunet!mcsun!Germany.EU.net!news.netmbx.de!zrz.tu-berlin.de!math.fu-berlin.de!Sirius.dfn.de!chx400!bernina!almesber
- From: almesber@nessie.cs.id.ethz.ch (Werner Almesberger)
- Subject: Re: Can I use dd on my UNIX system instead of Rawrite?
- Message-ID: <1992Aug13.122323.13523@bernina.ethz.ch>
- Sender: news@bernina.ethz.ch (USENET News System)
- Organization: Swiss Federal Institute of Technology (ETH), Zurich, CH
- References: <1992Aug12.060338.24805@ennews.eas.asu.edu> <1992Aug12.063534.4178@muddcs.claremont.edu> <1992Aug13.003041.28918@mits.mdata.fi>
- Date: Thu, 13 Aug 1992 12:23:23 GMT
- Lines: 69
-
- In article <1992Aug13.003041.28918@mits.mdata.fi> kennu@mits.mdata.fi (Kenneth Falck) writes:
- > How exactly does that lseek() writing work?
-
- You lseek to some place beyond the current end of the file and write some
- data, e.g.
-
-
- +----------+--------------------------------------+----------+
- | Old data | | New data |
- +----------+--------------------------------------+----------+
- ^ ^ ^
- old EOF lseek new
- here EOF
-
- Because the file is physically stored as a sequence of blocks,
- those blocks that have been skipped don't have to be mapped:
-
- +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
- | | | | - | - | - | - | - | - | - | - | - | | | | |
- +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
-
- By convention, reading an unmapped block returns a bunch of
- zero bytes.
-
- > If you lseek() past
- > the end of file, do some I/O routines automatically append the
- > corresponding amount of nulls or what?
-
- No, they just don't allocate blocks. (*)
-
- > And why doesn't this work with shoelace then...
-
- Because Shoelace seems to ignore this concept and loads garbage
- where it should load zeroes.
-
- > (Btw, is this optimization possible only for the unix/minix/linux
- > filesystems, or is it fs-independant and can be used on MSDOS too?)
-
- This works on UNIX-like systems, on CP/M, and several other systems
- (don't know about VMS - it proabably has it too) but it can't be used
- on an MS-DOS FS (*), because MS-DOS uses a chain of blocks instead of
- maps:
-
- UNIX Data MS-DOS FAT Data
- blocks blocks
-
- inode +---+ dir ent. +---+ +---+
- +----+ +---->| | +----+ +--->| |-+ -----> | |
- | | | +---+ | | | +---+ | +---+
- | B1 |------+ +---+ | | | |
- | B2 |----------->| | |strt|--+ +-------+
- | B3 |-----+ +---+ | | |
- | B4 |... | +---+ +----+ | +---+ +---+
- | B5 | +----->| | +->| |--... --> | |
- | | +---+ +---+ +---+
- +----+
-
- These pictures are greatly simplified.
-
- (*) The MS-DOS FS in Linux automatically fills any "holes" with zero
- blocks. Therefore, the file contents are correct, but you don't
- save any disk space.
-
- - Werner
- --
- _________________________________________________________________________
- / Werner Almesberger, ETH Zuerich, CH almesber@nessie.cs.id.ethz.ch /
- / IFW A44 Tel. +41 1 254 7213 almesberger@rzvax.ethz.ch /
- /_BITNET:_ALMESBER@CZHETH5A__HEPNET/CHADNET:_[20579::]57414::ALMESBERGER_/
-