diff options
Diffstat (limited to 'command-stubs/losetup-stub')
-rwxr-xr-x | command-stubs/losetup-stub | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/command-stubs/losetup-stub b/command-stubs/losetup-stub new file mode 100755 index 000000000..fed047d97 --- /dev/null +++ b/command-stubs/losetup-stub @@ -0,0 +1,40 @@ +#!/usr/bin/python + +import os +import sys + +# for testing +if (os.path.exists('isys')): + sys.path.append('isys') + +sys.path.append('/usr/lib/anaconda') + +import isys +from sys import argv + +def usage(): + print "usage: losetup [-d] /dev/loopN [image]" + sys.exit(1) + +if len(argv) < 3: + usage() + +if argv[1] == "-d" and len(argv[2] > 4) and argv[2][-5:-1] == "loop": + try: + isys.makeDevInode(argv[2][-5:], argv[2]) + isys.unlosetup(argv[2]) + except SystemError, (errno, msg): + print msg + sys.exit (1) + sys.exit(0) + +if len(argv[1] > 4) and argv[1][-5:-1] == "loop": + try: + isys.makeDevInode(argv[1][-5:], argv[1]) + isys.losetup(argv[1], argv[2]) + except SystemError, (errno, msg): + print msg + sys.exit (1) + sys.exit(0) + +usage() |