Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: utility/pack_firmware_image

Issue 6459017: Change pack_firmware_image::EntryBlob behavior (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python2.6 1 #!/usr/bin/env python2.6
2 2
3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 import os 7 import os
8 import re 8 import re
9 import struct 9 import struct
10 import subprocess 10 import subprocess
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 123
124 class EntryBlob(EntryFmapArea): 124 class EntryBlob(EntryFmapArea):
125 125
126 def __init__(self, **kwargs): 126 def __init__(self, **kwargs):
127 Entry._CheckFields(kwargs, ('path',)) 127 Entry._CheckFields(kwargs, ('path',))
128 super(EntryBlob, self).__init__(**kwargs) 128 super(EntryBlob, self).__init__(**kwargs)
129 129
130 def Pack(self, firmware_image, entries): 130 def Pack(self, firmware_image, entries):
131 size = os.stat(self.path).st_size 131 size = os.stat(self.path).st_size
132 if size > 0: 132 if size > self.length:
133 size = min(size, self.length) 133 raise PackError('blob too large: %d > %d' % (size, self.length))
134 else: 134 if size == 0: # special case for files like /dev/zero
135 size = self.length 135 size = self.length
136 with open(self.path, 'rb') as blob_image: 136 with open(self.path, 'rb') as blob_image:
137 firmware_image.seek(self.offset) 137 firmware_image.seek(self.offset)
138 firmware_image.write(blob_image.read(size)) 138 firmware_image.write(blob_image.read(size))
139 139
140 140
141 class EntryKeyBlock(EntryFmapArea): 141 class EntryKeyBlock(EntryFmapArea):
142 142
143 stdout = None 143 stdout = None
144 stderr = None 144 stderr = None
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 raise ConfigError('undefined variable: %s' % varname) 257 raise ConfigError('undefined variable: %s' % varname)
258 _Info('%s = %s' % (varname, repr(env[varname]))) 258 _Info('%s = %s' % (varname, repr(env[varname])))
259 259
260 pack_firmware_image(env['ENTRIES'], env['OUTPUT'], env['SIZE']) 260 pack_firmware_image(env['ENTRIES'], env['OUTPUT'], env['SIZE'])
261 261
262 sys.exit(0) 262 sys.exit(0)
263 263
264 264
265 if __name__ == '__main__': 265 if __name__ == '__main__':
266 main() 266 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698