Commit graph

311 commits

Author SHA1 Message Date
Vladimir 'phcoder' Serbinenko
cb544caa2e * grub-core/fs/zfs/zfs.c (zfs_mount): Fix spurious warning. 2011-11-10 08:43:08 +01:00
Vladimir 'phcoder' Serbinenko
45bd824d2e Fix ZFS memory and resource leaks.
* grub-core/fs/zfs/zfs.c (fill_vdev_info_real): New paramter inserted.
	All users updated.
	Free type on exit.
	(fill_vdev_info): New parameter inserted. All users updated.
	(check_pool_label): Likewise.
	(scan_disk): Likewise.
	(scan_devices): Close non-inserted disks.
	(fzap_iterate): Free l.
	(unmount_device): Free children descripto memory.
2011-11-10 08:38:06 +01:00
Vladimir 'phcoder' Serbinenko
ad9a2f44b4 * grub-core/fs/iso9660.c (grub_iso9660_iterate_dir): Fix grub_strncat
argument (access out of bounds).
2011-11-10 08:16:27 +01:00
Vladimir 'phcoder' Serbinenko
6b68db81fc * grub-core/fs/btrfs.c (grub_btrfs_read_logical): Fix RAID10 logic for
>= 6 drives.
2011-11-10 08:09:33 +01:00
Vladimir 'phcoder' Serbinenko
8a5a3a5b5a Fix several memory leaks.
* grub-core/fs/btrfs.c (grub_btrfs_dir): Fix memory leak.
	* grub-core/fs/cpio.c (grub_cpio_find_file): Likewise.
	(grub_cpio_dir): Likewise.
	* grub-core/fs/fat.c (grub_fat_label): Likewise.
	* grub-core/fs/jfs.c (grub_jfs_label): Likewise.
	* grub-core/fs/romfs.c (grub_romfs_close): Likewise.
	(grub_romfs_label): Likewise.
	* grub-core/fs/squash4.c (squash_mount): Use zalloc for safety.
	(squash_unmount): New function.
	(grub_squash_dir): Fix memory leak.
	(grub_squash_open): Likewise.
	(grub_squash_read): Likewise.
	(grub_squash_mtime): Likewise.
	* grub-core/fs/xfs.c (grub_xfs_open): Likewise.
	* grub-core/fs/zfs/zfs.c (check_pool_label): Likewise.
	* util/grub-fstest.c (fstest): Likewise.
2011-11-09 15:01:58 +01:00
Vladimir 'phcoder' Serbinenko
52b656c037 Several AFFS fixes.
* grub-core/fs/affs.c (grub_affs_bblock): Replace flags with version.
	(GRUB_AFFS_FLAG_FFS): Removed.
	(GRUB_AFFS_SYMLINK_SIZE): Likewise.
	(GRUB_AFFS_FILETYPE_DIR): Make positive and unsigned.
	(GRUB_AFFS_FILETYPE_DIR), (GRUB_AFFS_FILETYPE_REG): Fix a mix-up.
	(grub_fshelp_node): Make block 32-bit.
	Add block_cache and last_block_cache.
	(grub_affs_read_block): Fill and use block cache.
	(grub_affs_read_file): Removed.
	(grub_affs_mount): Zero-fill node. Fix version check. Don't reread
	boot block.
	(grub_affs_read_symlink): Fix symlink size. Add a \0 at the end for
	safety.
	(grub_affs_iterate_dir): Use more appropriate types. Zero-fill allocated
	space.
	(grub_affs_close): Free block cache.
	(grub_affs_read): Use grub_fshelp_read_file directly.
2011-11-09 11:43:39 +01:00
Vladimir 'phcoder' Serbinenko
438a746a3f * grub-core/fs/zfs/zfs.c (read_dva): Issue an error if read failed
with no error set.
2011-11-08 20:03:06 +01:00
Vladimir 'phcoder' Serbinenko
3ae17eb83c Fix potential problem with calling zfs_to_cpu and cpu_to_be in a row.
* grub-core/fs/zfs/zfscrypt.c (grub_zfs_decrypt_real): Use explicit
	byteswap when needed.
2011-11-08 19:44:18 +01:00
Vladimir 'phcoder' Serbinenko
4a19b6017d Fix ZFS crypto error types.
* grub-core/fs/zfs/zfscrypt.c (grub_ccm_decrypt): Fix return type.
	(grub_gcm_decrypt): Likewise.
	(grub_zfs_load_key_real): Fix error code type. Handle possible error
	from PBKDF2.
2011-11-08 16:07:27 +01:00
Vladimir 'phcoder' Serbinenko
9f421dd1f0 * grub-core/fs/zfs/zfs.c (zap_iterate): Remove set but not used
variable.
2011-11-08 11:32:19 +01:00
Vladimir 'phcoder' Serbinenko
3084ede4c7 ZFS crypto support.
* Makefile.util.def (libgrubmods): Add grub-core/fs/zfs/zfscrypt.c.
	* grub-core/Makefile.core.def (zfscrypt): New module.
	* grub-core/fs/zfs/zfs.c (subvolume): New structure.
	(grub_zfs_data): Replace mdn with subvol. Put case_insensitivity inside
	it. All users updated.
	(grub_zfs_decrypt): New var.
	(grub_zfs_load_key): Likewise.
	(zio_checksum_functions): Add SHA256+MAC.
	(zio_checksum_verify): Handle incomplete comparison due to MAC.
	(zio_read): Handle encrypted blocks.
	(zap_verify): Remove incorrect check.
	(fzap_iterate): Handle non-standard fzap.
	(zap_iterate): Likewise.
	(zap_iterate_u64): New function.
	(dnode_get_fullpath): Load keys.
	* grub-core/fs/zfs/zfscrypt.c: New file.
	* grub-core/lib/crypto.c (grub_crypto_cipher_close): Removed.
	(grub_crypto_ecb_encrypt): Make input const.
	* include/grub/crypto.h (grub_crypto_cipher_close): Inline.
	(grub_crypto_ecb_encrypt): Make input const.
	(GRUB_CIPHER_AES): New macro.
	* include/grub/zfs/dmu.h (dmu_object_type): Add DMU_OT_DSL_KEYCHAIN.
	* include/grub/zfs/dsl_dir.h (dsl_dir_phys): Add keychain.
	* include/grub/zfs/spa.h (grub_zfs_endian): Moved from here ...
	* include/grub/zfs/zfs.h (grub_zfs_endian): ... here. Added GURB_ZFS_
	prefix. All users updated.
	(grub_zfs_add_key): New proto.
	(grub_zfs_decrypt): Likewise.
	(grub_zfs_load_key): Likewise.
	* include/grub/zfs/zio.h (zio_checksum): Add SHA256+MAC.
	* util/grub-fstest.c (options): Add -K option.
	(argp_parser): Likewise.
