Documentation
¶
Overview ¶
cryptctl - Copyright (c) 2017 SUSE Linux GmbH, Germany This source code is licensed under GPL version 3 that can be found in LICENSE file.
cryptctl - Copyright (c) 2017 SUSE Linux GmbH, Germany This source code is licensed under GPL version 3 that can be found in LICENSE file.
cryptctl - Copyright (c) 2017 SUSE Linux GmbH, Germany This source code is licensed under GPL version 3 that can be found in LICENSE file.
cryptctl - Copyright (c) 2017 SUSE Linux GmbH, Germany This source code is licensed under GPL version 3 that can be found in LICENSE file.
Index ¶
- Constants
- func CheckBlockDevice(filePath string) error
- func CryptClose(name string) error
- func CryptErase(blockDev string) error
- func CryptFormat(key []byte, blockDev, uuid string) error
- func CryptOpen(key []byte, blockDev, name string) error
- func FileContains(paths, substr string) error
- func FileSpaceUsage(paths string) (totalSize int64, err error)
- func Format(blockDev, fsType string) error
- func FreeSpace(paths string) (int64, error)
- func GetSystemdMountNameForDir(dirPath string) string
- func IsDir(paths string) error
- func MirrorFiles(srcDir, destDir string, progressOut io.Writer) error
- func Mount(blockDev, fsType string, fsOptions []string, mountPoint string) error
- func SecureErase(filePath string, delete bool) error
- func Umount(mountPoint string) error
- type BlockDevice
- type BlockDevices
- type CryptMapping
- type MountPoint
- type MountPoints
Constants ¶
const ( BIN_CRYPTSETUP = "/sbin/cryptsetup" LUKS_CIPHER = "aes-xts-plain64:PBKDF2-sha512" LUKS_HASH = "sha512" LUKS_KEY_SIZE_S = "512" LUKS_KEY_SIZE_I = 512 )
const ( BIN_RSYNC = "/usr/bin/rsync" ERASE_NUM_PASS = 10 ERASE_BLOCK_SIZE = 128 * 1024 )
const ( BIN_MKFS = "/usr/sbin/mkfs" BIN_LSBLK = "/usr/bin/lsblk" BIN_MOUNT = "/usr/bin/mount" BIN_UMOUNT = "/usr/bin/umount" )
Variables ¶
This section is empty.
Functions ¶
func CheckBlockDevice ¶
Return nil if the file specified is a block device. Return an error otherwise.
func CryptClose ¶
Call cryptsetup luksClose on the mapped device node.
func CryptErase ¶
Call cryptsetup erase on the block device node.
func CryptFormat ¶
Call cryptsetup luksFormat on the block device node.
func FileContains ¶
Test whether file at the specified path can be read and contains the string. Case is sensitive.
func FileSpaceUsage ¶
Count the total space usage of the specified path; the path can be either a file or a directory.
func GetSystemdMountNameForDir ¶
GetSystemdMountNameForDir returns systemd's mount unit associated with the directory, supposedly a mount point.
func MirrorFiles ¶
Call rsync to recursively copy all files under source directory, including all file attributes/links, to the destination directory. If supplied, rsync progress output will be copied to the output stream. If some files already exist in the destination and the source files are newer, they will be overwritten. Both source directory and destination directory must be absolute.
func Mount ¶
Call mount to mount a file system. The mounted file system will be exposed to all processes on the computer.
func SecureErase ¶
Securely erase a file by overwriting it 10 times with random data, then delete the file. Needless to say this function is painfully slow. It relies on a vital assumption that the file system will overwrite data in place, bear in mind that many modern file systems and hardware designs do not satisfy the assumption, here are some examples: - Metadata/data journal. - Data compression. - Transient or persistent cache. - Additional redundancy mechanisms such as RAID.
Types ¶
type BlockDevice ¶
type BlockDevice struct { UUID string Name string // Name is the device node name Path string // full path to the device node under /dev including the prefix Type string // device type can be: partition, disk, encrypted, etc.. FileSystem string MountPoint string SizeByte int64 PKName string // PKName is the underlying block device's node name of a crypt block device }
Represent a block device currently detected on the system.
func GetBlockDevice ¶
func GetBlockDevice(node string) (blkDev BlockDevice, found bool)
Return information about the specific block device. The path of block device in return value will match the input device node path.
func (BlockDevice) IsLUKSEncrypted ¶
func (blkDev BlockDevice) IsLUKSEncrypted() bool
Return true if the block device is LUKS encrypted.
type BlockDevices ¶
type BlockDevices []BlockDevice
A list of block devices.
func GetBlockDevices ¶
func GetBlockDevices() BlockDevices
Return all block devices currently detected on the system.
func ParseBlockDevs ¶
func ParseBlockDevs(txt string) BlockDevices
Return all block devices defined in the input text. The input text is presumed to be obtained from the following command's output:
lsblk -P -b -o UUID,KNAME,TYPE,FSTYPE,MOUNTPOINT,SIZE
func (BlockDevices) GetByCriteria ¶
func (blkDevs BlockDevices) GetByCriteria(uuid, devPath, devType, fileSystem, mountPoint, pkName, name string) (BlockDevice, bool)
Find the first block device that satisfies the given criteria. If a criteria is empty, it is ignored.
type CryptMapping ¶
Represent a cryptsetup mapping currently effective on the system.
func CryptStatus ¶
func CryptStatus(name string) (mapping CryptMapping, err error)
Get luks device status. An error will be returned if the mapping status cannot be retrieved.
func ParseCryptStatus ¶
func ParseCryptStatus(txt string) (mapping CryptMapping)
Return cryptsetup status (a device mapper device) parsed from the text.
func (CryptMapping) IsValid ¶
func (mapping CryptMapping) IsValid() bool
Return true only if all fields (except Loop) are assigned.
type MountPoint ¶
type MountPoint struct { DeviceNode string MountPoint string FileSystem string Options []string Dump int Fsck int }
Represent a mount point entry in /etc/mtab.
func (*MountPoint) DiscardBtrfsSubvolume ¶
func (mount *MountPoint) DiscardBtrfsSubvolume()
Remove btrfs subvolume among mount options. The MountPoint is modified in-place.
func (MountPoint) Equals ¶
func (mount1 MountPoint) Equals(mount2 MountPoint) bool
Return true only if two mount points are identical in all attributes.
func (MountPoint) GetFileSystemSizeByte ¶
func (mount MountPoint) GetFileSystemSizeByte() (int64, error)
Return the total size of the file system in Bytes.
type MountPoints ¶
type MountPoints []MountPoint
A list of mount points.
func ParseMountPoints ¶
func ParseMountPoints(txt string) (mounts MountPoints)
Return all mount points defined in the input text except rootfs. Panic on malformed entry.
func ParseMtab ¶
func ParseMtab() MountPoints
Return all mount points that appear in /etc/mtab. Panic on error.
func (MountPoints) GetByCriteria ¶
func (mounts MountPoints) GetByCriteria(deviceNode, mountPoint, fileSystem string) (MountPoint, bool)
Find the first mount point that satisfies the given criteria. If a criteria is empty, it is ignored.
func (MountPoints) GetManyByCriteria ¶
func (mounts MountPoints) GetManyByCriteria(deviceNode, mountPoint, fileSystem string) (ret MountPoints)
Find the all mount points that satisfy the given criteria. If a criteria is empty, it is ignored.
func (MountPoints) GetMountPointOfPath ¶
func (mounts MountPoints) GetMountPointOfPath(fileOrDirPath string) (MountPoint, bool)
Find mount point for an arbitrary directory or file specified by an absolute path.