summaryrefslogtreecommitdiffstats
path: root/extras/file_size_contri.sh
blob: 4f52a9a89b4a5ae13cdfa59a87b57211a9630df4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash

# This script checks whether the contribution and disk-usage of a file is same.

CONTRIBUTION_HEX=`getfattr -h -e hex -d -m trusted.glusterfs.quota.*.contri $1 2>&1 | sed -e '/^#/d' | sed -e '/^getfattr/d' | sed -e '/^$/d' | cut -d'=' -f 2`

BLOCKS=`stat -c %b $1`
SIZE=$(($BLOCKS * 512))

CONTRIBUTION=`printf "%d" $CONTRIBUTION_HEX`

if [ $CONTRIBUTION -ne $SIZE ]; then
    printf "contribution of %s:%d\n" $1 $CONTRIBUTION
    echo "size of $1: $SIZE"
    echo "==================================================="
fi