From: Andrei Borzenkov <arvidjaar@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>,
linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [PATCH v3] F2FS support
Date: Mon, 14 Dec 2015 11:28:26 +0300 [thread overview]
Message-ID: <566E7DAA.4010202@gmail.com> (raw)
In-Reply-To: <20151119212824.GA11666@jaegeuk.local>
20.11.2015 00:28, Jaegeuk Kim пишет:
> Hello,
>
> Change log from v2:
> o Enhance the code quality suggested by Andrei
>
> Sorry for the long delay.
> Could you please check this patch?
>
> Thank you so much,
>
Thank you for continuing to work on it!
...
> +
> +static inline int
> +grub_generic_test_bit (int nr, const grub_uint32_t *addr)
> +{
> + return 1UL & (addr[nr / 32] >> (nr & 31));
> +}
> +
As already discussed this code is wrong on big-endian platform. On-disk
bitmap is little-endian and kernel explicitly uses test_bit_le() here.
> +static inline char *
> +__inline_addr (struct grub_f2fs_inode *inode)
> +{
> + return (char *)&inode->i_addr[1];
> +}
> +
> +static inline grub_uint64_t
> +grub_f2fs_file_size (struct grub_f2fs_inode *inode)
> +{
> + return grub_le_to_cpu64 (inode->i_size);
> +}
> +
> +static inline grub_uint32_t
> +__start_cp_addr (struct grub_f2fs_data *data)
> +{
> + struct grub_f2fs_checkpoint *ckpt = &data->ckpt;
> + grub_uint64_t ckpt_version = grub_le_to_cpu64 (ckpt->checkpoint_ver);
> + grub_uint32_t start_addr = data->cp_blkaddr;
> +
> + if (!(ckpt_version & 1))
This can use grub_cpu_to_le64_compile_time (1)
...
> +static inline int
> +grub_f2fs_test_bit (grub_uint32_t nr, const char *p)
> +{
> + int mask;
> +
> + p += (nr >> 3);
> + mask = 1 << (7 - (nr & 0x07));
> + return (mask & *p) != 0;
This is really just "return mask & *p".
> +}
> +
> +static int
> +grub_f2fs_sanity_check_sb (struct grub_f2fs_superblock *sb)
> +{
> + grub_uint32_t log_sectorsize, log_sectors_per_block;
> +
> + if (sb->magic != grub_cpu_to_le32_compile_time (F2FS_SUPER_MAGIC))
> + return -1;
> +
> + if (sb->log_blocksize != grub_cpu_to_le32_compile_time (F2FS_BLK_BITS))
> + return -1;
> +
> + log_sectorsize = grub_le_to_cpu32 (sb->log_sectorsize);
> + log_sectors_per_block = grub_le_to_cpu32 (sb->log_sectors_per_block);
> +
> + if (log_sectorsize > F2FS_MAX_LOG_SECTOR_SIZE)
> + return -1;
> +
> + if (log_sectorsize < F2FS_MIN_LOG_SECTOR_SIZE)
> + return -1;
> +
> + if (log_sectors_per_block + log_sectorsize != F2FS_MAX_LOG_SECTOR_SIZE)
This sounds like it should actually be F2FS_BLK_BITS; at least assuming
that F2FS_MAX_LOG_SECTOR_SIZE may differ from F2FS_BLK_BITS.
...
> +
> +static grub_ssize_t
> +grub_f2fs_read_file (grub_fshelp_node_t node,
> + grub_disk_read_hook_t read_hook, void *read_hook_data,
> + grub_off_t pos, grub_size_t len, char *buf)
> +{
> + struct grub_f2fs_inode *inode = &node->inode.i;
> + grub_off_t filesize = grub_f2fs_file_size (inode);
> + char *inline_addr = __inline_addr (inode);
> +
> + if (inode->i_inline & F2FS_INLINE_DATA)
> + {
> + if (pos > filesize || filesize > MAX_INLINE_DATA)
> + {
> + grub_error (GRUB_ERR_BAD_FS, "corrupted inline_data: need fsck");
Sorry for confusion, my fault. pos > filesize was OK, but filesize >
MAX_INLINE_DATA not.
...
> +
> +/* TODO: mkfs.f2fs stores label in a wrong way. Should be fixed. */
> +static void
> +grub_f2fs_unicode_to_ascii (grub_uint8_t *out_buf, grub_uint16_t *in_buf)
> +{
> + grub_uint16_t *pchTempPtr = in_buf;
> + grub_uint8_t *pwTempPtr = out_buf;
> +
> + while (*pchTempPtr != '\0')
> + {
> + *pwTempPtr = (grub_uint8_t) *pchTempPtr;
> + pchTempPtr++;
> + pwTempPtr++;
> + }
> + *pwTempPtr = '\0';
> + return;
> +}
Sorry, I do not see how it can work on both big and little endian
platforms. What byte order is used for on-disk label? Why cannot you use
grub_utf16_to_utf8 as I asked last time?
Also please add bundary check, do not rely on correct content.
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
next prev parent reply other threads:[~2015-12-14 8:28 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-24 8:19 [PATCH] F2FS support Jaegeuk Kim
2015-03-28 7:31 ` Andrei Borzenkov
2015-03-28 20:43 ` Jaegeuk Kim
2015-03-28 21:00 ` Andrei Borzenkov
2015-04-03 22:48 ` Jaegeuk Kim
2015-04-03 22:49 ` [PATCH v2] " Jaegeuk Kim
2015-04-29 20:48 ` [f2fs-dev] " Jaegeuk Kim
2015-04-30 3:32 ` Andrei Borzenkov
2015-05-02 17:15 ` Andrei Borzenkov
2015-05-03 6:28 ` Andrei Borzenkov
2015-11-19 21:28 ` [PATCH v3] " Jaegeuk Kim
2015-12-14 8:28 ` Andrei Borzenkov [this message]
2015-12-15 0:30 ` Jaegeuk Kim
2015-12-15 0:34 ` [PATCH v4] " Jaegeuk Kim
2015-12-15 8:34 ` Andrei Borzenkov
2015-12-15 18:08 ` Jaegeuk Kim
2015-12-15 18:14 ` [PATCH v5] " Jaegeuk Kim
2016-01-07 19:37 ` [f2fs-dev] " Michael Zimmermann
2016-01-08 19:41 ` [PATCH v6] " Jaegeuk Kim
2016-02-22 9:25 ` Andrei Borzenkov
2016-02-22 18:21 ` [f2fs-dev] " Jaegeuk Kim
2016-02-22 18:25 ` [PATCH v7] " Jaegeuk Kim
2016-03-01 19:52 ` [2.02] Re: [f2fs-dev] " Andrei Borzenkov
2016-03-02 23:20 ` Michael Zimmermann
2016-03-03 21:35 ` [2.02] " Jaegeuk Kim
2016-03-03 21:36 ` [2.02] Re: [f2fs-dev] [PATCH v8] " Jaegeuk Kim
2016-08-04 17:06 ` [2.02] " Jaegeuk Kim
2016-08-05 10:57 ` Andrei Borzenkov
2016-08-05 18:07 ` Jaegeuk Kim
2016-08-05 19:17 ` [f2fs-dev] " Michael Zimmermann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=566E7DAA.4010202@gmail.com \
--to=arvidjaar@gmail.com \
--cc=grub-devel@gnu.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).