Util: Replace mkblankimage.sh with the new gem5img.py.
Review Request #644 - Created April 17, 2011 and submitted
| Information | |
|---|---|
| Gabe Black | |
| gem5 | |
| Reviewers | |
| Default | |
| ali, gblack, nate, stever | |
Util: Replace mkblankimage.sh with the new gem5img.py. This change replaces the mkblankimage.sh script, used for creating new disk images, with a new gem5img.py script. The new version is written in python instead of bash, takes its parameters from command line arguments instead of prompting for them, and finds a free loopback device dynamically instead of hardcoding /dev/loop1. The file system used is now optionally configurable, and the blank image is filled by a "hole" left by lseek and write instead of literally filling it with zeroes. The functionality of the new script is broken into subcommands "init", "mount", "umount", "new", "partition", and "format". "init" creates a new file of the appropriate size, partitions it, and then formats the first (and only) new parition. "mount" attaches a new loopback device to the first parition of the image file and mounts it to the specified mount point. "umount" unmounts the specified mount point and identifies and cleans up the underlying loopback device. "new", "partition", and "format" are the individual stages of "init" but broken out so they can be run individually. That's so an image can be reinitialized in place if needed. Two features of the original script are being dropped. The first is the ability to specify a source directory to copy into the new file system. The second is the ability to specify a list of commands to run which are expected to (but not required to) update the permissions of the files in the new fs. Both of these seem easy enough to do manually, especially given the "mount" and "umount" commands, that removing them would meaningfully simplify the script without making it less useful.
Posted (April 18, 2011, 2:20 p.m.)
-
util/gem5img.py (Diff revision 1) -
This makes me feel uneasy for a script that you're likely to call using sudo. I know it's overly paranoid, but why not just simply give the user a tip if the program is not found (which you have to deal with anyway.)
-
util/gem5img.py (Diff revision 1) -
I'm not going to make you change it or anything, but this whole class seems to me to be a bit overkill, no? __notRoot = None def needSudo(): if __notRoot is None: __notRoot = os.geteuid() != 0 return __notRoot BTW: we also have m5.util.Singleton -
util/gem5img.py (Diff revision 1) -
This is pretty similar to m5.util.readCommand which made me think that it might be nice if we put your utility functions here in m5.util
-
util/gem5img.py (Diff revision 1) -
This is basically readCommand()
-
util/gem5img.py (Diff revision 1) -
Here is where you could suggest that it is in /sbin or /usr/sbin
Review request changed
Updated (April 23, 2011, 8:48 p.m.)
Diff: |
Revision 2 (+372 -219) |
|---|
Review request changed
Updated (April 24, 2011, 9:37 a.m.)
Diff: |
Revision 3 (+372 -219) |
|---|
