0

I'm searching for any kernel-level mechanism that is pass-through and will change file hashes by either encrypting file contents or appending data. The most obvious solution is encryption, but I can't find any appropriate (e.g. fully kernel-only, no ecryptfs, nothing FUSE powered, etc) encryption methods.

Specifically, I have a large number of files in /foo that I would like to also appear in /foobar in any manner that obfuscates the original MD5 of the files, without duplicating the raw data. I'm not concerned if the files in /foobar are rendered useless by additions--I'm happy to append a few random bytes to each file and let that break many of file formats, but I don't know how to do this with some sort of bind mount

1 Answer 1

1

If you are looking for a custom filesystem overlay, FUSE is the right direction. There are various custom filesystems written using FUSE (sshfs, ntfs-3g, wikipediafs...), including simple overlays like bindfs.

One could take the bindfs source code and modify it to, say, XOR the first byte with some random data whenever it processes a read operation.

For a pure kernel option, you could modify overlayfs or unionfs drivers in a similar way.

Another alternative is to take Samba, write a Samba vfs module to corrupt files, share the source directory, and mount it on the same machine using the Linux cifs driver. (The same is also possible using the 9p driver and the u9fs daemon, or with the nfs driver and some-or-other NFS server daemon.)


If you don't care about the contents, create sparse files with the desired size; they'll occupy no space at all:

$ truncate -s 1G largefile
$ du -h --apparent largefile
1G  largefile
$ du -h largefile
0   largefile

Loop over a tree like this:

cd /foo
find -type d | while read -r file; do
    mkdir -p "/foobar/$file"
done
find -type f | while read -r file; do
    truncate -r "$file" "/foobar/$file"
done
7
  • I need a kernel-level mechanism, which rules out any use of FUSE :-/ Otherwise this would be great :-P
    – Hamy
    Sep 3, 2014 at 5:44
  • Oh, sparse files is a great idea, but I should clarify that I do care about the contents being preserved, I just want the hash different. I'll update my post, sorry for the confusion
    – Hamy
    Sep 3, 2014 at 5:45
  • @Hamy: Could you also explain why is a kernel-level mechanism required specifically, and what makes FUSE unusable? Sep 3, 2014 at 5:45
  • Sure - kernel-only is a requirement of CrashPlan - It apparently cannot properly stat files (such as encrypted files) unless the modifications are done in the kernel and are therefore totally invisible to it. The kernel-only requirement removes the ability to use FUSE entirely because (AFAIK) every single FUSE-based filesystem is executed in userspace while fuse itself is the part run in the kernel
    – Hamy
    Sep 3, 2014 at 5:50
  • FYI, I have not tried a FUSE-based system yet, but I see hopeful reports that sshfs can indeed be used with crashplan at askubuntu.com/questions/337305/…, so I am giving it a shot right now. Perhaps the answer has been obvious all along...*fingers crossed*
    – Hamy
    Sep 3, 2014 at 5:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .