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