File: gfid_to_path.sh

package info (click to toggle)
glusterfs 11.1-3~bpo12%2B1
  • links: PTS
  • area: main
  • in suites: bookworm-backports
  • size: 45,092 kB
  • sloc: ansic: 467,228; sh: 51,851; python: 12,989; makefile: 1,962; yacc: 487; lisp: 124; lex: 61; xml: 14
file content (43 lines) | stat: -rw-r--r-- 878 bytes parent folder | download | duplicates (3)
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
#!/bin/bash

## Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com/>
## This file is part of GlusterFS.
##
## This file is licensed to you under your choice of the GNU Lesser
## General Public License, version 3 or any later version (LGPLv3 or
## later), or the GNU General Public License, version 2 (GPLv2), in all
## cases as published by the Free Software Foundation.

E_BADARGS=65


gfid_to_path ()
{
    brick_dir=$1;
    gfid_file=$(readlink -e $2);

    current_dir=$(pwd);
    cd $brick_dir;

    while read gfid
    do
        to_search=`echo .glusterfs/${gfid:0:2}"/"${gfid:2:2}"/"$gfid`;
        find . -samefile $to_search | grep -v $to_search;
    done < $gfid_file;

    cd $current_dir;
}


main ()
{
    if [ $# -ne 2 ]
    then
        echo "Usage: `basename $0` BRICK_DIR GFID_FILE";
        exit $E_BADARGS;
    fi

    gfid_to_path $1 $2;
}

main "$@";