2011-11-06 21:44:48 +01:00
Vladimir 'phcoder' Serbinenko
ae9a20d973 Small cleanup 2011-11-06 21:08:32 +01:00
Vladimir 'phcoder' Serbinenko
bc1de0bc26 GCM support 2011-11-06 21:05:25 +01:00
Vladimir 'phcoder' Serbinenko
d99b3726e5 Support ZFS subvolumes with multiple keys 2011-11-06 17:13:38 +01:00
Vladimir 'phcoder' Serbinenko
ed746949af ZFS passphrase support 2011-11-06 16:30:52 +01:00
Vladimir 'phcoder' Serbinenko
f003a8c5e7 Move ZFS crypto to separate module 2011-11-06 15:18:25 +01:00
Vladimir 'phcoder' Serbinenko
2cdc899567 ZFS crypto key adding 2011-11-06 14:44:29 +01:00
Vladimir 'phcoder' Serbinenko
1bc7cc1b4d First part of zfs-crypto. CCM support with 0-filled keys 2011-11-06 13:18:27 +01:00
Vladimir 'phcoder' Serbinenko
b632b404e0 Support zle compression on ZFS.
* grub-core/fs/zfs/zfs.c (zle_decompress): New function.
	(decomp_table): Add zle.
	* include/grub/zfs/zio.h (zio_compress): Add zle.
2011-11-05 14:50:53 +01:00
Vladimir 'phcoder' Serbinenko
c7ba4f6984 Support BtrFS embedding.
* grub-core/fs/btrfs.c (grub_btrfs_embed) [GRUB_UTIL]: New function.
	(grub_btrfs_fs) [GRUB_UTIL]: Set embed.
	* include/grub/fs.h (grub_fs) [GRUB_UTIL]: New field embed.
	* util/grub-setup.c (setup): Use fs embedding if available.
	Add additional sanity check.
2011-11-05 14:47:25 +01:00
Vladimir 'phcoder' Serbinenko
c2fd16cacb Support third redundancy strip on raidz3.
* grub-core/fs/zfs/zfs.c (recovery): Add Gauss for general case.
	Return error on singularity. All users updated.
	(read_device): Don't stop on 3rd failure on raidz3.
2011-11-04 15:19:23 +01:00
Vladimir 'phcoder' Serbinenko
8622923b66 Support case-insensitive ZFS subvolumes.
* grub-core/fs/zfs/zfs.c (mzap_lookup): New parameter case_insensitive.
	All users updated.
	(zap_hash): Likewise.
	(name_cmp): New function.
	(zap_leaf_array_equal): New parameter case_insensitive.
	All users updated.
	(zap_leaf_lookup): Likewise.
	(fzap_lookup): Likewise.
	(zap_lookup): Likewise.
	(dnode_get_path): New parameter case_insensitive. Retrieve case
	sensitiviness of a volume. All users updated.
	(dnode_get_fullpath): New parameter case_insensitive.
	All users updated.
	(grub_zfs_dir): Set info.case_insensitiveness.
2011-11-04 13:44:56 +01:00
Vladimir 'phcoder' Serbinenko
95f2e86095 Support second redundancy strip on raidz(2,3).
* grub-core/fs/zfs/zfs.c (powx): New array.
	(powx_inv): Likewise.
	(poly): New const.
	(xor_out): New function.
	(gf_mul): Likewise.
	(recovery): Likewise.
	(read_device): Use second redundancy strip.
2011-11-04 13:36:08 +01:00
Vladimir 'phcoder' Serbinenko
9d9b3d2f02 * grub-core/fs/ufs.c (grub_ufs_mtime) [MODE_UFS2]: Check mtime field
as well.
2011-11-03 15:00:45 +01:00
Vladimir 'phcoder' Serbinenko
7d0ac93163 Make reiserfs label retrieval similar to other *_label functions.
* grub-core/fs/reiserfs.c (grub_reiserfs_superblock): New field label.
	(REISERFS_MAX_LABEL_LENGTH): Removed.
	(REISERFS_LABEL_OFFSET): Likewise.
	(grub_reiserfs_label): Rewritten.
2011-11-03 14:57:34 +01:00
Vladimir 'phcoder' Serbinenko
f92ece7d45 * grub-core/fs/nilfs2.c (grub_nilfs2_mtime): Use correct superblock
field.
2011-11-03 14:52:59 +01:00
Vladimir 'phcoder' Serbinenko
cf5ba824ea * grub-core/fs/zfs/zfs.c (read_device): Support raidz3. 2011-11-03 07:29:35 +01:00
Vladimir 'phcoder' Serbinenko
177440046d * grub-core/fs/zfs/zfs.c (read_device): Add ability to sustain a single
drive failure on both raidz and raidz2.
2011-11-02 23:28:25 +01:00
Vladimir 'phcoder' Serbinenko
aca5aefc7c Fix RAIDZ(2) for >= 5 devices.
* grub-core/fs/zfs/zfs.c (read_device): Fix length formula. Remove
	asize argument. All users updated.
2011-11-02 20:48:04 +01:00
Vladimir 'phcoder' Serbinenko
ce8ca56ed9 Fix RAIDZ(2).
* grub-core/fs/zfs/zfs.c (grub_zfs_device_desc): New member ashift.
	(fill_vdev_info_real): Set ashift.
	(read_device): Rewrite RAIDZ part based on reverse engineering.
2011-11-01 20:05:28 +01:00
Vladimir 'phcoder' Serbinenko
7c01e783dc * grub-core/fs/btrfs.c (grub_btrfs_extent_read): Add sanity check and
don't report potentially unavialiable fields in debug output.
	(find_path): Fix double-free and memory leak.
2011-10-31 13:56:52 +01:00
Vladimir 'phcoder' Serbinenko
ce109e843c Read label on UFS1.
* grub-core/fs/ufs.c (grub_ufs_label): Remove MODE_UFS2 condition.
	(grub_ufs_fs): Always set .label.
