Discussion:
[PATCH 6/9] isofs: convert macro to function in rock.c
(too old to reply)
Pekka Enberg
2005-03-28 17:53:09 UTC
Permalink
This patch converts the CHECK_SP macro to a proper function in
fs/isofs/rock.c.

Signed-off-by: Pekka Enberg <***@cs.helsinki.fi>
---

rock.c | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)

Index: 2.6/fs/isofs/rock.c
===================================================================
--- 2.6.orig/fs/isofs/rock.c 2005-03-28 16:32:13.000000000 +0300
+++ 2.6/fs/isofs/rock.c 2005-03-28 16:32:16.000000000 +0300
@@ -28,15 +28,13 @@

#define SIG(A,B) ((A) | ((B) << 8)) /* isonum_721() */

-/* This is a way of ensuring that we have something in the system
- use fields that is compatible with Rock Ridge */
-#define CHECK_SP(FAIL) \
- if(rr->u.SP.magic[0] != 0xbe) FAIL; \
- if(rr->u.SP.magic[1] != 0xef) FAIL; \
- ISOFS_SB(inode->i_sb)->s_rock_offset=rr->u.SP.skip;
-/* We define a series of macros because each function must do exactly the
- same thing in certain places. We use the macros to ensure that everything
- is done correctly */
+static inline int rock_set_offset(struct inode *inode, struct rock_ridge * rr)
+{
+ if (rr->u.SP.magic[0] != 0xbe || rr->u.SP.magic[1] != 0xef)
+ return 0;
+ ISOFS_SB(inode->i_sb)->s_rock_offset = rr->u.SP.skip;
+ return 1;
+}

static int setup_rock_ridge(struct iso_directory_record *de, struct inode *inode, unsigned char ** chr)
{
@@ -92,7 +90,8 @@
goto out;
break;
case SIG('S', 'P'):
- CHECK_SP(goto out);
+ if (!rock_set_offset(inode, rr))
+ goto out;
break;
case SIG('C', 'E'):
{
@@ -225,7 +224,8 @@
break;
#endif
case SIG('S', 'P'):
- CHECK_SP(goto out);
+ if (!rock_set_offset(inode, rr))
+ goto out;
break;
case SIG('C', 'E'):
{
@@ -612,7 +612,8 @@
goto out;
break;
case SIG('S', 'P'):
- CHECK_SP(goto out);
+ if (!rock_set_offset(inode, rr))
+ goto out;
break;
case SIG('S', 'L'):
rpnt = get_symlink_chunk(rpnt, rr,
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



-------------------------------------------------------------------------------
Achtung: diese Newsgruppe ist eine unidirektional gegatete Mailingliste.
Antworten nur per Mail an die im Reply-To-Header angegebene Adresse.
Fragen zum Gateway -> ***@inka.de.
-------------------------------------------------------------------------------
Pekka Enberg
2005-03-28 17:56:33 UTC
Permalink
This patch extracts ZISOFS entry parsing to a separate function.

Signed-off-by: Pekka Enberg <***@cs.helsinki.fi>
---

rock.c | 77 +++++++++++++++++++++++++++++------------------------------------
1 files changed, 35 insertions(+), 42 deletions(-)

Index: 2.6/fs/isofs/rock.c
===================================================================
--- 2.6.orig/fs/isofs/rock.c 2005-03-28 18:26:34.000000000 +0300
+++ 2.6/fs/isofs/rock.c 2005-03-28 18:47:40.000000000 +0300
@@ -177,6 +177,40 @@
return 0;
}

+#ifdef CONFIG_ZISOFS
+static void rock_parse_zisofs_entry(struct rock_ridge *rr, struct inode *inode)
+{
+ int algo;
+
+ if (ISOFS_SB(inode->i_sb)->s_nocompress)
+ return;
+
+ algo = isonum_721(rr->u.ZF.algorithm);
+ if (algo == SIG('p', 'z')) {
+ int block_shift = isonum_711(&rr->u.ZF.parms[1]);
+ if (block_shift < PAGE_CACHE_SHIFT || block_shift > 17) {
+ printk(KERN_WARNING
+ "isofs: Can't handle ZF block size of 2^%d\n",
+ block_shift);
+ } else {
+ /* Note: we don't change i_blocks here */
+ ISOFS_I(inode)->i_file_format = isofs_file_compressed;
+ /* Parameters to compression algorithm (header size, block size) */
+ ISOFS_I(inode)->i_format_parm[0] =
+ isonum_711(&rr->u.ZF.parms[0]);
+ ISOFS_I(inode)->i_format_parm[1] =
+ isonum_711(&rr->u.ZF.parms[1]);
+ inode->i_size = isonum_733(rr->u.ZF.real_size);
+ }
+ } else {
+ printk(KERN_WARNING
+ "isofs: Unknown ZF compression algorithm: %c%c\n",
+ rr->u.ZF.algorithm[0],
+ rr->u.ZF.algorithm[1]);
+ }
+}
+#endif
+
static int
parse_rock_ridge_inode_internal(struct iso_directory_record *de,
struct inode *inode, int regard_xa)
@@ -384,48 +418,7 @@
break;
#ifdef CONFIG_ZISOFS
case SIG('Z', 'F'):
- if (!ISOFS_SB(inode->i_sb)->s_nocompress) {
- int algo;
- algo = isonum_721(rr->u.ZF.algorithm);
- if (algo == SIG('p', 'z')) {
- int block_shift =
- isonum_711(&rr->u.ZF.
- parms[1]);
- if (block_shift <
- PAGE_CACHE_SHIFT
- || block_shift > 17) {
- printk(KERN_WARNING
- "isofs: Can't handle ZF block size of 2^%d\n",
- block_shift);
- } else {
- /* Note: we don't change i_blocks here */
- ISOFS_I(inode)->
- i_file_format =
- isofs_file_compressed;
- /* Parameters to compression algorithm (header size, block size) */
- ISOFS_I(inode)->
- i_format_parm[0] =
- isonum_711(&rr->u.
- ZF.
- parms
- [0]);
- ISOFS_I(inode)->
- i_format_parm[1] =
- isonum_711(&rr->u.
- ZF.
- parms
- [1]);
- inode->i_size =
- isonum_733(rr->u.ZF.
- real_size);
- }
- } else {
- printk(KERN_WARNING
- "isofs: Unknown ZF compression algorithm: %c%c\n",
- rr->u.ZF.algorithm[0],
- rr->u.ZF.algorithm[1]);
- }
- }
+ rock_parse_zisofs_entry(rr, inode);
break;
#endif
default:
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



-------------------------------------------------------------------------------
Achtung: diese Newsgruppe ist eine unidirektional gegatete Mailingliste.
Antworten nur per Mail an die im Reply-To-Header angegebene Adresse.
Fragen zum Gateway -> ***@inka.de.
-------------------------------------------------------------------------------
Loading...