summaryrefslogtreecommitdiff
path: root/filesystems/glusterfs/files/xattr-init.sh
blob: a00f3daba6146a34b84624241cf1b83754086691 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh

# $NetBSD: xattr-init.sh,v 1.8 2011/08/09 07:15:42 manu Exp $

GLUSTERFS_XATTR="
  trusted.distribute.linkinfo
  trusted.distribute.fix.layout
  trusted.glusterfs.pathinfo
  trusted.glusterfs.volume-mark
  trusted.glusterfs.test
  trusted.posix1.gen
  trusted.gfid
  trusted.afr
  glusterfs.open-fd-count
  glusterfs.inodelk-count
  glusterfs.entrylk-count
  glusterfs.posixlk-count
"

test $# -ne 1 && {
	echo "usage: $0 /export/volume/path"
	exit 1
}

VOLUME=$1

test -d ${VOLUME} || {
	echo "$0: ${VOLUME} is not a directory"
	exit 1
}

mkdir -p ${VOLUME}/.attribute/user || {
	echo "$0: cannot create ${VOLUME}/.attribute/user"
	exit 1
}

mkdir -p ${VOLUME}/.attribute/system || {
	echo "$0: cannot create ${VOLUME}/.attribute/system"
	exit 1
}

extattrctl start ${VOLUME} || {
	echo "$0: cannot start extended attributes on ${VOLUME}"
	exit 1
}

for attr in ${GLUSTERFS_XATTR} ; do
	ns="user";
	echo ${attr} | egrep -q '^(trusted|system|security)\.' && ns="system"

	attrfile=${VOLUME}/.attribute/${ns}/${attr}

	test -e ${attrfile} && {
		echo "$0: ${attrfile} exists."
		exit 1
	}

	extattrctl initattr 1024 ${attrfile} || {
		echo "$0: cannot initialize ${attrfile}"
		exit 1
	}

	extattrctl enable ${VOLUME} ${ns} ${attr} ${attrfile} || {
		echo "$0: cannot enable ${attr} backed by ${attrfile}"
		exit 1
	}
done