Re: [PATCH V3 01/17] Squashfs: inode operations

2009-01-07 Thread Geert Uytterhoeven
On Mon, 5 Jan 2009, Phillip Lougher wrote:
 diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c
 new file mode 100644
 index 000..7a63398
 --- /dev/null
 +++ b/fs/squashfs/inode.c
 @@ -0,0 +1,346 @@

 +int squashfs_read_inode(struct inode *inode, long long ino)
 +{
 + struct super_block *sb = inode-i_sb;
 + struct squashfs_sb_info *msblk = sb-s_fs_info;
 + u64 block = SQUASHFS_INODE_BLK(ino) + msblk-inode_table;
^^^

 + TRACE(File inode %x:%x, start_block %llx, block_list_start 
 
 + %llx, offset %x\n, SQUASHFS_INODE_BLK(ino),
 
 + offset, squashfs_i(inode)-start, block, offset);

Note that I get lots of

| warning: format '%llx' expects type 'long long unsigned int', but argument 3 
has type 'u64'

on ppc64, since you switched from `unsigned long long' to 'u64', as `u64' is
(still -- this is being changed) `unsigned long' on pp64.

I guess no action has to be taken, for now?

With kind regards,

Geert Uytterhoeven
Software Architect

Sony Techsoft Centre Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium

Phone:+32 (0)2 700 8453
Fax:  +32 (0)2 700 8622
E-mail:   geert.uytterhoe...@sonycom.com
Internet: http://www.sony-europe.com/

A division of Sony Europe (Belgium) N.V.
VAT BE 0413.825.160 · RPR Brussels
Fortis · BIC GEBABEBB · IBAN BE41293037680010
--
To unsubscribe from this list: send the line unsubscribe linux-embedded in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V3 01/17] Squashfs: inode operations

2009-01-07 Thread Stephen Rothwell
Hi Geert,

On Wed, 7 Jan 2009 19:00:24 +0100 (CET) Geert Uytterhoeven 
geert.uytterhoe...@sonycom.com wrote:

 Note that I get lots of
 
 | warning: format '%llx' expects type 'long long unsigned int', but argument 
 3 has type 'u64'
 
 on ppc64, since you switched from `unsigned long long' to 'u64', as `u64' is
 (still -- this is being changed) `unsigned long' on pp64.
 
 I guess no action has to be taken, for now?

Correct, as we are in the process of changing u64 to unsigned long long for
powerpc.
-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/


pgpjU8K9LPVQg.pgp
Description: PGP signature


[PATCH V3 01/17] Squashfs: inode operations

2009-01-05 Thread Phillip Lougher

Signed-off-by: Phillip Lougher phil...@lougher.demon.co.uk
---
 fs/squashfs/inode.c |  346 +++
 1 files changed, 346 insertions(+), 0 deletions(-)

diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c
new file mode 100644
index 000..7a63398
--- /dev/null
+++ b/fs/squashfs/inode.c
@@ -0,0 +1,346 @@
+/*
+ * Squashfs - a compressed read only filesystem for Linux
+ *
+ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ * Phillip Lougher phil...@lougher.demon.co.uk
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * inode.c
+ */
+
+/*
+ * This file implements code to create and read inodes from disk.
+ *
+ * Inodes in Squashfs are identified by a 48-bit inode which encodes the
+ * location of the compressed metadata block containing the inode, and the byte
+ * offset into that block where the inode is placed (block, offset).
+ *
+ * To maximise compression there are different inodes for each file type
+ * (regular file, directory, device, etc.), the inode contents and length
+ * varying with the type.
+ *
+ * To further maximise compression, two types of regular file inode and
+ * directory inode are defined: inodes optimised for frequently occurring
+ * regular files and directories, and extended types where extra
+ * information has to be stored.
+ */
+
+#include linux/fs.h
+#include linux/vfs.h
+#include linux/zlib.h
+
+#include squashfs_fs.h
+#include squashfs_fs_sb.h
+#include squashfs_fs_i.h
+#include squashfs.h
+
+/*
+ * Initialise VFS inode with the base inode information common to all
+ * Squashfs inode types.  Sqsh_ino contains the unswapped base inode
+ * off disk.
+ */
+static int squashfs_new_inode(struct super_block *sb, struct inode *inode,
+   struct squashfs_base_inode *sqsh_ino)
+{
+   int err;
+
+   err = squashfs_get_id(sb, le16_to_cpu(sqsh_ino-uid), inode-i_uid);
+   if (err)
+   return err;
+
+   err = squashfs_get_id(sb, le16_to_cpu(sqsh_ino-guid), inode-i_gid);
+   if (err)
+   return err;
+
+   inode-i_ino = le32_to_cpu(sqsh_ino-inode_number);
+   inode-i_mtime.tv_sec = le32_to_cpu(sqsh_ino-mtime);
+   inode-i_atime.tv_sec = inode-i_mtime.tv_sec;
+   inode-i_ctime.tv_sec = inode-i_mtime.tv_sec;
+   inode-i_mode = le16_to_cpu(sqsh_ino-mode);
+   inode-i_size = 0;
+
+   return err;
+}
+
+
+struct inode *squashfs_iget(struct super_block *sb, long long ino,
+   unsigned int ino_number)
+{
+   struct inode *inode = iget_locked(sb, ino_number);
+   int err;
+
+   TRACE(Entered squashfs_iget\n);
+
+   if (!inode)
+   return ERR_PTR(-ENOMEM);
+   if (!(inode-i_state  I_NEW))
+   return inode;
+
+   err = squashfs_read_inode(inode, ino);
+   if (err) {
+   iget_failed(inode);
+   return ERR_PTR(err);
+   }
+
+   unlock_new_inode(inode);
+   return inode;
+}
+
+
+/*
+ * Initialise VFS inode by reading inode from inode table (compressed
+ * metadata).  The format and amount of data read depends on type.
+ */
+int squashfs_read_inode(struct inode *inode, long long ino)
+{
+   struct super_block *sb = inode-i_sb;
+   struct squashfs_sb_info *msblk = sb-s_fs_info;
+   u64 block = SQUASHFS_INODE_BLK(ino) + msblk-inode_table;
+   int err, type, offset = SQUASHFS_INODE_OFFSET(ino);
+   union squashfs_inode squashfs_ino;
+   struct squashfs_base_inode *sqshb_ino = squashfs_ino.base;
+
+   TRACE(Entered squashfs_read_inode\n);
+
+   /*
+* Read inode base common to all inode types.
+*/
+   err = squashfs_read_metadata(sb, sqshb_ino, block,
+   offset, sizeof(*sqshb_ino));
+   if (err  0)
+   goto failed_read;
+
+   err = squashfs_new_inode(sb, inode, sqshb_ino);
+   if (err)
+   goto failed_read;
+
+   block = SQUASHFS_INODE_BLK(ino) + msblk-inode_table;
+   offset = SQUASHFS_INODE_OFFSET(ino);
+
+   type = le16_to_cpu(sqshb_ino-inode_type);
+   switch (type) {
+   case SQUASHFS_REG_TYPE: {
+   unsigned int frag_offset, frag_size, frag;
+   u64 frag_blk;
+   struct squashfs_reg_inode *sqsh_ino = 

Re: [PATCH V3 01/17] Squashfs: inode operations

2009-01-05 Thread Evgeniy Polyakov
Hi.

On Mon, Jan 05, 2009 at 11:08:23AM +, Phillip Lougher 
(phil...@lougher.demon.co.uk) wrote:
 +int squashfs_read_inode(struct inode *inode, long long ino)
 +{
 + struct super_block *sb = inode-i_sb;
 + struct squashfs_sb_info *msblk = sb-s_fs_info;
 + u64 block = SQUASHFS_INODE_BLK(ino) + msblk-inode_table;
 + int err, type, offset = SQUASHFS_INODE_OFFSET(ino);
 + union squashfs_inode squashfs_ino;
 + struct squashfs_base_inode *sqshb_ino = squashfs_ino.base;
 +

What's the size of that union? If big enough it will lead to some
problems.

 + TRACE(Entered squashfs_read_inode\n);
 +
 + /*
 +  * Read inode base common to all inode types.
 +  */
 + err = squashfs_read_metadata(sb, sqshb_ino, block,
 + offset, sizeof(*sqshb_ino));
 + if (err  0)
 + goto failed_read;
 +
 + err = squashfs_new_inode(sb, inode, sqshb_ino);
 + if (err)
 + goto failed_read;
 +
 + block = SQUASHFS_INODE_BLK(ino) + msblk-inode_table;
 + offset = SQUASHFS_INODE_OFFSET(ino);
 +
 + type = le16_to_cpu(sqshb_ino-inode_type);
 + switch (type) {
 + case SQUASHFS_REG_TYPE: {
 + unsigned int frag_offset, frag_size, frag;
 + u64 frag_blk;

Above variables can be moved out of the switch, since they are used in
some other cases too.

-- 
Evgeniy Polyakov
--
To unsubscribe from this list: send the line unsubscribe linux-embedded in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html