2011-10-31 10:52:39 +01:00
Vladimir 'phcoder' Serbinenko
87661123b2 Use shifts in UFS.
* grub-core/fs/ufs.c (UFS_LOG_BLKSZ): New macro.
	(grub_ufs_data): New field log2_blksz.
	(grub_ufs_read_file): Use shifts.
	(grub_ufs_mount): Check block size and logarithm it.
2011-10-31 10:50:43 +01:00
Vladimir 'phcoder' Serbinenko
46bc1dc244 * grub-core/fs/ufs.c (grub_ufs_lookup_symlink): Fix handling of
long symlinks.
2011-10-31 10:40:30 +01:00
Vladimir 'phcoder' Serbinenko
19ee298767 Handle symlinks and long names on tar and cpio.
* grub-core/fs/cpio.c (ATTR_TYPE): New definition.
	(ATTR_FILE): Likewise.
	(ATTR_DIR): Likewise.
	(ATTR_LNK): Likewise.
	(grub_cpio_data) [MODE_USTAR]: New fields linkname and linkname_alloc.
	(grub_cpio_find_file): Fill mode, handle linkname field as well as
	L and K entries.
	(grub_cpio_mount): Zero-fill data.
	(handle_symlink): New function.
2011-10-30 23:06:25 +01:00
Vladimir 'phcoder' Serbinenko
c83a08d84a Fix iso9660 filename limitations and fix memory leaks.
* grub-core/fs/iso9660.c (set_rockridge): Free sua at the end.
	(grub_iso9660_iterate_dir): Fix slash handling in symlinks.
2011-10-30 20:23:05 +01:00
Vladimir 'phcoder' Serbinenko
45cdd3ea37 Fix JFS file name length limitations.
* grub-core/fs/jfs.c (grub_jfs_inode): Fix in-place symlink length.
	(grub_jfs_diropen): Fix maximum filename length.
	(grub_jfs_getent): Fix filename length.
	(grub_jfs_lookup_symlink): Fix size checks.
2011-10-30 20:14:57 +01:00
Vladimir 'phcoder' Serbinenko
eb0b6b45f3 Leverage BFS implementation to read AFS.
* Makefile.util.def (libgrubmods): Add afs.c.
	* grub-core/Makefile.core.def (afs): New module
	* grub-core/fs/afs.c: New file.
	* grub-core/fs/bfs.c [MODE_AFS]: Adapt for AFS.
2011-10-30 16:10:18 +01:00
Vladimir 'phcoder' Serbinenko
80f9f81424 Fix a mistake in previous commit 2011-10-30 14:25:53 +01:00
Vladimir 'phcoder' Serbinenko
785ab8c760 * grub-core/fs/bfs.c: MAcroify and add some necessary sanity checks. 2011-10-30 14:17:44 +01:00
Vladimir 'phcoder' Serbinenko
c4a1628f67 * grub-core/fs/bfs.c: Run indent. 2011-10-30 13:27:53 +01:00
Vladimir 'phcoder' Serbinenko
5825b3794b BFS implementation based on the specification.
* grub-core/fs/bfs.c: New file.
	* Makefile.util.def (libgrubmods): Add bfs.c.
	* grub-core/Makefile.core.def (bfs): New module.
2011-10-30 13:25:51 +01:00
Vladimir 'phcoder' Serbinenko
faba3d163a Remove afs and befs because of copyright problem.
* grub-core/fs/afs.c: Removed.
	* grub-core/fs/afs_be.c: Removed.
	* grub-core/fs/befs.c: Removed.
	* grub-core/fs/befs_be.c: Removed.
	* Makefile.util.def (libgrubkern): Remove afs, afs_be, befs and befs_be.
	* grub-core/Makefile.core.def (afs): Removed.
	(afs_be): Likewise.
	(befs): Likewise.
	(befs_be): Likewise.
2011-10-29 11:29:34 +02:00
Vladimir 'phcoder' Serbinenko
c39224b052 Prefer rockridge over Joliet.
* grub-core/fs/iso9660.c (grub_iso9660_mount): Move rockridge detection
	to ...
	(set_rockridge): ... here.
	(grub_iso9660_mount): Check rockridge on the primary label when
	discovering. Ignore Joliet if Rockridge is present.
2011-10-28 16:26:17 +02:00
Vladimir 'phcoder' Serbinenko
e551115a26 Use shifts in nilfs2.
* grub-core/fs/nilfs2.c (LOG_INODE_SIZE): New definition.
	(LOG_NILFS_DAT_ENTRY_SIZE): Likewise.
	(grub_nilfs2_palloc_entries_per_group): Replace with ...
	(grub_nilfs2_log_palloc_entries_per_group): ... this.
	(grub_nilfs2_palloc_group): Use shifts and bitmasks.
	(grub_nilfs2_entries_per_block): Replaced with ...
	(grub_nilfs2_log_entries_per_block_log): ... this.
	(grub_nilfs2_blocks_per_group): Replaced with ...
	(grub_nilfs2_blocks_per_group_log): ... this.
	(grub_nilfs2_blocks_per_desc_block): Replaced with ...
	(grub_nilfs2_blocks_per_desc_block_log): ... this.
	(grub_nilfs2_palloc_desc_block_offset): Replaced with ...
	(grub_nilfs2_palloc_desc_block_offset_log): ... this.
	(grub_nilfs2_palloc_entry_offset): Replaced ...
	(grub_nilfs2_palloc_entry_offset_log): ... this. Use shifts.
	(grub_nilfs2_dat_translate): Use shifts.
	(grub_nilfs2_read_inode): Likewise.
	(GRUB_MOD_INIT): Ensure that logs are correct.
2011-10-28 16:21:18 +02:00
Vladimir 'phcoder' Serbinenko
564dd58c2a Use shifts in minix filesystem.
* grub-core/fs/minix.c (GRUB_MINIX_ZONESZ): Use log_block_size.
	(GRUB_MINIX_ZONE2SECT): Likewise.
	(grub_minix_data): Replace block_size with log_block_size.
	(grub_minix_read_file): Use shifts.
	(grub_minix_mount): Check block size and take a logarithm.
