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