Commit 1d372116 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] rock: lindent it

Trying to turn rock.c into something which humans can read so we can fix some
bugs.

Start out by feeding it through scripts/Lindent.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 8a966191
......@@ -22,7 +22,6 @@
#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) \
......@@ -85,44 +84,50 @@
}}
/* return length of name field; 0: not found, -1: to be ignored */
int get_rock_ridge_filename(struct iso_directory_record * de,
char * retname, struct inode * inode)
int get_rock_ridge_filename(struct iso_directory_record *de,
char *retname, struct inode *inode)
{
int len;
unsigned char * chr;
unsigned char *chr;
CONTINUE_DECLS;
int retnamlen = 0, truncate=0;
int retnamlen = 0, truncate = 0;
if (!ISOFS_SB(inode->i_sb)->s_rock) return 0;
if (!ISOFS_SB(inode->i_sb)->s_rock)
return 0;
*retname = 0;
SETUP_ROCK_RIDGE(de, chr, len);
repeat:
{
struct rock_ridge * rr;
struct rock_ridge *rr;
int sig;
while (len > 2){ /* There may be one byte for padding somewhere */
rr = (struct rock_ridge *) chr;
if (rr->len < 3) goto out; /* Something got screwed up here */
while (len > 2) { /* There may be one byte for padding somewhere */
rr = (struct rock_ridge *)chr;
if (rr->len < 3)
goto out; /* Something got screwed up here */
sig = isonum_721(chr);
chr += rr->len;
len -= rr->len;
if (len < 0) goto out; /* corrupted isofs */
if (len < 0)
goto out; /* corrupted isofs */
switch(sig){
case SIG('R','R'):
if((rr->u.RR.flags[0] & RR_NM) == 0) goto out;
switch (sig) {
case SIG('R', 'R'):
if ((rr->u.RR.flags[0] & RR_NM) == 0)
goto out;
break;
case SIG('S','P'):
case SIG('S', 'P'):
CHECK_SP(goto out);
break;
case SIG('C','E'):
case SIG('C', 'E'):
CHECK_CE;
break;
case SIG('N','M'):
if (truncate) break;
if (rr->len < 5) break;
case SIG('N', 'M'):
if (truncate)
break;
if (rr->len < 5)
break;
/*
* If the flags are 2 or 4, this indicates '.' or '..'.
* We don't want to do anything with this, because it
......@@ -135,29 +140,34 @@ int get_rock_ridge_filename(struct iso_directory_record * de,
}
if (rr->u.NM.flags & ~1) {
printk("Unsupported NM flag settings (%d)\n",rr->u.NM.flags);
printk
("Unsupported NM flag settings (%d)\n",
rr->u.NM.flags);
break;
}
if((strlen(retname) + rr->len - 5) >= 254) {
if ((strlen(retname) + rr->len - 5) >= 254) {
truncate = 1;
break;
}
strncat(retname, rr->u.NM.name, rr->len - 5);
retnamlen += rr->len - 5;
break;
case SIG('R','E'):
if (buffer) kfree(buffer);
case SIG('R', 'E'):
if (buffer)
kfree(buffer);
return -1;
default:
break;
}
}
}
MAYBE_CONTINUE(repeat,inode);
if (buffer) kfree(buffer);
MAYBE_CONTINUE(repeat, inode);
if (buffer)
kfree(buffer);
return retnamlen; /* If 0, this file did not have a NM field */
out:
if(buffer) kfree(buffer);
if (buffer)
kfree(buffer);
return 0;
}
......@@ -166,64 +176,71 @@ parse_rock_ridge_inode_internal(struct iso_directory_record *de,
struct inode *inode, int regard_xa)
{
int len;
unsigned char * chr;
unsigned char *chr;
int symlink_len = 0;
CONTINUE_DECLS;
if (!ISOFS_SB(inode->i_sb)->s_rock) return 0;
if (!ISOFS_SB(inode->i_sb)->s_rock)
return 0;
SETUP_ROCK_RIDGE(de, chr, len);
if (regard_xa)
{
chr+=14;
len-=14;
if (len<0) len=0;
if (regard_xa) {
chr += 14;
len -= 14;
if (len < 0)
len = 0;
}
repeat:
{
int cnt, sig;
struct inode * reloc;
struct rock_ridge * rr;
struct inode *reloc;
struct rock_ridge *rr;
int rootflag;
while (len > 2){ /* There may be one byte for padding somewhere */
rr = (struct rock_ridge *) chr;
if (rr->len < 3) goto out; /* Something got screwed up here */
while (len > 2) { /* There may be one byte for padding somewhere */
rr = (struct rock_ridge *)chr;
if (rr->len < 3)
goto out; /* Something got screwed up here */
sig = isonum_721(chr);
chr += rr->len;
len -= rr->len;
if (len < 0) goto out; /* corrupted isofs */
if (len < 0)
goto out; /* corrupted isofs */
switch(sig){
switch (sig) {
#ifndef CONFIG_ZISOFS /* No flag for SF or ZF */
case SIG('R','R'):
if((rr->u.RR.flags[0] &
(RR_PX | RR_TF | RR_SL | RR_CL)) == 0) goto out;
case SIG('R', 'R'):
if ((rr->u.RR.flags[0] &
(RR_PX | RR_TF | RR_SL | RR_CL)) == 0)
goto out;
break;
#endif
case SIG('S','P'):
case SIG('S', 'P'):
CHECK_SP(goto out);
break;
case SIG('C','E'):
case SIG('C', 'E'):
CHECK_CE;
break;
case SIG('E','R'):
case SIG('E', 'R'):
ISOFS_SB(inode->i_sb)->s_rock = 1;
printk(KERN_DEBUG "ISO 9660 Extensions: ");
{ int p;
for(p=0;p<rr->u.ER.len_id;p++) printk("%c",rr->u.ER.data[p]);
{
int p;
for (p = 0; p < rr->u.ER.len_id; p++)
printk("%c", rr->u.ER.data[p]);
}
printk("\n");
break;
case SIG('P','X'):
case SIG('P', 'X'):
inode->i_mode = isonum_733(rr->u.PX.mode);
inode->i_nlink = isonum_733(rr->u.PX.n_links);
inode->i_uid = isonum_733(rr->u.PX.uid);
inode->i_gid = isonum_733(rr->u.PX.gid);
break;
case SIG('P','N'):
{ int high, low;
case SIG('P', 'N'):
{
int high, low;
high = isonum_733(rr->u.PN.dev_high);
low = isonum_733(rr->u.PN.dev_low);
/*
......@@ -233,46 +250,58 @@ parse_rock_ridge_inode_internal(struct iso_directory_record *de,
* and as a result we test to see if the entire device number is
* stored in the low field, and use that.
*/
if((low & ~0xff) && high == 0) {
inode->i_rdev = MKDEV(low >> 8, low & 0xff);
if ((low & ~0xff) && high == 0) {
inode->i_rdev =
MKDEV(low >> 8, low & 0xff);
} else {
inode->i_rdev = MKDEV(high, low);
inode->i_rdev =
MKDEV(high, low);
}
}
break;
case SIG('T','F'):
case SIG('T', 'F'):
/* Some RRIP writers incorrectly place ctime in the TF_CREATE field.
Try to handle this correctly for either case. */
cnt = 0; /* Rock ridge never appears on a High Sierra disk */
if(rr->u.TF.flags & TF_CREATE) {
inode->i_ctime.tv_sec = iso_date(rr->u.TF.times[cnt++].time, 0);
if (rr->u.TF.flags & TF_CREATE) {
inode->i_ctime.tv_sec =
iso_date(rr->u.TF.times[cnt++].time,
0);
inode->i_ctime.tv_nsec = 0;
}
if(rr->u.TF.flags & TF_MODIFY) {
inode->i_mtime.tv_sec = iso_date(rr->u.TF.times[cnt++].time, 0);
if (rr->u.TF.flags & TF_MODIFY) {
inode->i_mtime.tv_sec =
iso_date(rr->u.TF.times[cnt++].time,
0);
inode->i_mtime.tv_nsec = 0;
}
if(rr->u.TF.flags & TF_ACCESS) {
inode->i_atime.tv_sec = iso_date(rr->u.TF.times[cnt++].time, 0);
if (rr->u.TF.flags & TF_ACCESS) {
inode->i_atime.tv_sec =
iso_date(rr->u.TF.times[cnt++].time,
0);
inode->i_atime.tv_nsec = 0;
}
if(rr->u.TF.flags & TF_ATTRIBUTES) {
inode->i_ctime.tv_sec = iso_date(rr->u.TF.times[cnt++].time, 0);
if (rr->u.TF.flags & TF_ATTRIBUTES) {
inode->i_ctime.tv_sec =
iso_date(rr->u.TF.times[cnt++].time,
0);
inode->i_ctime.tv_nsec = 0;
}
break;
case SIG('S','L'):
{int slen;
struct SL_component * slp;
struct SL_component * oldslp;
case SIG('S', 'L'):
{
int slen;
struct SL_component *slp;
struct SL_component *oldslp;
slen = rr->len - 5;
slp = &rr->u.SL.link;
inode->i_size = symlink_len;
while (slen > 1){
while (slen > 1) {
rootflag = 0;
switch(slp->flags &~1){
switch (slp->flags & ~1) {
case 0:
inode->i_size += slp->len;
inode->i_size +=
slp->len;
break;
case 2:
inode->i_size += 1;
......@@ -285,33 +314,48 @@ parse_rock_ridge_inode_internal(struct iso_directory_record *de,
inode->i_size += 1;
break;
default:
printk("Symlink component flag not implemented\n");
printk
("Symlink component flag not implemented\n");
}
slen -= slp->len + 2;
oldslp = slp;
slp = (struct SL_component *) (((char *) slp) + slp->len + 2);
slp =
(struct SL_component
*)(((char *)slp) +
slp->len + 2);
if(slen < 2) {
if( ((rr->u.SL.flags & 1) != 0)
&& ((oldslp->flags & 1) == 0) ) inode->i_size += 1;
if (slen < 2) {
if (((rr->u.SL.
flags & 1) != 0)
&&
((oldslp->
flags & 1) == 0))
inode->i_size +=
1;
break;
}
/*
* If this component record isn't continued, then append a '/'.
*/
if (!rootflag && (oldslp->flags & 1) == 0)
if (!rootflag
&& (oldslp->flags & 1) == 0)
inode->i_size += 1;
}
}
symlink_len = inode->i_size;
break;
case SIG('R','E'):
printk(KERN_WARNING "Attempt to read inode for relocated directory\n");
case SIG('R', 'E'):
printk(KERN_WARNING
"Attempt to read inode for relocated directory\n");
goto out;
case SIG('C','L'):
ISOFS_I(inode)->i_first_extent = isonum_733(rr->u.CL.location);
reloc = isofs_iget(inode->i_sb, ISOFS_I(inode)->i_first_extent, 0);
case SIG('C', 'L'):
ISOFS_I(inode)->i_first_extent =
isonum_733(rr->u.CL.location);
reloc =
isofs_iget(inode->i_sb,
ISOFS_I(inode)->i_first_extent,
0);
if (!reloc)
goto out;
inode->i_mode = reloc->i_mode;
......@@ -327,25 +371,47 @@ parse_rock_ridge_inode_internal(struct iso_directory_record *de,
iput(reloc);
break;
#ifdef CONFIG_ZISOFS
case SIG('Z','F'):
if ( !ISOFS_SB(inode->i_sb)->s_nocompress ) {
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);
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;
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);
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]);
printk(KERN_WARNING
"isofs: Unknown ZF compression algorithm: %c%c\n",
rr->u.ZF.algorithm[0],
rr->u.ZF.algorithm[1]);
}
}
break;
......@@ -355,9 +421,10 @@ parse_rock_ridge_inode_internal(struct iso_directory_record *de,
}
}
}
MAYBE_CONTINUE(repeat,inode);
MAYBE_CONTINUE(repeat, inode);
out:
if(buffer) kfree(buffer);
if (buffer)
kfree(buffer);
return 0;
}
......@@ -376,24 +443,24 @@ static char *get_symlink_chunk(char *rpnt, struct rock_ridge *rr, char *plimit)
if (slp->len > plimit - rpnt)
return NULL;
memcpy(rpnt, slp->text, slp->len);
rpnt+=slp->len;
rpnt += slp->len;
break;
case 2:
if (rpnt >= plimit)
return NULL;
*rpnt++='.';
*rpnt++ = '.';
break;
case 4:
if (2 > plimit - rpnt)
return NULL;
*rpnt++='.';
*rpnt++='.';
*rpnt++ = '.';
*rpnt++ = '.';
break;
case 8:
if (rpnt >= plimit)
return NULL;
rootflag = 1;
*rpnt++='/';
*rpnt++ = '/';
break;
default:
printk("Symlink component flag not implemented (%d)\n",
......@@ -401,7 +468,7 @@ static char *get_symlink_chunk(char *rpnt, struct rock_ridge *rr, char *plimit)
}
slen -= slp->len + 2;
oldslp = slp;
slp = (struct SL_component *) ((char *) slp + slp->len + 2);
slp = (struct SL_component *)((char *)slp + slp->len + 2);
if (slen < 2) {
/*
......@@ -412,7 +479,7 @@ static char *get_symlink_chunk(char *rpnt, struct rock_ridge *rr, char *plimit)
!(oldslp->flags & 1)) {
if (rpnt >= plimit)
return NULL;
*rpnt++='/';
*rpnt++ = '/';
}
break;
}
......@@ -423,22 +490,20 @@ static char *get_symlink_chunk(char *rpnt, struct rock_ridge *rr, char *plimit)
if (!rootflag && !(oldslp->flags & 1)) {
if (rpnt >= plimit)
return NULL;
*rpnt++='/';
*rpnt++ = '/';
}
}
return rpnt;
}
int parse_rock_ridge_inode(struct iso_directory_record * de,
struct inode * inode)
int parse_rock_ridge_inode(struct iso_directory_record *de, struct inode *inode)
{
int result=parse_rock_ridge_inode_internal(de,inode,0);
int result = parse_rock_ridge_inode_internal(de, inode, 0);
/* if rockridge flag was reset and we didn't look for attributes
* behind eventual XA attributes, have a look there */
if ((ISOFS_SB(inode->i_sb)->s_rock_offset==-1)
&&(ISOFS_SB(inode->i_sb)->s_rock==2))
{
result=parse_rock_ridge_inode_internal(de,inode,14);
if ((ISOFS_SB(inode->i_sb)->s_rock_offset == -1)
&& (ISOFS_SB(inode->i_sb)->s_rock == 2)) {
result = parse_rock_ridge_inode_internal(de, inode, 14);
}
return result;
}
......@@ -473,9 +538,9 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page)
goto out_noread;
offset = ei->i_iget5_offset;
pnt = (unsigned char *) bh->b_data + offset;
pnt = (unsigned char *)bh->b_data + offset;
raw_inode = (struct iso_directory_record *) pnt;
raw_inode = (struct iso_directory_record *)pnt;
/*
* If we go past the end of the buffer, there is some sort of error.
......@@ -490,7 +555,7 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page)
repeat:
while (len > 2) { /* There may be one byte for padding somewhere */
rr = (struct rock_ridge *) chr;
rr = (struct rock_ridge *)chr;
if (rr->len < 3)
goto out; /* Something got screwed up here */
sig = isonum_721(chr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment