1*8975f5c5SAndroid Build Coastguard Worker# Copyright 2018 The Chromium Authors 2*8975f5c5SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be 3*8975f5c5SAndroid Build Coastguard Worker# found in the LICENSE file. 4*8975f5c5SAndroid Build Coastguard Worker 5*8975f5c5SAndroid Build Coastguard Worker"""Copies a FVM file and extends it by a specified amount. 6*8975f5c5SAndroid Build Coastguard Worker 7*8975f5c5SAndroid Build Coastguard WorkerArg #1: path to 'fvm'. 8*8975f5c5SAndroid Build Coastguard Worker #2: the path to the source fvm.blk. 9*8975f5c5SAndroid Build Coastguard Worker #3: the path that the extended FVM file will be written to. 10*8975f5c5SAndroid Build Coastguard Worker #4: the additional number of bytes to grow fvm.blk by.""" 11*8975f5c5SAndroid Build Coastguard Worker 12*8975f5c5SAndroid Build Coastguard Workerimport os 13*8975f5c5SAndroid Build Coastguard Workerimport shutil 14*8975f5c5SAndroid Build Coastguard Workerimport subprocess 15*8975f5c5SAndroid Build Coastguard Workerimport sys 16*8975f5c5SAndroid Build Coastguard Worker 17*8975f5c5SAndroid Build Coastguard Workerdef ExtendFVM(fvm_tool_path, src_path, dest_path, delta): 18*8975f5c5SAndroid Build Coastguard Worker old_size = os.path.getsize(src_path) 19*8975f5c5SAndroid Build Coastguard Worker new_size = old_size + int(delta) 20*8975f5c5SAndroid Build Coastguard Worker shutil.copyfile(src_path, dest_path) 21*8975f5c5SAndroid Build Coastguard Worker subprocess.check_call([fvm_tool_path, dest_path, 'extend', '--length', 22*8975f5c5SAndroid Build Coastguard Worker str(new_size)]) 23*8975f5c5SAndroid Build Coastguard Worker return 0 24*8975f5c5SAndroid Build Coastguard Worker 25*8975f5c5SAndroid Build Coastguard Workerif __name__ == '__main__': 26*8975f5c5SAndroid Build Coastguard Worker sys.exit(ExtendFVM(*sys.argv[1:])) 27