2011-10-28 16:09:20 +02:00
Vladimir 'phcoder' Serbinenko
ed9ba06dd0 Use shifts in squash4.
* grub-core/fs/squash4.c (grub_squash_data): New field log2_blksz.
	(squash_mount): Check block size and take logarithm.
	(direct_read): Use shifts.
2011-10-28 16:05:16 +02:00
Vladimir 'phcoder' Serbinenko
ad03fe768e Correct befs block counting logic.
* grub-core/fs/afs.c (GRUB_AFS_BLOCKS_PER_DI_RUN): Replaced with...
	(GRUB_AFS_LOG_BLOCKS_PER_DI_RUN): ... this.
	(GRUB_AFS_BLOCKRUN_LOG_SIZE): New definition.
	(grub_afs_read_inode): Use block_shift.
	(RANGE_SHIFT): New definition.
	(grub_afs_read_block): Account for RANGE_SHIFT, emit errors on
	unexpected conditions, use shifts and appropriate types.
	(GRUB_MOD_INIT): Check the value of GRUB_AFS_BLOCKRUN_LOG_SIZE.
2011-10-28 15:59:47 +02:00
Vladimir 'phcoder' Serbinenko
5b1ae25f06 Support BFS (befs) UUID.
* grub-core/fs/afs.c (grub_afs_inode): Make small_data zero-size.
	(grub_afs_small_data_element_header): New struct.
	(grub_afs_read_inode): Read complete inode. Fix ino type while on it.
	(grub_afs_read_attribute) [MODE_BFS]: New function.
	(grub_afs_iterate_dir): Allocate for complete inode.
	(grub_afs_mount): Likewise.
	(grub_afs_uuid) [MODE_BFS]: New function.
	(grub_afs_fs) [MODE_BFS]: Add .uuid.
2011-10-27 20:58:52 +02:00
Vladimir 'phcoder' Serbinenko
f8d82408d9 * grub-core/fs/zfs/zfs.c (read_device): Silence spurious warning.
(zfs_unmount): Fix memory leak.
2011-10-27 20:55:09 +02:00
Vladimir 'phcoder' Serbinenko
5773fb6410 Support NTFS reparse points.
* grub-core/fs/ntfs.c (list_file): Set symlink type when appropriate.
	(symlink_descriptor): New struct.
	(grub_ntfs_read_symlink): New function.
	(grub_ntfs_iterate_dir): Use grub_ntfs_read_symlink.
	(grub_ntfs_open): Likewise.
2011-10-27 03:04:27 +02:00
Vladimir 'phcoder' Serbinenko
91c3fdde0d * include/grub/ntfs.h: Add GRUB_NTFS_ prefix. All users updated. 2011-10-27 02:59:45 +02:00
Vladimir 'phcoder' Serbinenko
52a050751b * grub-core/fs/nilfs2.c (grub_nilfs2_uuid): Add missing field length. 2011-10-27 02:52:54 +02:00
Vladimir 'phcoder' Serbinenko
1869edb5bc ZFS multi-device and version 33 support.
* Makefile.util.def (libgrubkern): Add grub-core/fs/zfs/zfsinfo.c.
	* grub-core/fs/zfs/zfs.c (grub_zfs_device_desc): New struct.
	(grub_zfs_data): Add multidev-ice-related fields.
	(zio_checksum_verify): Zero-pad printed values. Print checksum name.
	(dva_get_offset): Make dva const.
	(zfs_fetch_nvlist): New function.
	(fill_vdev_info_real): Likewise.
	(fill_vdev_info): Likewise.
	(check_pool_label): Likewise.
	(scan_disk): Likewise.
	(scan_devices): Likewise.
	(read_device): Likewise.
	(read_dva): Likewise.
	(zio_read_gang): Use read_dva.
	(zio_read_data): Likewise.
	(zap_leaf_lookup): Add missing endian conversion.
	(zap_verify): Add missing endian conversion. All users updated.
	(fzap_lookup): Likewise.
	(fzap_iterate): Likewise.
	(dnode_get_path): Handle SA bonus.
	(nvlist_find_value): Make input const. All users updated.
	(unmount_device): New function.
	(zfs_unmount): Use unmount_device.
	(zfs_mount): Use scan_disk.
	(zfs_mtime): New function.
	(grub_zfs_open): Handle system attributes.
	(fill_fs_info): Likewise.
	(grub_zfs_dir): Likewise.
	(grub_zfs_fs): Add mtime.
	* grub-core/fs/zfs/zfsinfo.c (print_vdev_info): Add missing return.
	* include/grub/zfs/sa_impl.h (SA_TYPE_OFFSET): New definition.
	(SA_MTIME_OFFSET): Likewise.
	(SA_SYMLINK_OFFSET): Likewise.
	* include/grub/zfs/zfs.h (SPA_VERSION): Increase to 33.
	* util/grub-fstest.c (CMD_ZFSINFO): New enum value.
	(fstest): Support zfsinfo.
	(argp_parser): Likewise.
2011-10-27 02:49:50 +02:00
Vladimir 'phcoder' Serbinenko
8563e2a670 Small multidevice fix 2011-10-27 02:36:10 +02:00
Vladimir 'phcoder' Serbinenko
34c5965451 Support version 33 including symlinks 2011-10-27 02:04:04 +02:00
Vladimir 'phcoder' Serbinenko
11e50e923a merge mainline into zfs 2011-10-26 19:26:24 +02:00
Vladimir 'phcoder' Serbinenko
5587329c91 ZFS fixes.
* grub-core/fs/zfs/zfs.c (fzap_iterate): Fix handling of indexes
	sharing the same block. Iterate over correct number of indices.
	(dnode_get_path): Handle symlinks correctly.
2011-10-26 17:32:21 +02:00
Vladimir 'phcoder' Serbinenko
c0584900ee * grub-core/fs/jfs.c (grub_jfs_sblock): Fix offset to volname. 2011-10-26 00:35:41 +02:00
Vladimir 'phcoder' Serbinenko
67e2bd718e Read label on HFS+.
* grub-core/fs/hfsplus.c (grub_hfsplus_cmp_catkey_id): New function.
	(grub_hfsplus_btree_search): Fix types.
	(grub_hfsplus_label): Implement.
