Skip to content

Commit

Permalink
Enhanced mkvdisk
Browse files Browse the repository at this point in the history
new -m option instructs mkvdisk to create a fixed (=static, non-dynamic) VHD, VHDX or VDI image
  • Loading branch information
maxpat78 committed Apr 19, 2023
1 parent e15c93a commit a49f9e5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ $RECYCLE.BIN/
# =========================
# Operating System Files
# =========================
BUGS.TXT
7 changes: 6 additions & 1 deletion FATtools/scripts/mkvdisk.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def create_parser(parser_create_fn=argparse.ArgumentParser,parser_create_args=No
par.add_argument('image_file',help="The image file or disk device to write to",metavar="IMAGE_FILE")
par.add_argument("-s", "--size", dest="image_size", help="specify virtual disk size. K, M, G or T suffixes accepted", metavar="SIZE",required=True)
par.add_argument("-b", "--base", dest="base_image", help="specify a virtual disk image base to create a differencing image with default parameters", metavar="BASE")
par.add_argument("-m", "--monolithic", dest="monolithic", help="immediately allocates all image sectors (except for VMDK)", action="store_true", default=False)
par.add_argument("-f", "--force", dest="force", help="overwrites a pre-existing image", action="store_true", default=False)
return par

Expand Down Expand Up @@ -60,7 +61,11 @@ def call(args):
else:
fmt = vmdkutils

fmt.mk_dynamic(args.image_file, fssize, overwrite='yes')
if not args.monolithic or fmt == vmdkutils:
fmt.mk_dynamic(args.image_file, fssize, overwrite='yes')
else:
fmt.mk_fixed(args.image_file, fssize, overwrite='yes')

print("Virtual disk image '%s' created."%args.image_file)

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion FATtools/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.0.9'
__version__ = '1.0.10'
5 changes: 4 additions & 1 deletion FATtools/vhdutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,11 @@ def mk_crc(s):
return struct.pack('>i', ~crc)


def mk_fixed(name, size):
def mk_fixed(name, size, overwrite='no'):
"Creates an empty fixed VHD or transforms a previous image if 'size' is -1"
if os.path.exists(name):
if size != -1 and overwrite!='yes':
raise BaseException("Can't silently overwrite a pre-existing VHD image!")
if os.path.exists(name):
f = myfile(name, 'r+b')
if size == -1:
Expand Down
9 changes: 4 additions & 5 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FATtools
========

Install using pip install .
Install from PyPI using `pip install FATtools` (easier) or downloading the source code (or the released packages) from here.

Born to re-sort directory entries in a FAT32 root table to cope with some hardware MP3 players' limits, it now provides full read/write support in Python 3 (both 32- and 64-bit) for FAT12/16/32 and exFAT filesystems, for hacking and recovering purposes.

Expand Down Expand Up @@ -39,9 +39,6 @@ Code is GPLed (look at GPL.TXT).



Sample usage (see inside 'samples' directory for more usage samples).


# At a glance

The package installs a `fattools` script, you can use this to perform simple command line operations.
Expand Down Expand Up @@ -86,7 +83,7 @@ part = Volume.vopen('MyDiskImage.img', 'r+b', 'partition0')
mkfat.exfat_mkfs(part, part.size)
```

- to order items inside directory tables easily, with GUI:
- to order items inside directory tables easily, with GUI and drag support:
```
fattools reordergui
```
Expand Down Expand Up @@ -171,3 +168,5 @@ for t in T:
o.sort()
vclose(o)
```

Please look inside 'samples' directory for more usage samples.

0 comments on commit a49f9e5

Please sign in to comment.