fsquota

package module
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 16 Imported by: 0

README

fsquota

license GoDoc Build Status Go Report Card

fsquota is a native Go library for interacting with (Linux) filesystem quotas. This library does not make use of cgo or invoke external commands, but rather interacts directly with the kernel interface by use of syscalls. This library was originally written by the Anexia R&D team. This repository has a few modifications for our use by InfiniteTactics.t

Portability

fsquota has been developed with Linux in mind and as such only supports Linux for now. Support for other platforms may be added in the future.

fsqm

This repository also ships fsqm, a simple command line interface to filesystem quotas. fsqm provides the ability to retrieve user and group quota reports and management of user and group quotas.

Status

The current release is v0.1.8.

Changes to fsquota are subject to semantic versioning.

License

fsquota is licensed under the terms of the MIT license.

Documentation

Overview

Package fsquota provides functions for working with filesystem quotas

Index

Constants

View Source
const VersionMajor = 0

VersionMajor is the Major version

View Source
const VersionMinor = 1

VersionMinor is the Minor version

View Source
const VersionPatch = 9

VersionPatch is the Patch version

Variables

This section is empty.

Functions

func GroupQuotasSupported added in v0.1.3

func GroupQuotasSupported(path string) (supported bool, err error)

GroupQuotasSupported checks if group quotas are supported on a given path

func UserQuotasSupported added in v0.1.3

func UserQuotasSupported(path string) (supported bool, err error)

UserQuotasSupported checks if quotas are supported on a given path

func VersionString

func VersionString() string

VersionString returns the complete version string

Types

type Info

type Info struct {
	Limits

	// Byte usage
	BytesUsed uint64 `json:"bytes_used"`
	// File usage
	FilesUsed uint64 `json:"files_used"`
}

Info contains quota information

func GetGroupInfo

func GetGroupInfo(path string, group *user.Group) (info *Info, err error)

GetGroupInfo retrieves a group's quota information

func GetUserInfo

func GetUserInfo(path string, user *user.User) (info *Info, err error)

GetUserInfo retrieves a user's quota information

func SetGroupQuota

func SetGroupQuota(path string, group *user.Group, limits *Limits) (info *Info, err error)

SetGroupQuota configures a group's quota

func SetUserQuota

func SetUserQuota(path string, user *user.User, limits *Limits) (info *Info, err error)

SetUserQuota configures a user's quota

type Limit

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

Limit represents a combined hard and soft limit

func (*Limit) GetHard

func (l *Limit) GetHard() (limit uint64)

GetHard retrieves the hard limit

func (*Limit) GetSoft

func (l *Limit) GetSoft() (limit uint64)

GetSoft retrieves the soft limit

func (*Limit) MarshalJSON added in v0.1.7

func (l *Limit) MarshalJSON() ([]byte, error)

MarshalJSON marshals a Limit struct

func (*Limit) SetHard

func (l *Limit) SetHard(limit uint64)

SetHard sets the hard limit

func (*Limit) SetSoft

func (l *Limit) SetSoft(limit uint64)

SetSoft sets the soft limit

type Limits

type Limits struct {
	// Byte usage limits
	Bytes Limit `json:"bytes"`

	// File count limits
	Files Limit `json:"files"`
}

Limits contains quota limits

type Report

type Report struct {
	// Map of user or group to info structure
	Infos map[string]*Info
}

Report contains a quota report

func GetGroupReport

func GetGroupReport(path string) (report *Report, err error)

GetGroupReport retrieves a report of all group quotas present at the given path

func GetUserReport

func GetUserReport(path string) (report *Report, err error)

GetUserReport retrieves a report of all user quotas present at the given path

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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