2011-10-26 00:32:17 +02:00
Vladimir 'phcoder' Serbinenko
e9cc6b7b0e * grub-core/fs/ntfs.c (grub_ntfs_uuid): Fix a memory leak. 2011-10-26 00:29:46 +02:00
Vladimir 'phcoder' Serbinenko
19832ddb37 * grub-core/fs/fat.c (grub_fat_uuid): Make uppercase to match Linux. 2011-10-25 21:53:57 +02:00
Vladimir 'phcoder' Serbinenko
66b4085033 Fix symlink handling on iso9660.
* grub-core/fs/iso9660.c (grub_fshelp_node): Remove dir_off. Add symlink
	All users updated.
	(grub_iso9660_susp_iterate): Accept zero-size iterate.
	(grub_iso9660_read_symlink): Moved most of code ...
	(grub_iso9660_iterate_dir): ... here. Fill node->symlink.
2011-10-25 21:52:48 +02:00
Vladimir 'phcoder' Serbinenko
e12119495d Support multi-extent iso files.
* grub-core/fs/iso9660.c (grub_iso9660_data): Remove first_sector.
	Add node.
	(grub_fshelp_node): Revamp. All users updated.
	(FLAG_*): New enum.
	(read_node): New function.
	(grub_iso9660_susp_iterate): Use read_node. Receive a node as argument.
	All users updated.
	(grub_iso9660_mount): Don't attempt to read sua when there is none.
	(get_node_size): New function.
	(grub_iso9660_iterate_dir): Use read_node. Agglomerate multi-extent
	entries.
	Fix memory leak on . and ..
	(grub_iso9660_read): Use read_node.
	(grub_iso9660_close): Free node.
2011-10-25 18:18:58 +02:00
Vladimir 'phcoder' Serbinenko
d4888031f2 Fix tar 4G limit and handle paths containing dot.
* grub-core/fs/cpio.c (grub_cpio_data): Use grub_off_t for offsets.
	(canonicalize): New function.
	(grub_cpio_find_file): Use canonicalize. Store offs in
	grub_disk_addr_t.
	(grub_cpio_dir): Use grub_disk_addr_t.
	(grub_cpio_open): Likewise.
2011-10-25 18:12:36 +02:00
Vladimir 'phcoder' Serbinenko
9f12e664cc Fix handling of uncompressed blocks on squashfs and break 4G limit.
* grub-core/fs/squash4.c (grub_squash_super): Add block_size. Remove
	unused flags.
	(grub_squash_inode): Add long_file and block_size.
	(grub_squash_cache_inode): New struct.
	(grub_squash_dirent): Make types into enum.
	(SQUASH_TYPE_LONG_REGULAR): New type.
	(grub_squash_frag_desc): Add field size.
	(SQUASH_BLOCK_FLAGS): New enum.
	(grub_squash_data): Use grub_squash_cache_inode.
	(grub_fshelp_node): Make ino_chunk 64-bit.
	(read_chunk): Minor argument change. All users updated.
	(squash_mount): Use correct le_to_cpu.
	(grub_squash_open): Handle LONG_REGULAR.
	(direct_read): New function.
	(grub_squash_read_data): Handle blocks correctly.
2011-10-25 18:09:00 +02:00
Vladimir 'phcoder' Serbinenko
f4d9b64bba * grub-core/fs/romfs.c (grub_romfs_open): Add missing return. 2011-10-25 17:38:22 +02:00
Vladimir 'phcoder' Serbinenko
5bbd28b8ce Fix 2G limit on ZFS.
* grub-core/fs/zfs/zfs.c (zio_checksum_verify): Use more appropriate
	types.
	(uberblock_verify): Likewise.
	(dmu_read): Likewise.
	(grub_zfs_read): Likewise. Remove invalid cast.
2011-10-24 21:33:35 +02:00
Vladimir 'phcoder' Serbinenko
68c72069d9 * grub-core/fs/jfs.c (grub_jfs_blkno): Use more appropriate types.
(grub_jfs_blkno): Fix incorrect shift.
	(grub_jfs_read_file): Use more appropriate types.
2011-10-24 17:02:02 +02:00
Vladimir 'phcoder' Serbinenko
6e536dc8ad Support triple indirect on minix2 and minix3.
* grub-core/fs/minix.c (grub_minix_inode) [MODE_MINIX2 || MODE_MINIX3]:
	Declare triple_indir_zone.
	(grub_minix_get_file_block) [MODE_MINIX2 || MODE_MINIX3]: Handle triple
	indirect.
2011-10-24 16:16:28 +02:00
Vladimir 'phcoder' Serbinenko
e0864e7ab7 Minix FS fixes.
* grub-core/fs/minix.c (GRUB_MINIX_INODE_SIZE): Size is always 32-bit.
	(grub_minix_inode) [!MODE_MINIX2 && !MODE_MINIX3]: Make size 32-bit.
	Rename ctime to mtime. All users updated.
	(grub_minix_get_file_block): Fix types and double indirect computations.
2011-10-24 10:45:47 +02:00
Vladimir 'phcoder' Serbinenko
89481cabbd * grub-core/fs/fat.c (grub_fat_label) [MODE_EXFAT]: Set *label to 0
if no label is found.
	(grub_fat_iterate_dir): Fix file size type.
	(grub_fat_iterate_dir): Likewise.
2011-10-24 01:31:06 +02:00
Vladimir 'phcoder' Serbinenko
a374751b16 ExFAT support.
* Makefile.util.def (libgrubmods.a): Add grub-core/fs/exfat.c.
	* grub-core/Makefile.core.def (exfat): New module.
	* grub-core/fs/exfat.c: New file.
	* grub-core/fs/fat.c (GRUB_FAT_DIR_ENTRY_SIZE): Removed.
	(GRUB_FAT_ATTR_*): Make into an enum.
	(GRUB_FAT_ATTR_LONG_NAME) [MODE_EXFAT]: Removed.
	(GRUB_FAT_ATTR_VALID) [MODE_EXFAT]: Remove GRUB_FAT_ATTR_VOLUME_ID.
	(GRUB_FAT_ATTR_VOLUME_ID) [MODE_EXFAT]: Removed.
	(GRUB_FAT_MAXFILE): Removed.
	(grub_exfat_bpb) [MODE_EXFAT]: New struct.
	(grub_current_fat_bpb_t): New type.
	(grub_fat_dir_entry) [MODE_EXFAT]: New struct.
	(grub_fat_dir_node) [MODE_EXFAT]: New struct.
	(grub_fat_dir_node_t): New type.
	(grub_fat_data) [MODE_EXFAT]: Remove root_sector and num_root_sectors.
	(fat_log2) [MODE_EXFAT]: Removed.
	(grub_fat_mount): Use grub_current_fat_bpb_t. Add some sanity checks.
	(grub_fat_mount) [MODE_EXFAT]: Handle ExFAT.
	(grub_fat_iterate_dir) [MODE_EXFAT]: New function.
	(grub_fat_find_dir) [MODE_EXFAT]: Handle ExFAT.
	(grub_fat_label) [MODE_EXFAT]: New function.
	(grub_fat_fs) [MODE_EXFAT]: Set name to "exfat" and
	reserved_first_sector to 0.
