From 76d773709c5f9a37191ceb08bda8075762c94c78 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 11 Dec 2002 21:00:55 +0000 Subject: add mknod stub --- command-stubs/Makefile | 2 +- command-stubs/mknod-stub | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100755 command-stubs/mknod-stub diff --git a/command-stubs/Makefile b/command-stubs/Makefile index 64ff41062..e68983bba 100644 --- a/command-stubs/Makefile +++ b/command-stubs/Makefile @@ -1,7 +1,7 @@ include ../Makefile.inc STUBS = raidstart-stub raidstop-stub kudzu-probe-stub list-harddrives-stub \ - loadkeys-stub losetup-stub pump-stub + loadkeys-stub losetup-stub pump-stub mknod-stub all: @echo "Nothing to do" diff --git a/command-stubs/mknod-stub b/command-stubs/mknod-stub new file mode 100755 index 000000000..ff9f5312d --- /dev/null +++ b/command-stubs/mknod-stub @@ -0,0 +1,50 @@ +#!/usr/bin/python + +import sys +import isys +import string +import stat + +def usage(): + sys.stderr.write("Usage: %s [b|c] or\n" %(sys.argv[0],)) + sys.stderr.write("Usage: %s \n" %(sys.argv[0],)) + sys.exit(1) + +def main(): + if len(sys.argv) < 2: + usage() + + if (sys.argv[1] == '-h') or (sys.argv[1] == '--help'): + usage() + + path = sys.argv[1] + if (len(sys.argv) == 2): + drive = path + # strip off any path elements up until what's useful for making the + # inode + while (drive.find('/') != -1): + if (drive.startswith("cciss") or drive.startswith("ida") or + drive.startswith("rd") or drive.startswith("ataraid")): + break + drive = drive[drive.find('/') + 1:] + isys.makeDevInode(drive, path) + sys.exit(0) + + if len(sys.argv) < 5: + usage() + + if (sys.argv[2] == 'b'): + type = stat.S_IFBLK + elif (sys.argv[2] == 'c'): + type = stat.S_IFCHR + else: + usage() + + major = int(sys.argv[3]) + minor = int(sys.argv[4]) + path = sys.argv[1] + + isys.mknod(path, 0644 | type, isys.makedev(major, minor)) + +if __name__ == "__main__": + main() -- cgit