Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Given e.g. a gzipped textfile file.txt.gz, how to create a special file file.txt that on reading yields the (interactively) decompressed contents of the .gz file, and on writing a) re-gzips the new content or b) denies write-access?

share|improve this question
    
Is there something wrong with just using zcat? –  jordanm Jan 14 '13 at 16:42
    
@jordanm gzip was just an example, next time it could be tar or an entirely different program that (transparently) converts (one-way or two-way) between two data formats –  Tobias Kienzler Jan 14 '13 at 17:20
    
May I ask what you are trying to achieve by doing this, perhaps there's a simpler solution for your problem without the need of these special files. –  David Kohen Jan 14 '13 at 17:30
    
@DavidKohen In general? A transparent data conversion tool one output of which other programs can simply treat as files. I guess FUSE is the best choice here indeed –  Tobias Kienzler Jan 14 '13 at 17:46
    
That's what pipes are made for, though this may be an interesting FUSE file system. –  David Kohen Jan 15 '13 at 13:03
add comment

1 Answer

up vote 5 down vote accepted

Under Linux (or FreeBSD, NetBSD, MacOS X) FUSE comes to mind, it already features some Archive File Systems, that you should have a look at.

If the FUSE-mounted virtual file system just passes through non-archive-files, this could be what you want.

share|improve this answer
    
Yes, FUSE sounds like it can do it, though I wonder if one can mount to a file instead of a directory containing a dummy file (if the example's archive contains only compressed data) –  Tobias Kienzler Jan 14 '13 at 17:25
1  
If you are talking about a few files, you may be able to do something like this with softlinks (so it'll be files and not directories) and FUSE, of you are talking many (100+) I think you need to go elsewhere. –  David Kohen Jan 14 '13 at 17:28
1  
@DavidKohen Good point. It would only be a couple of files, so an alias that mounts to a mktemp directory and softlinking would suffice indeed –  Tobias Kienzler Jan 14 '13 at 17:33
1  
As it doesn't seem completely unrelated, I'd like to point out that some filesystems (among them Btrfs, Reiser4 and ZFS) support (per-filesystem) transparent compression –  sr_ Jan 15 '13 at 7:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.