2011-10-19 20:19:25 +02:00
Vladimir 'phcoder' Serbinenko
366e34fa5a Fix few obvious type discrepancies.
* grub-core/fs/affs.c (grub_affs_read_file): Use grub_off_t for offset.
	* grub-core/fs/afs.c (grub_afs_read_file): Likewise.
	* grub-core/fs/fshelp.c (grub_fshelp_find_file): Remove leftover
	variable.
	* grub-core/fs/hfs.c (grub_hfs_read_file): Use grub_off_t for offset
	and connected types.
	* grub-core/fs/nilfs2.c (grub_nilfs2_read_file): Use grub_off_t for
	offset.
	(grub_nilfs2_iterate_dir): Use grub_off_t for fpos.
	* grub-core/fs/sfs.c (grub_sfs_read_file): Use grub_off_t for offset.
	* grub-core/fs/ufs.c (grub_ufs_read_file): Use grub_off_t for offset
	and connected types.
2011-10-16 11:57:48 +02:00
Vladimir 'phcoder' Serbinenko
3b619ae116 * grub-core/fs/xfs.c (grub_xfs_inode): New field fork_offset.
(GRUB_XFS_INO_AGBITS): Make into inline function.
	(GRUB_XFS_INO_INOINAG): Likewise.
	(GRUB_XFS_INO_AG): Likewise.
	(GRUB_XFS_FSB_TO_BLOCK): Likewise.
	(GRUB_XFS_EXTENT_OFFSET): Likewise.
	(GRUB_XFS_EXTENT_BLOCK): Likewise.
	(GRUB_XFS_EXTENT_SIZE): Likewise.
	(GRUB_XFS_ROUND_TO_DIRENT): Likewise.
	(GRUB_XFS_NEXT_DIRENT): Likewise.
	(grub_xfs_read_block): Rewrite the btree parsing. Fixes invalid BMAP.
	(grub_xfs_read_file): Fix offset type.
2011-10-16 11:48:54 +02:00
Vladimir 'phcoder' Serbinenko
d891955241 Fix overflow with >2GiB file on HFS+. >4GiB wasn't tested.
* grub-core/fs/hfsplus.c (grub_hfsplus_btree): Use more appropriate
	types.
	(grub_hfsplus_btree_recoffset): Likewise.
	(grub_hfsplus_btree_recptr): Likewise.
	(grub_hfsplus_find_block): Likewise.
	(grub_hfsplus_btree_search): Likewise.
	(grub_hfsplus_read_block): Likewise.
	(grub_hfsplus_read_file): Likewise.
	(grub_hfsplus_mount): Likewise.
	(grub_hfsplus_btree_iterate_node): Likewise.
	(grub_hfsplus_btree_search): Likewise.
	(grub_hfsplus_iterate_dir): Likewise.
	(grub_hfsplus_read): A small code simplification.
2011-10-14 22:41:21 +02:00
Szymon Janc
0e2b7e39f2 * grub-core/fs/btrfs.c: Include <minilzo.h> instead of "minilzo.h".
* grub-core/io/lzopio.c: Likewise.
2011-10-03 22:25:06 +02:00
Szymon Janc
139d67a82f * grub-core/fs/btrfs.c: Fix code style regressions. 2011-10-03 21:50:32 +02:00
Szymon Janc
579c12fbb4 * grub-core/fs/btrfs.c: Some minor cleanups. 2011-08-24 11:24:10 +02:00
Szymon Janc
00b98c9b2e * grub-core/fs/btrfs.c (grub_btrfs_lzo_decompress): Random fixes and some
cleanup.
2011-08-23 19:49:01 +02:00
Szymon Janc
540c000f0d merge trunk 2011-08-20 09:49:15 +02:00
Szymon Janc
4334690fbf More work on LZO for btrfs support. Some fixes and code refactoring. 2011-08-20 02:05:08 +02:00
Vladimir 'phcoder' Serbinenko
43526629e5 * grub-core/fs/jfs.c (grub_jfs_read_file): New parameter ino.
All users updated.
	(grub_jfs_lookup_symlink): Use correct starting inode.
2011-08-16 23:10:38 +02:00
Szymon Janc
095f077e6d Add support for LZO compression in btrfs.
* Makefile.util.def (libgrubmods.a): Add minilzo.c and add required flags
to cflags in cppflags.
* Makefile.core.def (btrfs): Likewise.
* grub-core/fs/btrfs.c: Include minilzo.h.
(grub_btrfs_superblock): Add sectorsize, nodesize, leafsize, stripsize and
dummy5 field.
(GRUB_BTRFS_COMPRESSION_LZO): New define.
(grub_btrfs_extent_read): Add support for LZO compression type.
2011-08-14 11:46:05 +02:00
Szymon Janc
b6085f3236 * grub-core/fs/btrfs.c: Some code style fixes. 2011-08-14 11:42:53 +02:00
Yves Blusseau
9e322ce8de Display the path of the file when file is not found
* grub-core/fs/fat.c: Display the filename when file is not found.
	* grub-core/fs/fshelp.c: Likewise.
	* grub-core/fs/hfs.c: Likewise.
	* grub-core/fs/jfs.c: Likewise.
	* grub-core/fs/minix.c: Likewise.
	* grub-core/fs/ufs.c: Likewise.
	* grub-core/fs/btrfs.c: Likewise.
	* grub-core/commands/i386/pc/play.c: Likewise.
