Exemplo n.º 1
0
// Setxattr will set the value for a named attribute on file at path
func Setxattr(path string, name string, data []byte, options int) error {
	p := C.CString(path)
	n := C.CString(name)
	defer C.free(unsafe.Pointer(p))
	defer C.free(unsafe.Pointer(n))

	_, err := C.setxattr(p, n, unsafe.Pointer(&data[0]), C.size_t(len(data)), 0, C.int(options))
	if err != nil {
		return err
	}
	return nil
}
Exemplo n.º 2
0
func cleardelattr(filepath string) error {
	val := C.char(0)
	e := C.setxattr(
		C.CString(filepath),
		C.CString("novm-deleted"),
		unsafe.Pointer(&val),
		C.size_t(1),
		C.int(0))
	if e != 0 {
		return syscall.Unlink(path.Join(filepath, ".deleted"))
	}
	return nil
}
Exemplo n.º 3
0
func setdelattr(filepath string) error {
	val := C.char(1)
	e := C.setxattr(
		C.CString(filepath),
		C.CString("novm-deleted"),
		unsafe.Pointer(&val),
		C.size_t(1),
		C.int(0))
	if e != 0 {
		fd, err := syscall.Open(
			path.Join(filepath, ".deleted"),
			syscall.O_RDWR|syscall.O_CREAT,
			syscall.S_IRUSR|syscall.S_IWUSR|syscall.S_IXUSR)
		if err == nil {
			syscall.Close(fd)
		}
		return err
	}
	return nil
}