Version: 1:0
parted: Racket Interface to GNU Parted Disk Partion Utility
1 Introduction
WARNING: THIS IS ALPHA-TESTING SOFTWARE. USE WITH CAUTION.
It is easy to lose all the data on a hard disk drive accidentally. This
package uses GNU Parted with the Racket sudo package, so literally one line of code can obliterate
either your doctoral dissertation, or received love-letters (nobody has both).
Don’t even think of suing the author. This package provides a Racket interface to the
GNU Parted disk-partitioning utilities. You must have GNU Parted installed,
for this package to function.
This package calls the command-line
parted program, sometimes using the poorly-documented
machine-parseable output interface. It does not use the FFI, nor otherwise add native code to the
Racket host process. It is developed with GNU Parted 2.3.
This package was originally written for the RackOut firmware
updater.
2 Interface
(parted-unit? x) → boolean?
|
x : any/c |
Predicate for whether x is a valid “unit” argument for certain procedures, and for
representing the units in structs. Currently this must be a symbol: 'byte or 'cylinder. CHS is not currently supported.
(struct | | parted-disk | ( | unit | | | | | path | | | | | end | | | | | transport | | | | | sector-size | | | | | physical-sector-size | | | | | type-name | | | | | model | | | | | cylinders | | | | | heads | | | | | sectors | | | | | cylinder-size | | | | | partitions) | | | #:extra-constructor-name make-parted-disk) |
|
unit : parted-unit? |
path : path? |
end : nonnegative-real? |
transport : string? |
sector-size : nonnegative-real? |
physical-sector-size : nonnegative-real? |
type-name : string? |
model : string? |
cylinders : (or/c #f nonnegative-integer?) |
heads : (or/c #f nonnegative-integer?) |
sectors : (or/c #f nonnegative-integer?) |
cylinder-size : (or/c #f nonnegative-integer?) |
partitions : (list-of parted-partition?) |
Struct representing a disk drive.
(struct | | parted-partition | ( | unit | | | | | number | | | | | start | | | | | end | | | | | size | | | | | filesystem | | | | | name | | | | | flags | | | | | type) | | | #:extra-constructor-name make-parted-partition) |
|
unit : parted-unit? |
number : nonnegative-integer? |
start : nonnegative-real? |
end : nonnegative-real? |
size : (or/c #f nonnegative-real?) |
filesystem : string? |
name : string? |
flags : string? |
type : string? |
Struct representing a partition of a disk drive.
(get-parted-disk | | #:disk disk-or-path | | | | | | [ | #:unit unit]) | | → | | parted-disk? |
|
disk-or-path : parted-disk-or-path? |
unit : parted-unit? = 'byte |
Yields a parted-disk struct for the disk given by disk-or-path. (A parted-disk struct may be given for disk-or-path to get updated information for the same disk.)
(parted-mklabel | | #:disk disk-or-path | | | | | | [ | #:label-type label-type]) | | → | | void? |
|
disk-or-path : parted-disk-or-path? |
label-type : string? = "msdos" |
Perform the GNU Parted mklabel operation.
(parted-mkpart | | #:disk disk-or-path | | | | | | [ | #:partition-type partition-type | | | | | | | #:filesystem-type filesystem-type | | | | | | | #:unit unit] | | | | | | | #:start start | | | | | | | #:end end) | | → | | void? |
|
disk-or-path : disk-or-path? |
partition-type : string? = #f |
filesystem-type : string? = #f |
unit : parted-unit? = 'byte |
start : nonnegative-integer? |
end : nonnegative-integer? |
Perform the GNU Parted mkpart operation.
(parted-partition/unit-byte? x) → boolean?
|
x : any/c |
Predicate for whether x is a parted-partition and uses “byte” units (as opposed to “cylinder”). It is equivalent to:
(and (parted-partition? X) |
(eq? 'byte (parted-partition-unit X))) |
(parted-mkpart/partition | | #:disk disk-or-path | | | | | | | #:partition partition) | | → | | void? |
|
disk-or-path : disk-or-path? |
partition : nonnegative-integer? |
Perform the GNU Parted mkpart operation, but using a parted-partition struct to specify the properties of the partition.
This is useful as part of a pattern of using get-parted-disk to save the current partition information for a disk, performing
some operation that results in the partition table being corrupted or lost, and
then restoring the partitions (restoring either all, or selectively).
(parted-mkpartfs | | #:disk disk-or-path | | | | | | | #:partition-type partition-type | | | | | | | #:filesystem-type filesystem-type | | | | | | [ | #:unit unit] | | | | | | | #:start start | | | | | | | #:end end) | | → | | void? |
|
disk-or-path : disk-or-path? |
partition-type : string? |
filesystem-type : string? |
unit : parted-unit? = 'byte |
start : nonnegative-integer? |
end : nonnegative-integer? |
Perform the GNU Parted mklabel operation.
Note that the GNU Parted 2.3 documentation discourages use of
this operation; separate filesystem-specific tools are usually better suited to
filesystem creation.
3 Known Issues
Logic of distinguishing msdos partition types with info given is not yet 100% clear.
May need CHS unit support.
Needs more testing with different devices and operations.
4 History
5 Legal
Copyright 2012 Neil Van Dyke. This program is Free Software; you
can redistribute it and/or modify it under the terms of the GNU Lesser General
Public License as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version. This program is
distributed in the hope that it will be useful, but without any warranty;
without even the implied warranty of merchantability or fitness for a
particular purpose. See http://www.gnu.org/licenses/ for details. For other
licenses and consulting, please contact the author.