2011-06-26 21:48:52 +02:00
Szymon Janc
cbf597afb1 * grub-core/commands/cmp.c (grub_cmd_cmp): Remove unnecessary NULL
pointer checks before calling grub_free().
	* grub-core/commands/wildcard.c (match_devices): Likewise.
	* grub-core/commands/wildcard.c (match_files): Likewise.
	* grub-core/fs/cpio.c (grub_cpio_dir): Likewise.
	* grub-core/fs/cpio.c (grub_cpio_open): Likewise.
	* grub-core/fs/udf.c (grub_udf_read_block): Likewise.
	* grub-core/fs/xfs.c (grub_xfs_read_block): Likewise.
	* grub-core/loader/efi/chainloader.c (grub_cmd_chainloader): Likewise.
	* grub-core/normal/cmdline.c (grub_cmdline_get): Likewise.
	* grub-core/script/yylex.l (grub_lexer_unput): Likewise.
	* grub-core/video/readers/jpeg.c (grub_video_reader_jpeg): Likewise.
	* grub-core/video/readers/png.c (grub_png_output_byte): Likewise.
2011-06-26 17:17:41 +02:00
Manoel Rebelo Abranches
90162423e9 Network infrastructure.
The ARP protocol was made by Paulo Pinatti <ppinatti@br.ibm.com>

	* include/grub/net/arp.h: New file.
	* include/grub/net/device.h: Likewise.
	* include/grub/net/ethernet.h: Likewise.
	* include/grub/net/ip.h: Likewise.
	* include/grub/net/netbuff.h: Likewise.
	* include/grub/net/tftp.h: Likewise.
	* include/grub/net/udp.h: Likewise.
	* include/grub/ieee1275/ofnet.h: Likewise.
	* include/grub/emu/export.h: Likewise.
	* include/grub/net.h: Likewise.
	* grub-core/net/arp.c: Likewise.
	* grub-core/net/ethernet.c: Likewise.
	* grub-core/net/ip.c: Likewise.
	* grub-core/net/udp.c: Likewise.
	* grub-core/net/tftp.c: Likewise.
	* grub-core/net/netbuff.c: Likewise.
	* grub-core/net/net.c: Likewise.
	* grub-core/net/drivers/emu/emunet.c: Likewise.
	* grub-core/net/drivers/ieee1275/ofnet.c: Likewise.
	* grub-core/Makefile.am (KERNEL_HEADER_FILES): Add net.h, ofnet.h and
	export.h.
	* grub-core/Makefile.core.def (net): New module.
	(tftp): Likewise.
	(ofnet): Likewise.
	(emunet): Likewise.
	* grub-core/commands/ls.c (grub_ls_list_devices) [!GRUB_UTIL]: List
	network protocols.
	* grub-core/kern/device.c (grub_net_open) : New variable.
	(grub_device_open): Handle network device.
	(grub_device_close): Likewise.
	* grub-core/kern/file.c (grub_file_net_seek) : New variable.
	(grub_grubnet_fini): Likewise.
	(grub_file_seek): Seek in network device.
	* grub-core/kern/fs.c (grub_fs_probe): Handle network devices.
	* grub-core/kern/ieee1275/init.c (grub_machine_set_prefix): Handle
	network root.
	(grub_machine_fini): Call grub_grubnet_fini.
	* grub-core/kern/ieee1275/openfw.c (grub_ieee1275_parse_args): Handle
	network.
	(grub_ieee1275_get_aliasdevname): New function.
	* grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_get_mbi_size):
	Add unofficial Solaris network info.
	(grub_multiboot_make_mbi): Likewise.
	* grub-core/fs/i386/pc/pxe.c: Moved from here ...
	* grub-core/net/i386/pc/pxe.c: ...here. Adapted for new design.
	* include/grub/device.h (grub_fs): Removed.
	* include/grub/err.h (grub_err_t): Add network-related values.
	* include/grub/i386/pc/pxe.h: Removed bootp parts.
	* include/grub/ieee1275/ieee1275.h (grub_ofnetcard_data): New struct.
	(grub_ieee1275_get_aliasdevname): New proto.
	* include/grub/net.h: Rewritten.

	Also-By: Paulo Pinatti <ppinatti@br.ibm.com>

	Also-By: Vladimir Serbinenko <phcoder@gmail.com>
2011-06-24 22:16:05 +02:00
Vladimir 'phcoder' Serbinenko
98e2f50661 * grub-core/fs/iso9660.c (grub_iso9660_iterate_dir): Skip . and .. 2011-06-24 13:02:49 +02:00
Vladimir 'phcoder' Serbinenko
290766fb77 ZFS zlib support
* grub-core/fs/zfs/zfs.c (zlib_decompress): New function.
	(decomp_table): Add zlib entries.
	(zio_read): USe 8 bits for compression function rather than 3.
	* include/grub/zfs/zio.h (zio_compress): Add zlib values.
2011-06-24 00:31:29 +02:00
Vladimir 'phcoder' Serbinenko
005dd67cb6 * grub-core/disk/ahci.c: Add missing license statements.
* grub-core/fs/romfs.c: Likewise.
	* grub-core/lib/ia64/setjmp.S: Likewise.
	* grub-core/loader/i386/pc/freedos.c: Likewise.
	* grub-core/loader/ia64/efi/linux.c: Likewise.
	* grub-core/video/colors.c: Likewise.
	* include/grub/dl.h (GRUB_MOD_DEP): New macro.
2011-06-24 00:29:21 +02:00
Manoel R. Abranches
85fd555441 Merge Mainline. 2011-05-27 00:23:33 -03:00
Colin Watson
09728256a8 * grub-core/fs/squash4.c: Add missing GRUB_MOD_LICENSE. 2011-05-18 17:16:59 +02:00
Vladimir 'phcoder' Serbinenko
bf947d36e3 Use full 64-bit division.
* grub-core/kern/misc.c (grub_divmod64_full): Renamed to ...
	(grub_divmod64): ... this.
	* include/grub/misc.h (grub_divmod64): Removed. All users switch to full
	version.
