partition.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. #
  2. # Copyright (c) 2013-2016 Intel Corporation.
  3. #
  4. # SPDX-License-Identifier: GPL-2.0-only
  5. #
  6. # DESCRIPTION
  7. # This module provides the OpenEmbedded partition object definitions.
  8. #
  9. # AUTHORS
  10. # Tom Zanussi <tom.zanussi (at] linux.intel.com>
  11. # Ed Bartosh <ed.bartosh> (at] linux.intel.com>
  12. import logging
  13. import os
  14. import uuid
  15. from wic import WicError
  16. from wic.misc import exec_cmd, exec_native_cmd, get_bitbake_var
  17. from wic.pluginbase import PluginMgr
  18. logger = logging.getLogger('wic')
  19. class Partition():
  20. def __init__(self, args, lineno):
  21. self.args = args
  22. self.active = args.active
  23. self.align = args.align
  24. self.disk = args.disk
  25. self.device = None
  26. self.extra_space = args.extra_space
  27. self.exclude_path = args.exclude_path
  28. self.include_path = args.include_path
  29. self.change_directory = args.change_directory
  30. self.fsopts = args.fsopts
  31. self.fspassno = args.fspassno
  32. self.fstype = args.fstype
  33. self.label = args.label
  34. self.use_label = args.use_label
  35. self.mkfs_extraopts = args.mkfs_extraopts
  36. self.mountpoint = args.mountpoint
  37. self.no_table = args.no_table
  38. self.num = None
  39. self.offset = args.offset
  40. self.overhead_factor = args.overhead_factor
  41. self.part_name = args.part_name
  42. self.part_type = args.part_type
  43. self.rootfs_dir = args.rootfs_dir
  44. self.size = args.size
  45. self.fixed_size = args.fixed_size
  46. self.source = args.source
  47. self.sourceparams = args.sourceparams
  48. self.system_id = args.system_id
  49. self.use_uuid = args.use_uuid
  50. self.uuid = args.uuid
  51. self.fsuuid = args.fsuuid
  52. self.type = args.type
  53. self.no_fstab_update = args.no_fstab_update
  54. self.updated_fstab_path = None
  55. self.has_fstab = False
  56. self.update_fstab_in_rootfs = False
  57. self.hidden = args.hidden
  58. self.mbr = args.mbr
  59. self.lineno = lineno
  60. self.source_file = ""
  61. def get_extra_block_count(self, current_blocks):
  62. """
  63. The --size param is reflected in self.size (in kB), and we already
  64. have current_blocks (1k) blocks, calculate and return the
  65. number of (1k) blocks we need to add to get to --size, 0 if
  66. we're already there or beyond.
  67. """
  68. logger.debug("Requested partition size for %s: %d",
  69. self.mountpoint, self.size)
  70. if not self.size:
  71. return 0
  72. requested_blocks = self.size
  73. logger.debug("Requested blocks %d, current_blocks %d",
  74. requested_blocks, current_blocks)
  75. if requested_blocks > current_blocks:
  76. return requested_blocks - current_blocks
  77. else:
  78. return 0
  79. def get_rootfs_size(self, actual_rootfs_size=0):
  80. """
  81. Calculate the required size of rootfs taking into consideration
  82. --size/--fixed-size flags as well as overhead and extra space, as
  83. specified in kickstart file. Raises an error if the
  84. `actual_rootfs_size` is larger than fixed-size rootfs.
  85. """
  86. if self.fixed_size:
  87. rootfs_size = self.fixed_size
  88. if actual_rootfs_size > rootfs_size:
  89. raise WicError("Actual rootfs size (%d kB) is larger than "
  90. "allowed size %d kB" %
  91. (actual_rootfs_size, rootfs_size))
  92. else:
  93. extra_blocks = self.get_extra_block_count(actual_rootfs_size)
  94. if extra_blocks < self.extra_space:
  95. extra_blocks = self.extra_space
  96. rootfs_size = actual_rootfs_size + extra_blocks
  97. rootfs_size = int(rootfs_size * self.overhead_factor)
  98. logger.debug("Added %d extra blocks to %s to get to %d total blocks",
  99. extra_blocks, self.mountpoint, rootfs_size)
  100. return rootfs_size
  101. @property
  102. def disk_size(self):
  103. """
  104. Obtain on-disk size of partition taking into consideration
  105. --size/--fixed-size options.
  106. """
  107. return self.fixed_size if self.fixed_size else self.size
  108. def prepare(self, creator, cr_workdir, oe_builddir, rootfs_dir,
  109. bootimg_dir, kernel_dir, native_sysroot, updated_fstab_path):
  110. """
  111. Prepare content for individual partitions, depending on
  112. partition command parameters.
  113. """
  114. self.updated_fstab_path = updated_fstab_path
  115. if self.updated_fstab_path and not (self.fstype.startswith("ext") or self.fstype == "msdos"):
  116. self.update_fstab_in_rootfs = True
  117. if not self.source:
  118. if self.fstype == "none" or self.no_table:
  119. return
  120. if not self.size and not self.fixed_size:
  121. raise WicError("The %s partition has a size of zero. Please "
  122. "specify a non-zero --size/--fixed-size for that "
  123. "partition." % self.mountpoint)
  124. if self.fstype == "swap":
  125. self.prepare_swap_partition(cr_workdir, oe_builddir,
  126. native_sysroot)
  127. self.source_file = "%s/fs.%s" % (cr_workdir, self.fstype)
  128. else:
  129. if self.fstype in ('squashfs', 'erofs'):
  130. raise WicError("It's not possible to create empty %s "
  131. "partition '%s'" % (self.fstype, self.mountpoint))
  132. rootfs = "%s/fs_%s.%s.%s" % (cr_workdir, self.label,
  133. self.lineno, self.fstype)
  134. if os.path.isfile(rootfs):
  135. os.remove(rootfs)
  136. prefix = "ext" if self.fstype.startswith("ext") else self.fstype
  137. method = getattr(self, "prepare_empty_partition_" + prefix)
  138. method(rootfs, oe_builddir, native_sysroot)
  139. self.source_file = rootfs
  140. return
  141. plugins = PluginMgr.get_plugins('source')
  142. if self.source not in plugins:
  143. raise WicError("The '%s' --source specified for %s doesn't exist.\n\t"
  144. "See 'wic list source-plugins' for a list of available"
  145. " --sources.\n\tSee 'wic help source-plugins' for "
  146. "details on adding a new source plugin." %
  147. (self.source, self.mountpoint))
  148. srcparams_dict = {}
  149. if self.sourceparams:
  150. # Split sourceparams string of the form key1=val1[,key2=val2,...]
  151. # into a dict. Also accepts valueless keys i.e. without =
  152. splitted = self.sourceparams.split(',')
  153. srcparams_dict = dict((par.split('=', 1) + [None])[:2] for par in splitted if par)
  154. plugin = PluginMgr.get_plugins('source')[self.source]
  155. plugin.do_configure_partition(self, srcparams_dict, creator,
  156. cr_workdir, oe_builddir, bootimg_dir,
  157. kernel_dir, native_sysroot)
  158. plugin.do_stage_partition(self, srcparams_dict, creator,
  159. cr_workdir, oe_builddir, bootimg_dir,
  160. kernel_dir, native_sysroot)
  161. plugin.do_prepare_partition(self, srcparams_dict, creator,
  162. cr_workdir, oe_builddir, bootimg_dir,
  163. kernel_dir, rootfs_dir, native_sysroot)
  164. plugin.do_post_partition(self, srcparams_dict, creator,
  165. cr_workdir, oe_builddir, bootimg_dir,
  166. kernel_dir, rootfs_dir, native_sysroot)
  167. # further processing required Partition.size to be an integer, make
  168. # sure that it is one
  169. if not isinstance(self.size, int):
  170. raise WicError("Partition %s internal size is not an integer. "
  171. "This a bug in source plugin %s and needs to be fixed." %
  172. (self.mountpoint, self.source))
  173. if self.fixed_size and self.size > self.fixed_size:
  174. raise WicError("File system image of partition %s is "
  175. "larger (%d kB) than its allowed size %d kB" %
  176. (self.mountpoint, self.size, self.fixed_size))
  177. def prepare_rootfs(self, cr_workdir, oe_builddir, rootfs_dir,
  178. native_sysroot, real_rootfs = True, pseudo_dir = None):
  179. """
  180. Prepare content for a rootfs partition i.e. create a partition
  181. and fill it from a /rootfs dir.
  182. Currently handles ext2/3/4, btrfs, vfat and squashfs.
  183. """
  184. rootfs = "%s/rootfs_%s.%s.%s" % (cr_workdir, self.label,
  185. self.lineno, self.fstype)
  186. if os.path.isfile(rootfs):
  187. os.remove(rootfs)
  188. p_prefix = os.environ.get("PSEUDO_PREFIX", "%s/usr" % native_sysroot)
  189. if (pseudo_dir):
  190. # Canonicalize the ignore paths. This corresponds to
  191. # calling oe.path.canonicalize(), which is used in bitbake.conf.
  192. include_paths = [rootfs_dir] + (get_bitbake_var("PSEUDO_INCLUDE_PATHS") or "").split(",")
  193. canonical_paths = []
  194. for path in include_paths:
  195. if "$" not in path:
  196. trailing_slash = path.endswith("/") and "/" or ""
  197. canonical_paths.append(os.path.realpath(path) + trailing_slash)
  198. include_paths = ",".join(canonical_paths)
  199. pseudo = "export PSEUDO_PREFIX=%s;" % p_prefix
  200. pseudo += "export PSEUDO_LOCALSTATEDIR=%s;" % pseudo_dir
  201. pseudo += "export PSEUDO_PASSWD=%s;" % rootfs_dir
  202. pseudo += "export PSEUDO_NOSYMLINKEXP=1;"
  203. pseudo += "export PSEUDO_INCLUDE_PATHS=%s;" % include_paths
  204. pseudo += "%s " % get_bitbake_var("FAKEROOTCMD")
  205. else:
  206. pseudo = None
  207. if not self.size and real_rootfs:
  208. # The rootfs size is not set in .ks file so try to get it
  209. # from bitbake variable
  210. rsize_bb = get_bitbake_var('ROOTFS_SIZE')
  211. rdir = get_bitbake_var('IMAGE_ROOTFS')
  212. if rsize_bb and (rdir == rootfs_dir or (rootfs_dir.split('/')[-2] == "tmp-wic" and rootfs_dir.split('/')[-1][:6] == "rootfs")):
  213. # Bitbake variable ROOTFS_SIZE is calculated in
  214. # Image._get_rootfs_size method from meta/lib/oe/image.py
  215. # using IMAGE_ROOTFS_SIZE, IMAGE_ROOTFS_ALIGNMENT,
  216. # IMAGE_OVERHEAD_FACTOR and IMAGE_ROOTFS_EXTRA_SPACE
  217. self.size = int(round(float(rsize_bb)))
  218. else:
  219. # Bitbake variable ROOTFS_SIZE is not defined so compute it
  220. # from the rootfs_dir size using the same logic found in
  221. # get_rootfs_size() from meta/classes/image.bbclass
  222. du_cmd = "du -ks %s" % rootfs_dir
  223. out = exec_cmd(du_cmd)
  224. self.size = int(out.split()[0])
  225. prefix = "ext" if self.fstype.startswith("ext") else self.fstype
  226. method = getattr(self, "prepare_rootfs_" + prefix)
  227. method(rootfs, cr_workdir, oe_builddir, rootfs_dir, native_sysroot, pseudo)
  228. self.source_file = rootfs
  229. # get the rootfs size in the right units for kickstart (kB)
  230. du_cmd = "du -Lbks %s" % rootfs
  231. out = exec_cmd(du_cmd)
  232. self.size = int(out.split()[0])
  233. def prepare_rootfs_ext(self, rootfs, cr_workdir, oe_builddir, rootfs_dir,
  234. native_sysroot, pseudo):
  235. """
  236. Prepare content for an ext2/3/4 rootfs partition.
  237. """
  238. du_cmd = "du -ks %s" % rootfs_dir
  239. out = exec_cmd(du_cmd)
  240. actual_rootfs_size = int(out.split()[0])
  241. rootfs_size = self.get_rootfs_size(actual_rootfs_size)
  242. with open(rootfs, 'w') as sparse:
  243. os.ftruncate(sparse.fileno(), rootfs_size * 1024)
  244. extraopts = self.mkfs_extraopts or "-F -i 8192"
  245. # use hash_seed to generate reproducible ext4 images
  246. (extraopts, pseudo) = self.get_hash_seed_ext4(extraopts, pseudo)
  247. label_str = ""
  248. if self.label:
  249. label_str = "-L %s" % self.label
  250. mkfs_cmd = "mkfs.%s %s %s %s -U %s -d %s" % \
  251. (self.fstype, extraopts, rootfs, label_str, self.fsuuid, rootfs_dir)
  252. exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
  253. if self.updated_fstab_path and self.has_fstab and not self.no_fstab_update:
  254. debugfs_script_path = os.path.join(cr_workdir, "debugfs_script")
  255. with open(debugfs_script_path, "w") as f:
  256. f.write("cd etc\n")
  257. f.write("rm fstab\n")
  258. f.write("write %s fstab\n" % (self.updated_fstab_path))
  259. debugfs_cmd = "debugfs -w -f %s %s" % (debugfs_script_path, rootfs)
  260. exec_native_cmd(debugfs_cmd, native_sysroot)
  261. mkfs_cmd = "fsck.%s -pvfD %s" % (self.fstype, rootfs)
  262. exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
  263. if os.getenv('SOURCE_DATE_EPOCH'):
  264. sde_time = hex(int(os.getenv('SOURCE_DATE_EPOCH')))
  265. debugfs_script_path = os.path.join(cr_workdir, "debugfs_script")
  266. files = []
  267. for root, dirs, others in os.walk(rootfs_dir):
  268. base = root.replace(rootfs_dir, "").rstrip(os.sep)
  269. files += [ "/" if base == "" else base ]
  270. files += [ base + "/" + n for n in dirs + others ]
  271. with open(debugfs_script_path, "w") as f:
  272. f.write("set_current_time %s\n" % (sde_time))
  273. if self.updated_fstab_path and self.has_fstab and not self.no_fstab_update:
  274. f.write("set_inode_field /etc/fstab mtime %s\n" % (sde_time))
  275. f.write("set_inode_field /etc/fstab mtime_extra 0\n")
  276. for file in set(files):
  277. for time in ["atime", "ctime", "crtime"]:
  278. f.write("set_inode_field \"%s\" %s %s\n" % (file, time, sde_time))
  279. f.write("set_inode_field \"%s\" %s_extra 0\n" % (file, time))
  280. for time in ["wtime", "mkfs_time", "lastcheck"]:
  281. f.write("set_super_value %s %s\n" % (time, sde_time))
  282. for time in ["mtime", "first_error_time", "last_error_time"]:
  283. f.write("set_super_value %s 0\n" % (time))
  284. debugfs_cmd = "debugfs -w -f %s %s" % (debugfs_script_path, rootfs)
  285. exec_native_cmd(debugfs_cmd, native_sysroot)
  286. self.check_for_Y2038_problem(rootfs, native_sysroot)
  287. def get_hash_seed_ext4(self, extraopts, pseudo):
  288. if os.getenv('SOURCE_DATE_EPOCH'):
  289. sde_time = int(os.getenv('SOURCE_DATE_EPOCH'))
  290. if pseudo:
  291. pseudo = "export E2FSPROGS_FAKE_TIME=%s;%s " % (sde_time, pseudo)
  292. else:
  293. pseudo = "export E2FSPROGS_FAKE_TIME=%s; " % sde_time
  294. # Set hash_seed to generate deterministic directory indexes
  295. namespace = uuid.UUID("e7429877-e7b3-4a68-a5c9-2f2fdf33d460")
  296. if self.fsuuid:
  297. namespace = uuid.UUID(self.fsuuid)
  298. hash_seed = str(uuid.uuid5(namespace, str(sde_time)))
  299. extraopts += " -E hash_seed=%s" % hash_seed
  300. return (extraopts, pseudo)
  301. def prepare_rootfs_btrfs(self, rootfs, cr_workdir, oe_builddir, rootfs_dir,
  302. native_sysroot, pseudo):
  303. """
  304. Prepare content for a btrfs rootfs partition.
  305. """
  306. du_cmd = "du -ks %s" % rootfs_dir
  307. out = exec_cmd(du_cmd)
  308. actual_rootfs_size = int(out.split()[0])
  309. rootfs_size = self.get_rootfs_size(actual_rootfs_size)
  310. with open(rootfs, 'w') as sparse:
  311. os.ftruncate(sparse.fileno(), rootfs_size * 1024)
  312. label_str = ""
  313. if self.label:
  314. label_str = "-L %s" % self.label
  315. mkfs_cmd = "mkfs.%s -b %d -r %s %s %s -U %s %s" % \
  316. (self.fstype, rootfs_size * 1024, rootfs_dir, label_str,
  317. self.mkfs_extraopts, self.fsuuid, rootfs)
  318. exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
  319. def prepare_rootfs_msdos(self, rootfs, cr_workdir, oe_builddir, rootfs_dir,
  320. native_sysroot, pseudo):
  321. """
  322. Prepare content for a msdos/vfat rootfs partition.
  323. """
  324. du_cmd = "du -bks %s" % rootfs_dir
  325. out = exec_cmd(du_cmd)
  326. blocks = int(out.split()[0])
  327. rootfs_size = self.get_rootfs_size(blocks)
  328. label_str = "-n boot"
  329. if self.label:
  330. label_str = "-n %s" % self.label
  331. size_str = ""
  332. extraopts = self.mkfs_extraopts or '-S 512'
  333. dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \
  334. (label_str, self.fsuuid, size_str, extraopts, rootfs,
  335. rootfs_size)
  336. exec_native_cmd(dosfs_cmd, native_sysroot)
  337. mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (rootfs, rootfs_dir)
  338. exec_native_cmd(mcopy_cmd, native_sysroot)
  339. if self.updated_fstab_path and self.has_fstab and not self.no_fstab_update:
  340. mcopy_cmd = "mcopy -m -i %s %s ::/etc/fstab" % (rootfs, self.updated_fstab_path)
  341. exec_native_cmd(mcopy_cmd, native_sysroot)
  342. chmod_cmd = "chmod 644 %s" % rootfs
  343. exec_cmd(chmod_cmd)
  344. prepare_rootfs_vfat = prepare_rootfs_msdos
  345. def prepare_rootfs_squashfs(self, rootfs, cr_workdir, oe_builddir, rootfs_dir,
  346. native_sysroot, pseudo):
  347. """
  348. Prepare content for a squashfs rootfs partition.
  349. """
  350. extraopts = self.mkfs_extraopts or '-noappend'
  351. squashfs_cmd = "mksquashfs %s %s %s" % \
  352. (rootfs_dir, rootfs, extraopts)
  353. exec_native_cmd(squashfs_cmd, native_sysroot, pseudo=pseudo)
  354. def prepare_rootfs_erofs(self, rootfs, cr_workdir, oe_builddir, rootfs_dir,
  355. native_sysroot, pseudo):
  356. """
  357. Prepare content for a erofs rootfs partition.
  358. """
  359. extraopts = self.mkfs_extraopts or ''
  360. erofs_cmd = "mkfs.erofs %s -U %s %s %s" % \
  361. (extraopts, self.fsuuid, rootfs, rootfs_dir)
  362. exec_native_cmd(erofs_cmd, native_sysroot, pseudo=pseudo)
  363. def prepare_empty_partition_none(self, rootfs, oe_builddir, native_sysroot):
  364. pass
  365. def prepare_empty_partition_ext(self, rootfs, oe_builddir,
  366. native_sysroot):
  367. """
  368. Prepare an empty ext2/3/4 partition.
  369. """
  370. size = self.disk_size
  371. with open(rootfs, 'w') as sparse:
  372. os.ftruncate(sparse.fileno(), size * 1024)
  373. extraopts = self.mkfs_extraopts or "-i 8192"
  374. # use hash_seed to generate reproducible ext4 images
  375. (extraopts, pseudo) = self.get_hash_seed_ext4(extraopts, None)
  376. label_str = ""
  377. if self.label:
  378. label_str = "-L %s" % self.label
  379. mkfs_cmd = "mkfs.%s -F %s %s -U %s %s" % \
  380. (self.fstype, extraopts, label_str, self.fsuuid, rootfs)
  381. exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
  382. self.check_for_Y2038_problem(rootfs, native_sysroot)
  383. def prepare_empty_partition_btrfs(self, rootfs, oe_builddir,
  384. native_sysroot):
  385. """
  386. Prepare an empty btrfs partition.
  387. """
  388. size = self.disk_size
  389. with open(rootfs, 'w') as sparse:
  390. os.ftruncate(sparse.fileno(), size * 1024)
  391. label_str = ""
  392. if self.label:
  393. label_str = "-L %s" % self.label
  394. mkfs_cmd = "mkfs.%s -b %d %s -U %s %s %s" % \
  395. (self.fstype, self.size * 1024, label_str, self.fsuuid,
  396. self.mkfs_extraopts, rootfs)
  397. exec_native_cmd(mkfs_cmd, native_sysroot)
  398. def prepare_empty_partition_msdos(self, rootfs, oe_builddir,
  399. native_sysroot):
  400. """
  401. Prepare an empty vfat partition.
  402. """
  403. blocks = self.disk_size
  404. label_str = "-n boot"
  405. if self.label:
  406. label_str = "-n %s" % self.label
  407. size_str = ""
  408. extraopts = self.mkfs_extraopts or '-S 512'
  409. dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \
  410. (label_str, self.fsuuid, extraopts, size_str, rootfs,
  411. blocks)
  412. exec_native_cmd(dosfs_cmd, native_sysroot)
  413. chmod_cmd = "chmod 644 %s" % rootfs
  414. exec_cmd(chmod_cmd)
  415. prepare_empty_partition_vfat = prepare_empty_partition_msdos
  416. def prepare_swap_partition(self, cr_workdir, oe_builddir, native_sysroot):
  417. """
  418. Prepare a swap partition.
  419. """
  420. path = "%s/fs.%s" % (cr_workdir, self.fstype)
  421. with open(path, 'w') as sparse:
  422. os.ftruncate(sparse.fileno(), self.size * 1024)
  423. label_str = ""
  424. if self.label:
  425. label_str = "-L %s" % self.label
  426. mkswap_cmd = "mkswap %s -U %s %s" % (label_str, self.fsuuid, path)
  427. exec_native_cmd(mkswap_cmd, native_sysroot)
  428. def check_for_Y2038_problem(self, rootfs, native_sysroot):
  429. """
  430. Check if the filesystem is affected by the Y2038 problem
  431. (Y2038 problem = 32 bit time_t overflow in January 2038)
  432. """
  433. def get_err_str(part):
  434. err = "The {} filesystem {} has no Y2038 support."
  435. if part.mountpoint:
  436. args = [part.fstype, "mounted at %s" % part.mountpoint]
  437. elif part.label:
  438. args = [part.fstype, "labeled '%s'" % part.label]
  439. elif part.part_name:
  440. args = [part.fstype, "in partition '%s'" % part.part_name]
  441. else:
  442. args = [part.fstype, "in partition %s" % part.num]
  443. return err.format(*args)
  444. # ext2 and ext3 are always affected by the Y2038 problem
  445. if self.fstype in ["ext2", "ext3"]:
  446. logger.warn(get_err_str(self))
  447. return
  448. ret, out = exec_native_cmd("dumpe2fs %s" % rootfs, native_sysroot)
  449. # if ext4 is affected by the Y2038 problem depends on the inode size
  450. for line in out.splitlines():
  451. if line.startswith("Inode size:"):
  452. size = int(line.split(":")[1].strip())
  453. if size < 256:
  454. logger.warn("%s Inodes (of size %d) are too small." %
  455. (get_err_str(self), size))
  456. break