Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm looking for something that works like UnionFS in Windows 7. My usecase: having clean code working directory in a read-only directory, and compiling it in a union filesystem which would store compiled binaries logically in the same place, but physically in different directory.

Libraries do not work this way, even though they were accepted as an answer in http://superuser.com/questions/66857/unionfs-alike-on-windows-virtually-merge-folders -- they only show top-level directories in one place.

The code itself is huge (2GB of data), and I'd like to avoid copying it for every build in my build server.

share|improve this question
    
Oh, oops. :-/ I'm trying to solve the exact same problem myself, and did not read nearly carefully enough. I'll delete my comment. I have virtually no familiarity with the Windows platform. :-/ –  Omnifarious Feb 7 '12 at 13:04

3 Answers 3

Could you use symbolic links to fake this? http://en.wikipedia.org/wiki/NTFS_symbolic_link It's not answering the exact question but I think it will solve the use case you've given.

share|improve this answer
    
I don't see how could it... could you explain? –  liori Sep 7 '10 at 13:29
    
I don't know the way your build tree is structured but assuming it's something like src, src/bin, src/obj, then you can have bin and obj be symbolic links to wherever you want to the code to be. Just make sure your build isn't deleting those folders completely. Alternatively have src be the symbolic link to the "read only" then have the links in the read only go back. Either way you should be able to make it work. Unless i'm completely missing your scenario. –  MikeBaz Sep 7 '10 at 15:50
    
I don't control the build procedure, and it can write everywhere. –  liori Sep 7 '10 at 15:57
    
@liori: for this use case, you could reproduce the directories and create symbolic links for every file (something like cd SOURCE; find -type d -exec sh -c 'cd BUILDDIR && mkdir "$@"' _ {} +; find -type f -exec sh -c 'mklink "$1" "BUILDDIR/$1"' _ {} \; or some Windows equivalent). –  Gilles Sep 7 '10 at 19:03
    
@Gilles: you make me think copying isn't that bad solution... (besides, could you make it into an answer?) –  liori Sep 7 '10 at 20:31

You can make a poor-man's unionfs with symbolic links: reproduce the directory structure of the source, but make links (symbolic or hard) for the files. This should be suitable for your purpose as long as the build system doesn't try to modify source files.

With GNU cp, it's as easy as cp -al or cp -as. But I don't know if there is a port of GNU tools that understands Windows links.

If you need to call the mklink command, it can be done with POSIX tools (warning, typed directly into the browser):

cd SOURCE
find -type d -exec sh -c 'cd BUILDDIR && mkdir "$@"' _ {} +
find -type f -exec sh -c 'mklink "$1" "BUILDDIR/$1"' _ {} \;

I suppose there is a native Windows way involving Powershell, but I have no idea what it looks like. It might be worth investigating if your directory tree is large and your disks are fast because forking under Windows tends to be slow, and the commands above need to fork a lot.

share|improve this answer
    
The native way would be something like for /R %BUILDDIR% %F in (*.*) do @junction X:%pnxF %F, using the junction tool from sysinternals. –  MSalters Feb 7 '12 at 14:49

I found this, but I don't really know how well it works:

share|improve this answer

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.