2011-05-18 15:35:19 +02:00
Vladimir 'phcoder' Serbinenko
1e4b43901a * grub-core/fs/fat.c: Include grub/fat.h.
(grub_fat_bpb): Moved to ...
	* include/grub/fat.h (grub_fat_bpb): ... here. New file.
	* grub-core/loader/i386/pc/chainloader.c: Include grub/fat.h and
	grub/ntfs.h.
	* include/grub/i386/pc/chainloader.h (grub_chainloader_flags_t):
	Moved from here...
	* grub-core/loader/i386/pc/chainloader.c (grub_chainloader_flags_t): ...
	here.
	* grub-core/loader/i386/pc/chainloader.c (grub_chainloader_patch_bpb):
	New function.
	(grub_chainloader_cmd): Patch BPB if --bpb is given.
	(GRUB_MOD_INIT): Show --bpb.
	* grub-core/loader/i386/pc/ntldr.c (grub_cmd_ntldr): Patch BPB.
	* grub-core/normal/main.c (features): New variable.
	(GRUB_MOD_INIT): Set feature_* variables.
	* include/grub/i386/pc/chainloader.h (grub_chainloader_patch_bpb): New
	proto.
	* include/grub/ntfs.h (grub_ntfs_bpb): New field bios_drive.
2011-05-18 12:48:14 +02:00
Vladimir 'phcoder' Serbinenko
b756f75f07 Several FS mtime support.
* grub-core/fs/affs.c (grub_affs_time): New struct.
	(grub_affs_file): New field mtime.
	(grub_fshelp_node): Changed 'block' and 'parent' to more appropriate
	type. Removed 'size'. New field 'di'. All users updated.
	(grub_affs_mount): Simplify checsum checking.
	(grub_affs_iterate_dir): New helper grub_affs_create_node.
	(grub_affs_dir): Handle mtime.
	* grub-core/fs/cpio.c (grub_cpio_find_file): Handle mtime.
	(grub_cpio_dir): Likewise.
	* grub-core/fs/hfs.c (grub_hfs_dirrec): New fields 'ctime' and 'mtime'.
	(grub_hfs_filerec): New field mtime.
	(grub_hfs_dir): Handle mtime.
	(grub_hfs_mtime): New function.
	(grub_hfs_fs): Register grub_hfs_mtime.
	* grub-core/fs/iso9660.c (grub_iso9660_date2): New struct.
	(grub_iso9660_dir): New field mtime.
	(grub_fshelp_node): New field dirent.
	(iso9660_to_unixtime): New function.
	(iso9660_to_unixtime2): Likewise.
	(grub_iso9660_read_symlink): Use node->dirent.
	(grub_iso9660_iterate_dir): Likewise.
	(grub_iso9660_dir): Set mtime.
	(grub_iso9660_mtime): New function.
	(grub_iso9660_fs): Register grub_iso9660_mtime.
	* grub-core/fs/jfs.c (grub_jfs_time): New struct.
	(grub_jfs_inode): New fields atime, ctime and mtime.
	(grub_jfs_dir): Set mtime.
	* grub-core/fs/minix.c (grub_minix_dir): Likewise.
	* grub-core/fs/ntfs.c (list_file): Set mtime.
	(grub_ntfs_dir): Likewise.
	* grub-core/fs/reiserfs.c (grub_fshelp_node): New field 'mtime'.
	(grub_reiserfs_iterate_dir): Set mtime.
	(grub_reiserfs_dir): Likewise.
	* grub-core/fs/sfs.c (grub_sfs_obj): New field mtime.
	(grub_fshelp_node): Likewise.
	(grub_sfs_iterate_dir): Set mtime.
	(grub_sfs_dir): Likewise.
	* grub-core/fs/udf.c (grub_udf_dir): Set mtime.
	* grub-core/fs/xfs.c (grub_xfs_time): New struct.
	(grub_xfs_inode): New fields atime, mtime, ctime.
	(grub_xfs_dir): Set mtime.
	* include/grub/datetime.h (grub_datetime2unixtime): New function.
	* include/grub/hfs.h (grub_hfs_sblock): New fields ctime and mtime.
	* include/grub/ntfs.h (grub_fshelp_node): New field mtime.

	Support UDF symlinks.

	* grub-core/fs/udf.c (grub_udf_iterate_dir): Handle symlinks.
	(grub_ufs_read_symlink): New function. All users updated.

	Check amiga partmap checksum.

	* grub-core/partmap/amiga.c (grub_amiga_rdsk): Pad to 128 bytes.
	(grub_amiga_partition): Likewise.
	(amiga_partition_map_checksum): New function.
	(amiga_partition_map_iterate): Check checksum.
2011-05-15 12:23:54 +02:00
Vladimir 'phcoder' Serbinenko
5470225d58 ROMFS support.
* Makefile.util.def (libgrubmods.a): Add romfs.
	* grub-core/Makefile.core.def (romfs): New module.
	* grub-core/fs/romfs.c: New file.
2011-05-15 12:01:03 +02:00
Vladimir 'phcoder' Serbinenko
d4680a3556 Squashfs v4 support.
* Makefile.util.def (libgrubmods.a): Add squash4.
	* grub-core/Makefile.core.def (squash4): New module.
	* grub-core/fs/squash4.c: New file.
	* grub-core/io/gzio.c (grub_gzio): New members disk_input_off,
	disk_input_start, disk_input.
	(get_byte): Handle disk_input.
	(grub_zlib_disk_read): New function.
	* include/grub/deflate.h (grub_zlib_disk_read): New proto.
2011-05-15 11:58:22 +02:00
Feiran Zheng
bcb18e748f * Makefile.util.def (libgrubmods.a): Add minix3.
* grub-core/Makefile.core.def (minix3): New module.
	* grub-core/fs/minix.c (GRUB_MINIX_MAGIC) [MODE_MINIX3]: New value.
	(GRUB_MINIX_BSIZE): Removed.
	(GRUB_MINIX_INODE_DIR_BLOCKS): New definition. All users updated.
	(grub_minix_ino_t): New type.
	(grub_minix_le_to_cpu_ino): New macro.
	(GRUB_MINIX_ZONE2SECT): New definition. All users updated.
	(grub_minix_sblock) [MODE_MINIX3]: Change for minix3.
	(grub_minix_data): New field block_size.
	(grub_minix_read_file): Handle 64-bit correctly.
	* grub-core/fs/minix3.c: New file.

	Also-By: Vladimir Serbinenko <phcoder@gmail.com>
2011-05-15 11:53:16 +02:00
Vladimir 'phcoder' Serbinenko
983b414d77 * grub-core/fs/btrfs.c (grub_btrfs_read_logical): Silence spurious
warning. Move variables before code while on it.
2011-05-15 10:23:02 +02:00