udisks

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2022 License: MIT Imports: 4 Imported by: 0

README

udisks

udisks gives you high level access to Linux system drives and block devices wrapping the udisk2 interfaces.

An example command line udisks client to list drives and block device properties can be installed with:

go install github.com/rubiojr/go-udisks/cmd/udisks@latest
package main

import (
	"encoding/json"
	"fmt"

	"os"

	"github.com/rubiojr/go-udisks"
)

func main() {
	client, err := udisks.NewClient()
	if err != nil {
		panic(err)
	}

	// List all block devices available to UDisks2
  devs, err := client.BlockDevices()
  if err != nil {
  	panic(err)
  }
  pretty(devs)
}

func pretty(dev interface{}) {
	prettyString, _ := json.MarshalIndent(dev, "", "  ")
	fmt.Println(string(prettyString))
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidDrive = errors.New("invalid drive")

Functions

This section is empty.

Types

type BlockDevice

type BlockDevice struct {
	UUID                string
	Device              string
	Id                  string
	Drive               *Drive
	Filesystems         []Filesystem
	CryptoBackingDevice *CryptoBackingDevice
	Path                string
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient() (*Client, error)

func (*Client) BlockDevices

func (c *Client) BlockDevices() ([]*BlockDevice, error)

BlockDevices returns the list of all block devices known to UDisks

func (*Client) Drives

func (c *Client) Drives() ([]*Drive, error)

Drives returns the list of all block devices known to UDisks

type CryptoBackingDevice

type CryptoBackingDevice struct {
	Path                string
	CleartextDevicePath string
	HintEncryptionType  string
	MetadataSize        uint64
}

type Drive

type Drive struct {
	Vendor         string
	Model          string
	Serial         string
	Id             string
	MediaRemovable bool
	Ejectable      bool
	MediaAvailable bool
	ConnectionBus  string
	SiblingId      string
	Seat           string
	Removable      bool
	Size           uint64
}

type Filesystem

type Filesystem struct {
	MountPoints []string
	Size        uint64
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL