xattr

package module
v0.0.0-...-68e7a68 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2016 License: BSD-2-Clause Imports: 3 Imported by: 7

README

Introduction

This package provides a simple interface to user extended attributes on Linux and OSX. Support for xattrs is filesystem dependant, so not a given even if you are running one of those operating systems.

Linux notes

Support for extended attributes is available on ext3/ext4 but generally not enabled by default on most distributions. Make sure that you add the

user_xattr

flag to /etc/fstab for the filesystem you want to use.

Installation

goinstall github.com/davecheney/xattr

Documentation

godoc github.com/davecheney/xattr

Usage

A example program is provided with the source. The simplest way to compile and install it is

make -C $GOROOT/src/pkg/github.com/davecheney/xattr/example clean install

This will install it to your $GOBIN directory. If you have trouble running this example, make sure there isn't another xattr somewhere higher in your $PATH.

Before you start

All extended attributes need a file to be associated with. In this example I'm going to create an empty file in my home directory (see notes in the installation section)

touch ~/testfile

Setting an attribute

% $GOBIN/xattr -w username dave ~/testfile

Listing known attributes

% $GOBIN/xattr ~/testfile
username

Printing attribute values

% $GOBIN/xattr -p username ~/testfile
dave

Listing names and values

 % $GOBIN/xattr -l ~/testfile
 username: dave

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Getxattr

func Getxattr(path, name string) ([]byte, error)

Retrieve extended attribute data associated with path.

func Listxattr

func Listxattr(path string) ([]string, error)

Retrieves a list of names of extended attributes associated with the given path in the file system.

func Removexattr

func Removexattr(path, name string) error

Remove the attribute.

func Setxattr

func Setxattr(path, name string, data []byte) error

Associates name and data together as an attribute of path.

Types

type XAttrError

type XAttrError struct {
	Op   string
	Path string
	Name string
	Err  error
}

XAttrError records an error and the operation, file path and attribute that caused it.

func (*XAttrError) Error

func (e *XAttrError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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