3 # Copyright (c) 2014, Lawrence Livermore National Security, LLC.
4 # Produced at the Lawrence Livermore National Laboratory.
5 # Written by Christopher J. Morrone <morrone2@llnl.gov>
8 # This file is part of lustre-tools-llnl.
10 # This program is free software; you can redistribute it and/or modify it
11 # under the terms of the GNU General Public License (as published by the
12 # Free Software Foundation) version 2, dated June 1991.
14 # This program is distributed in the hope that it will be useful, but WITHOUT
15 # ANY WARRANTY; without even the IMPLIED WARRANTY OF
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # terms and conditions of the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software Foundation,
21 # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 # Given a zfs dataset for a Lustre OST and the object number of a file
24 # in that dataset, this script will call zdb to retreive the Lustre FID
25 # and print it out in standard Lustre FID format.
31 return sum(b[i] << i*8 for i in range(len(b)))
34 if len(sys.argv) != 3:
35 print "Usage:", sys.argv[0], "<dataset> <object>"
38 p = subprocess.Popen(["zdb", "-e", "-vvv", sys.argv[1], sys.argv[2]],
39 stdout=subprocess.PIPE)
40 pout, perr = p.communicate()
44 for line in pout.split('\n'):
46 if not part or part[0] != 'trusted.fid':
62 print "FID not found on", sys.argv[1], sys.argv[2]
66 + hex(from_bytes(b[0:8])) \
68 + hex(from_bytes(b[8:12])) \
70 + hex(from_bytes(b[12:16])) \
75 if __name__ == '__main__':