aboutsummaryrefslogtreecommitdiffstats
path: root/fusearchive.py
blob: f18c7c76924cd59139e38d1b9ecdfc5705ab0b8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python

#    Copyright (C) 2001  Jeff Epler  <jepler@unpythonic.dhs.org>
#    Copyright (C) 2006  Csaba Henk  <csaba.henk@creo.hu>
#    Copyright (C) 2009  Steve Slaven  <bpk@hoopajoo.net>
#
#    This program can be distributed under the terms of the GNU LGPL.
#    See the file COPYING.
#

import logging, sys, os, fuse
import FuseArchive

log_level = logging.DEBUG
#log_level = logging.WARNING

logging.basicConfig( level = log_level,
                     format = '%(asctime)s %(levelname)s %(filename)s:%(lineno)d %(module)s:%(funcName)s() %(message)s',
                     stream = sys.stderr,
                     filemode = 'w' )

enable_stats = False
enable_psyco = False

if enable_psyco:
    # Import Psyco if available
    try:
        import psyco
        psyco.full()
    except ImportError:
        pass

if enable_stats:
    import hotshot
    prof = hotshot.Profile( "fusearchive_stats" )
    prof.runcall()
    prof.close()

usage = """
Userspace nullfs-alike: mirror the filesystem tree from some point on.

""" + fuse.Fuse.fusage

server = FuseArchive.FileSystem(version="%prog " + fuse.__version__,
                usage=usage,
                dash_s_do='setsingle')

server.multithreaded = False

server.parse(values=server, errex=1)

if len(server.parser.largs) != 2:
    print "Usage: " + sys.argv[0] + " storageDirectory mountDirectory"
    sys.exit(1)

server.root = server.parser.largs[0]

try:
    if server.fuse_args.mount_expected():
        os.chdir(server.root)
except OSError:
    print >> sys.stderr, "can't enter root of underlying filesystem"
    sys.exit(1)

server.main()