summaryrefslogtreecommitdiffstats
path: root/losetup-stub
blob: e96f684ea17fe104fabfad7e973da651f36528df (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
#!/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()