summaryrefslogtreecommitdiffstats
path: root/extras/quota-remove-xattr.sh
blob: 83e8c292e8440c2fa78bb992973fd2a6f8e06cc1 (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
#!/bin/bash

# This script is used to remove xattrs set by quota translator on a path.
# It is generally invoked from quota-metadata-cleanup.sh, but can
# also be used stand-alone.

usage ()
{
    echo >&2 "usage: $0 <path>"
}

main ()
{
    [ $# -ne 1 ] && usage $0

    XATTR_KEY_VALUE_PAIRS=`getfattr -d -m 'trusted.glusterfs.quota' $1 2>/dev/null | sed -e '/^# file/d'`

    for i in $XATTR_KEY_VALUE_PAIRS; do
        XATTR_KEY=`echo $i | sed -e 's/\([^=]*\).*/\1/g'`
        setfattr -x $XATTR_KEY $1
    done
}

main $@