| 1 |
/* PR rtl-optimization/45593 */ |
| 2 |
/* Testcase by Arnaud Lacombe <[email protected]> */ |
| 3 |
/* { dg-additional-options "-fpermissive" } */ |
| 4 |
|
| 5 |
typedef unsigned int __u32; |
| 6 |
typedef __u32 __be32; |
| 7 |
static inline __attribute__((always_inline)) int __attribute__((__cold__)) printk(const char *s, ...) { return 0; } |
| 8 |
typedef struct journal_s journal_t; |
| 9 |
typedef struct journal_header_s |
| 10 |
{ |
| 11 |
__be32 h_magic; |
| 12 |
__be32 h_blocktype; |
| 13 |
__be32 h_sequence; |
| 14 |
} journal_header_t; |
| 15 |
typedef struct journal_superblock_s |
| 16 |
{ |
| 17 |
journal_header_t s_header; |
| 18 |
__be32 s_blocksize; |
| 19 |
__be32 s_maxlen; |
| 20 |
} journal_superblock_t; |
| 21 |
struct journal_s |
| 22 |
{ |
| 23 |
struct buffer_head *j_sb_buffer; |
| 24 |
journal_superblock_t *j_superblock; |
| 25 |
int j_format_version; |
| 26 |
int j_blocksize; |
| 27 |
unsigned int j_maxlen; |
| 28 |
}; |
| 29 |
static void journal_fail_superblock (journal_t *journal) |
| 30 |
{ |
| 31 |
journal->j_sb_buffer = ((void *)0); |
| 32 |
} |
| 33 |
static int journal_get_superblock(journal_t *journal) |
| 34 |
{ |
| 35 |
struct buffer_head *bh; |
| 36 |
journal_superblock_t *sb; |
| 37 |
int err = -100; |
| 38 |
bh = journal->j_sb_buffer; |
| 39 |
if (!buffer_uptodate(bh)) { |
| 40 |
if (!buffer_uptodate(bh)) { |
| 41 |
printk ("JBD: IO error reading journal superblock\n"); |
| 42 |
goto out; |
| 43 |
} |
| 44 |
} |
| 45 |
err = -101; |
| 46 |
if (sb->s_header.h_magic != (( __be32)(__u32)(0)) || |
| 47 |
sb->s_blocksize != (( __be32)(__u32)(journal->j_blocksize))) { |
| 48 |
printk("JBD: no valid journal superblock found\n"); |
| 49 |
goto out; |
| 50 |
} |
| 51 |
switch((( __u32)(__be32)(sb->s_header.h_blocktype))) { |
| 52 |
case 0: |
| 53 |
case 1: |
| 54 |
break; |
| 55 |
default: |
| 56 |
goto out; |
| 57 |
} |
| 58 |
if ((( __u32)(__be32)(sb->s_maxlen)) < journal->j_maxlen) |
| 59 |
journal->j_maxlen = (( __u32)(__be32)(sb->s_maxlen)); |
| 60 |
else if ((( __u32)(__be32)(sb->s_maxlen)) > journal->j_maxlen) { |
| 61 |
printk ("JBD: journal file too short\n"); |
| 62 |
goto out; |
| 63 |
} |
| 64 |
return 0; |
| 65 |
out: |
| 66 |
journal_fail_superblock(journal); |
| 67 |
return err; |
| 68 |
} |
| 69 |
static int load_superblock(journal_t *journal) |
| 70 |
{ |
| 71 |
journal_get_superblock(journal); |
| 72 |
return 0; |
| 73 |
} |
| 74 |
int jbd2_journal_update_format (journal_t *journal) |
| 75 |
{ |
| 76 |
journal_get_superblock(journal); |
| 77 |
return 0; |
| 78 |
} |
| 79 |
int jbd2_journal_wipe(journal_t *journal, int write) |
| 80 |
{ |
| 81 |
load_superblock(journal); |
| 82 |
return 0; |
| 83 |
} |