提交 cb00ea35 编写于 作者: C Cyrill Gorcunov 提交者: Linus Torvalds

UDF: coding style conversion - lindent

This patch converts UDF coding style to kernel coding style using Lindent.
Signed-off-by: NCyrill Gorcunov <gorcunov@gmail.com>
Cc: Jan Kara <jack@ucw.cz>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 95a631e2
此差异已折叠。
......@@ -79,8 +79,7 @@ static uint16_t crc_table[256] = {
* July 21, 1997 - Andrew E. Mileski
* Adapted from OSTA-UDF(tm) 1.50 standard.
*/
uint16_t
udf_crc(uint8_t *data, uint32_t size, uint16_t crc)
uint16_t udf_crc(uint8_t * data, uint32_t size, uint16_t crc)
{
while (size--)
crc = crc_table[(crc >> 8 ^ *(data++)) & 0xffU] ^ (crc << 8);
......@@ -138,7 +137,7 @@ int main(int argc, char **argv)
/* Get the polynomial */
sscanf(argv[1], "%lo", &poly);
if (poly & 0xffff0000U){
if (poly & 0xffff0000U) {
fprintf(stderr, "polynomial is too large\en");
exit(1);
}
......@@ -147,12 +146,12 @@ int main(int argc, char **argv)
/* Create a table */
printf("static unsigned short crc_table[256] = {\n");
for (n = 0; n < 256; n++){
for (n = 0; n < 256; n++) {
if (n % 8 == 0)
printf("\t");
crc = n << 8;
for (i = 0; i < 8; i++){
if(crc & 0x8000U)
for (i = 0; i < 8; i++) {
if (crc & 0x8000U)
crc = (crc << 1) ^ poly;
else
crc <<= 1;
......@@ -162,7 +161,7 @@ int main(int argc, char **argv)
printf("0x%04xU ", crc);
else
printf("0x%04xU, ", crc);
if(n % 8 == 7)
if (n % 8 == 7)
printf("\n");
}
printf("};\n");
......
......@@ -82,14 +82,13 @@ int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
lock_kernel();
if ( filp->f_pos == 0 )
{
if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) < 0)
{
if (filp->f_pos == 0) {
if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) <
0) {
unlock_kernel();
return 0;
}
filp->f_pos ++;
filp->f_pos++;
}
result = do_udf_readdir(dir, filp, filldir, dirent);
......@@ -98,10 +97,11 @@ int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
}
static int
do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *dirent)
do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
void *dirent)
{
struct udf_fileident_bh fibh;
struct fileIdentDesc *fi=NULL;
struct fileIdentDesc *fi = NULL;
struct fileIdentDesc cfi;
int block, iblock;
loff_t nf_pos = filp->f_pos - 1;
......@@ -117,7 +117,7 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
sector_t offset;
int i, num;
unsigned int dt_type;
struct extent_position epos = { NULL, 0, {0, 0}};
struct extent_position epos = { NULL, 0, {0, 0} };
if (nf_pos >= size)
return 0;
......@@ -125,65 +125,61 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
if (nf_pos == 0)
nf_pos = (udf_ext0_offset(dir) >> 2);
fibh.soffset = fibh.eoffset = (nf_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
fibh.soffset = fibh.eoffset =
(nf_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
fibh.sbh = fibh.ebh = NULL;
else if (inode_bmap(dir, nf_pos >> (dir->i_sb->s_blocksize_bits - 2),
&epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30))
{
&epos, &eloc, &elen,
&offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
block = udf_get_lb_pblock(dir->i_sb, eloc, offset);
if ((++offset << dir->i_sb->s_blocksize_bits) < elen)
{
if ((++offset << dir->i_sb->s_blocksize_bits) < elen) {
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
epos.offset -= sizeof(short_ad);
else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
epos.offset -= sizeof(long_ad);
}
else
} else
offset = 0;
if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block)))
{
if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) {
brelse(epos.bh);
return -EIO;
}
if (!(offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9))-1)))
{
if (!(offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1))) {
i = 16 >> (dir->i_sb->s_blocksize_bits - 9);
if (i+offset > (elen >> dir->i_sb->s_blocksize_bits))
i = (elen >> dir->i_sb->s_blocksize_bits)-offset;
for (num=0; i>0; i--)
{
block = udf_get_lb_pblock(dir->i_sb, eloc, offset+i);
if (i + offset > (elen >> dir->i_sb->s_blocksize_bits))
i = (elen >> dir->i_sb->s_blocksize_bits) -
offset;
for (num = 0; i > 0; i--) {
block =
udf_get_lb_pblock(dir->i_sb, eloc,
offset + i);
tmp = udf_tgetblk(dir->i_sb, block);
if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp))
if (tmp && !buffer_uptodate(tmp)
&& !buffer_locked(tmp))
bha[num++] = tmp;
else
brelse(tmp);
}
if (num)
{
if (num) {
ll_rw_block(READA, num, bha);
for (i=0; i<num; i++)
for (i = 0; i < num; i++)
brelse(bha[i]);
}
}
}
else
{
} else {
brelse(epos.bh);
return -ENOENT;
}
while ( nf_pos < size )
{
while (nf_pos < size) {
filp->f_pos = nf_pos + 1;
fi = udf_fileident_read(dir, &nf_pos, &fibh, &cfi, &epos, &eloc, &elen, &offset);
fi = udf_fileident_read(dir, &nf_pos, &fibh, &cfi, &epos, &eloc,
&elen, &offset);
if (!fi)
{
if (!fi) {
if (fibh.sbh != fibh.ebh)
brelse(fibh.ebh);
brelse(fibh.sbh);
......@@ -196,43 +192,41 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
if (fibh.sbh == fibh.ebh)
nameptr = fi->fileIdent + liu;
else
{
else {
int poffset; /* Unpaded ending offset */
poffset = fibh.soffset + sizeof(struct fileIdentDesc) + liu + lfi;
poffset =
fibh.soffset + sizeof(struct fileIdentDesc) + liu +
lfi;
if (poffset >= lfi)
nameptr = (char *)(fibh.ebh->b_data + poffset - lfi);
else
{
nameptr =
(char *)(fibh.ebh->b_data + poffset - lfi);
else {
nameptr = fname;
memcpy(nameptr, fi->fileIdent + liu, lfi - poffset);
memcpy(nameptr + lfi - poffset, fibh.ebh->b_data, poffset);
memcpy(nameptr, fi->fileIdent + liu,
lfi - poffset);
memcpy(nameptr + lfi - poffset,
fibh.ebh->b_data, poffset);
}
}
if ( (cfi.fileCharacteristics & FID_FILE_CHAR_DELETED) != 0 )
{
if ( !UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNDELETE) )
if ((cfi.fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) {
if (!UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNDELETE))
continue;
}
if ( (cfi.fileCharacteristics & FID_FILE_CHAR_HIDDEN) != 0 )
{
if ( !UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNHIDE) )
if ((cfi.fileCharacteristics & FID_FILE_CHAR_HIDDEN) != 0) {
if (!UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNHIDE))
continue;
}
if ( cfi.fileCharacteristics & FID_FILE_CHAR_PARENT )
{
if (cfi.fileCharacteristics & FID_FILE_CHAR_PARENT) {
iblock = parent_ino(filp->f_path.dentry);
flen = 2;
memcpy(fname, "..", flen);
dt_type = DT_DIR;
}
else
{
} else {
kernel_lb_addr tloc = lelb_to_cpu(cfi.icb.extLocation);
iblock = udf_get_lb_pblock(dir->i_sb, tloc, 0);
......@@ -240,10 +234,10 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
dt_type = DT_UNKNOWN;
}
if (flen)
{
if (filldir(dirent, fname, flen, filp->f_pos, iblock, dt_type) < 0)
{
if (flen) {
if (filldir
(dirent, fname, flen, filp->f_pos, iblock,
dt_type) < 0) {
if (fibh.sbh != fibh.ebh)
brelse(fibh.ebh);
brelse(fibh.sbh);
......
......@@ -19,10 +19,10 @@
#include <linux/buffer_head.h>
#if 0
static uint8_t *
udf_filead_read(struct inode *dir, uint8_t *tmpad, uint8_t ad_size,
kernel_lb_addr fe_loc, int *pos, int *offset,
struct buffer_head **bh, int *error)
static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad,
uint8_t ad_size, kernel_lb_addr fe_loc,
int *pos, int *offset, struct buffer_head **bh,
int *error)
{
int loffset = *offset;
int block;
......@@ -31,31 +31,27 @@ udf_filead_read(struct inode *dir, uint8_t *tmpad, uint8_t ad_size,
*error = 0;
ad = (uint8_t *)(*bh)->b_data + *offset;
ad = (uint8_t *) (*bh)->b_data + *offset;
*offset += ad_size;
if (!ad)
{
if (!ad) {
brelse(*bh);
*error = 1;
return NULL;
}
if (*offset == dir->i_sb->s_blocksize)
{
if (*offset == dir->i_sb->s_blocksize) {
brelse(*bh);
block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos);
if (!block)
return NULL;
if (!(*bh = udf_tread(dir->i_sb, block)))
return NULL;
}
else if (*offset > dir->i_sb->s_blocksize)
{
} else if (*offset > dir->i_sb->s_blocksize) {
ad = tmpad;
remainder = dir->i_sb->s_blocksize - loffset;
memcpy((uint8_t *)ad, (*bh)->b_data + loffset, remainder);
memcpy((uint8_t *) ad, (*bh)->b_data + loffset, remainder);
brelse(*bh);
block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos);
......@@ -64,47 +60,47 @@ udf_filead_read(struct inode *dir, uint8_t *tmpad, uint8_t ad_size,
if (!((*bh) = udf_tread(dir->i_sb, block)))
return NULL;
memcpy((uint8_t *)ad + remainder, (*bh)->b_data, ad_size - remainder);
memcpy((uint8_t *) ad + remainder, (*bh)->b_data,
ad_size - remainder);
*offset = ad_size - remainder;
}
return ad;
}
#endif
struct fileIdentDesc *
udf_fileident_read(struct inode *dir, loff_t *nf_pos,
struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
struct udf_fileident_bh *fibh,
struct fileIdentDesc *cfi,
struct extent_position *epos,
kernel_lb_addr *eloc, uint32_t *elen,
sector_t *offset)
kernel_lb_addr * eloc, uint32_t * elen,
sector_t * offset)
{
struct fileIdentDesc *fi;
int i, num, block;
struct buffer_head * tmp, * bha[16];
struct buffer_head *tmp, *bha[16];
fibh->soffset = fibh->eoffset;
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
{
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
fi = udf_get_fileident(UDF_I_DATA(dir) -
(UDF_I_EFE(dir) ?
sizeof(struct extendedFileEntry) :
sizeof(struct fileEntry)),
dir->i_sb->s_blocksize, &(fibh->eoffset));
dir->i_sb->s_blocksize,
&(fibh->eoffset));
if (!fi)
return NULL;
*nf_pos += ((fibh->eoffset - fibh->soffset) >> 2);
memcpy((uint8_t *)cfi, (uint8_t *)fi, sizeof(struct fileIdentDesc));
memcpy((uint8_t *) cfi, (uint8_t *) fi,
sizeof(struct fileIdentDesc));
return fi;
}
if (fibh->eoffset == dir->i_sb->s_blocksize)
{
if (fibh->eoffset == dir->i_sb->s_blocksize) {
int lextoffset = epos->offset;
if (udf_next_aext(dir, epos, eloc, elen, 1) !=
......@@ -113,7 +109,7 @@ udf_fileident_read(struct inode *dir, loff_t *nf_pos,
block = udf_get_lb_pblock(dir->i_sb, *eloc, *offset);
(*offset) ++;
(*offset)++;
if ((*offset << dir->i_sb->s_blocksize_bits) >= *elen)
*offset = 0;
......@@ -125,30 +121,32 @@ udf_fileident_read(struct inode *dir, loff_t *nf_pos,
return NULL;
fibh->soffset = fibh->eoffset = 0;
if (!(*offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9))-1)))
if (!
(*offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1)))
{
i = 16 >> (dir->i_sb->s_blocksize_bits - 9);
if (i+*offset > (*elen >> dir->i_sb->s_blocksize_bits))
i = (*elen >> dir->i_sb->s_blocksize_bits)-*offset;
for (num=0; i>0; i--)
{
block = udf_get_lb_pblock(dir->i_sb, *eloc, *offset+i);
if (i + *offset >
(*elen >> dir->i_sb->s_blocksize_bits))
i = (*elen >> dir->i_sb->s_blocksize_bits) -
*offset;
for (num = 0; i > 0; i--) {
block =
udf_get_lb_pblock(dir->i_sb, *eloc,
*offset + i);
tmp = udf_tgetblk(dir->i_sb, block);
if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp))
if (tmp && !buffer_uptodate(tmp)
&& !buffer_locked(tmp))
bha[num++] = tmp;
else
brelse(tmp);
}
if (num)
{
if (num) {
ll_rw_block(READA, num, bha);
for (i=0; i<num; i++)
for (i = 0; i < num; i++)
brelse(bha[i]);
}
}
}
else if (fibh->sbh != fibh->ebh)
{
} else if (fibh->sbh != fibh->ebh) {
brelse(fibh->sbh);
fibh->sbh = fibh->ebh;
}
......@@ -161,12 +159,10 @@ udf_fileident_read(struct inode *dir, loff_t *nf_pos,
*nf_pos += ((fibh->eoffset - fibh->soffset) >> 2);
if (fibh->eoffset <= dir->i_sb->s_blocksize)
{
memcpy((uint8_t *)cfi, (uint8_t *)fi, sizeof(struct fileIdentDesc));
}
else if (fibh->eoffset > dir->i_sb->s_blocksize)
{
if (fibh->eoffset <= dir->i_sb->s_blocksize) {
memcpy((uint8_t *) cfi, (uint8_t *) fi,
sizeof(struct fileIdentDesc));
} else if (fibh->eoffset > dir->i_sb->s_blocksize) {
int lextoffset = epos->offset;
if (udf_next_aext(dir, epos, eloc, elen, 1) !=
......@@ -175,7 +171,7 @@ udf_fileident_read(struct inode *dir, loff_t *nf_pos,
block = udf_get_lb_pblock(dir->i_sb, *eloc, *offset);
(*offset) ++;
(*offset)++;
if ((*offset << dir->i_sb->s_blocksize_bits) >= *elen)
*offset = 0;
......@@ -188,60 +184,60 @@ udf_fileident_read(struct inode *dir, loff_t *nf_pos,
if (!(fibh->ebh = udf_tread(dir->i_sb, block)))
return NULL;
if (sizeof(struct fileIdentDesc) > - fibh->soffset)
{
if (sizeof(struct fileIdentDesc) > -fibh->soffset) {
int fi_len;
memcpy((uint8_t *)cfi, (uint8_t *)fi, - fibh->soffset);
memcpy((uint8_t *)cfi - fibh->soffset, fibh->ebh->b_data,
memcpy((uint8_t *) cfi, (uint8_t *) fi, -fibh->soffset);
memcpy((uint8_t *) cfi - fibh->soffset,
fibh->ebh->b_data,
sizeof(struct fileIdentDesc) + fibh->soffset);
fi_len = (sizeof(struct fileIdentDesc) + cfi->lengthFileIdent +
fi_len =
(sizeof(struct fileIdentDesc) +
cfi->lengthFileIdent +
le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3;
*nf_pos += ((fi_len - (fibh->eoffset - fibh->soffset)) >> 2);
*nf_pos +=
((fi_len - (fibh->eoffset - fibh->soffset)) >> 2);
fibh->eoffset = fibh->soffset + fi_len;
}
else
{
memcpy((uint8_t *)cfi, (uint8_t *)fi, sizeof(struct fileIdentDesc));
} else {
memcpy((uint8_t *) cfi, (uint8_t *) fi,
sizeof(struct fileIdentDesc));
}
}
return fi;
}
struct fileIdentDesc *
udf_get_fileident(void * buffer, int bufsize, int * offset)
struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
{
struct fileIdentDesc *fi;
int lengthThisIdent;
uint8_t * ptr;
uint8_t *ptr;
int padlen;
if ( (!buffer) || (!offset) ) {
udf_debug("invalidparms\n, buffer=%p, offset=%p\n", buffer, offset);
if ((!buffer) || (!offset)) {
udf_debug("invalidparms\n, buffer=%p, offset=%p\n", buffer,
offset);
return NULL;
}
ptr = buffer;
if ( (*offset > 0) && (*offset < bufsize) ) {
if ((*offset > 0) && (*offset < bufsize)) {
ptr += *offset;
}
fi=(struct fileIdentDesc *)ptr;
if (le16_to_cpu(fi->descTag.tagIdent) != TAG_IDENT_FID)
{
fi = (struct fileIdentDesc *)ptr;
if (le16_to_cpu(fi->descTag.tagIdent) != TAG_IDENT_FID) {
udf_debug("0x%x != TAG_IDENT_FID\n",
le16_to_cpu(fi->descTag.tagIdent));
udf_debug("offset: %u sizeof: %lu bufsize: %u\n",
*offset, (unsigned long)sizeof(struct fileIdentDesc), bufsize);
*offset, (unsigned long)sizeof(struct fileIdentDesc),
bufsize);
return NULL;
}
if ( (*offset + sizeof(struct fileIdentDesc)) > bufsize )
{
if ((*offset + sizeof(struct fileIdentDesc)) > bufsize) {
lengthThisIdent = sizeof(struct fileIdentDesc);
}
else
} else
lengthThisIdent = sizeof(struct fileIdentDesc) +
fi->lengthFileIdent + le16_to_cpu(fi->lengthOfImpUse);
......@@ -255,56 +251,53 @@ udf_get_fileident(void * buffer, int bufsize, int * offset)
}
#if 0
static extent_ad *
udf_get_fileextent(void * buffer, int bufsize, int * offset)
static extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset)
{
extent_ad * ext;
extent_ad *ext;
struct fileEntry *fe;
uint8_t * ptr;
uint8_t *ptr;
if ( (!buffer) || (!offset) )
{
if ((!buffer) || (!offset)) {
printk(KERN_ERR "udf: udf_get_fileextent() invalidparms\n");
return NULL;
}
fe = (struct fileEntry *)buffer;
if ( le16_to_cpu(fe->descTag.tagIdent) != TAG_IDENT_FE )
{
if (le16_to_cpu(fe->descTag.tagIdent) != TAG_IDENT_FE) {
udf_debug("0x%x != TAG_IDENT_FE\n",
le16_to_cpu(fe->descTag.tagIdent));
return NULL;
}
ptr=(uint8_t *)(fe->extendedAttr) + le32_to_cpu(fe->lengthExtendedAttr);
ptr =
(uint8_t *) (fe->extendedAttr) +
le32_to_cpu(fe->lengthExtendedAttr);
if ( (*offset > 0) && (*offset < le32_to_cpu(fe->lengthAllocDescs)) )
{
if ((*offset > 0) && (*offset < le32_to_cpu(fe->lengthAllocDescs))) {
ptr += *offset;
}
ext = (extent_ad *)ptr;
ext = (extent_ad *) ptr;
*offset = *offset + sizeof(extent_ad);
return ext;
}
#endif
short_ad *
udf_get_fileshortad(uint8_t *ptr, int maxoffset, int *offset, int inc)
short_ad *udf_get_fileshortad(uint8_t * ptr, int maxoffset, int *offset,
int inc)
{
short_ad *sa;
if ( (!ptr) || (!offset) )
{
if ((!ptr) || (!offset)) {
printk(KERN_ERR "udf: udf_get_fileshortad() invalidparms\n");
return NULL;
}
if ( (*offset < 0) || ((*offset + sizeof(short_ad)) > maxoffset) )
if ((*offset < 0) || ((*offset + sizeof(short_ad)) > maxoffset))
return NULL;
else if ((sa = (short_ad *)ptr)->extLength == 0)
else if ((sa = (short_ad *) ptr)->extLength == 0)
return NULL;
if (inc)
......@@ -312,20 +305,18 @@ udf_get_fileshortad(uint8_t *ptr, int maxoffset, int *offset, int inc)
return sa;
}
long_ad *
udf_get_filelongad(uint8_t *ptr, int maxoffset, int * offset, int inc)
long_ad *udf_get_filelongad(uint8_t * ptr, int maxoffset, int *offset, int inc)
{
long_ad *la;
if ( (!ptr) || (!offset) )
{
if ((!ptr) || (!offset)) {
printk(KERN_ERR "udf: udf_get_filelongad() invalidparms\n");
return NULL;
}
if ( (*offset < 0) || ((*offset + sizeof(long_ad)) > maxoffset) )
if ((*offset < 0) || ((*offset + sizeof(long_ad)) > maxoffset))
return NULL;
else if ((la = (long_ad *)ptr)->extLength == 0)
else if ((la = (long_ad *) ptr)->extLength == 0)
return NULL;
if (inc)
......
......@@ -38,8 +38,7 @@
#define _ECMA_167_H 1
/* Character set specification (ECMA 167r3 1/7.2.1) */
typedef struct
{
typedef struct {
uint8_t charSetType;
uint8_t charSetInfo[63];
} __attribute__ ((packed)) charspec;
......@@ -58,8 +57,7 @@ typedef struct
typedef uint8_t dstring;
/* Timestamp (ECMA 167r3 1/7.3) */
typedef struct
{
typedef struct {
__le16 typeAndTimezone;
__le16 year;
uint8_t month;
......@@ -72,8 +70,7 @@ typedef struct
uint8_t microseconds;
} __attribute__ ((packed)) timestamp;
typedef struct
{
typedef struct {
uint16_t typeAndTimezone;
int16_t year;
uint8_t month;
......@@ -94,8 +91,7 @@ typedef struct
#define TIMESTAMP_TIMEZONE_MASK 0x0FFF
/* Entity identifier (ECMA 167r3 1/7.4) */
typedef struct
{
typedef struct {
uint8_t flags;
uint8_t ident[23];
uint8_t identSuffix[8];
......@@ -107,8 +103,7 @@ typedef struct
/* Volume Structure Descriptor (ECMA 167r3 2/9.1) */
#define VSD_STD_ID_LEN 5
struct volStructDesc
{
struct volStructDesc {
uint8_t structType;
uint8_t stdIdent[VSD_STD_ID_LEN];
uint8_t structVersion;
......@@ -127,8 +122,7 @@ struct volStructDesc
#define VSD_STD_ID_TEA01 "TEA01" /* (2/9.3) */
/* Beginning Extended Area Descriptor (ECMA 167r3 2/9.2) */
struct beginningExtendedAreaDesc
{
struct beginningExtendedAreaDesc {
uint8_t structType;
uint8_t stdIdent[VSD_STD_ID_LEN];
uint8_t structVersion;
......@@ -136,8 +130,7 @@ struct beginningExtendedAreaDesc
} __attribute__ ((packed));
/* Terminating Extended Area Descriptor (ECMA 167r3 2/9.3) */
struct terminatingExtendedAreaDesc
{
struct terminatingExtendedAreaDesc {
uint8_t structType;
uint8_t stdIdent[VSD_STD_ID_LEN];
uint8_t structVersion;
......@@ -145,8 +138,7 @@ struct terminatingExtendedAreaDesc
} __attribute__ ((packed));
/* Boot Descriptor (ECMA 167r3 2/9.4) */
struct bootDesc
{
struct bootDesc {
uint8_t structType;
uint8_t stdIdent[VSD_STD_ID_LEN];
uint8_t structVersion;
......@@ -167,21 +159,18 @@ struct bootDesc
#define BOOT_FLAGS_ERASE 0x01
/* Extent Descriptor (ECMA 167r3 3/7.1) */
typedef struct
{
typedef struct {
__le32 extLength;
__le32 extLocation;
} __attribute__ ((packed)) extent_ad;
typedef struct
{
typedef struct {
uint32_t extLength;
uint32_t extLocation;
} kernel_extent_ad;
/* Descriptor Tag (ECMA 167r3 3/7.2) */
typedef struct
{
typedef struct {
__le16 tagIdent;
__le16 descVersion;
uint8_t tagChecksum;
......@@ -204,8 +193,7 @@ typedef struct
#define TAG_IDENT_LVID 0x0009
/* NSR Descriptor (ECMA 167r3 3/9.1) */
struct NSRDesc
{
struct NSRDesc {
uint8_t structType;
uint8_t stdIdent[VSD_STD_ID_LEN];
uint8_t structVersion;
......@@ -214,8 +202,7 @@ struct NSRDesc
} __attribute__ ((packed));
/* Primary Volume Descriptor (ECMA 167r3 3/10.1) */
struct primaryVolDesc
{
struct primaryVolDesc {
tag descTag;
__le32 volDescSeqNum;
__le32 primaryVolDescNum;
......@@ -244,8 +231,7 @@ struct primaryVolDesc
#define PVD_FLAGS_VSID_COMMON 0x0001
/* Anchor Volume Descriptor Pointer (ECMA 167r3 3/10.2) */
struct anchorVolDescPtr
{
struct anchorVolDescPtr {
tag descTag;
extent_ad mainVolDescSeqExt;
extent_ad reserveVolDescSeqExt;
......@@ -253,8 +239,7 @@ struct anchorVolDescPtr
} __attribute__ ((packed));
/* Volume Descriptor Pointer (ECMA 167r3 3/10.3) */
struct volDescPtr
{
struct volDescPtr {
tag descTag;
__le32 volDescSeqNum;
extent_ad nextVolDescSeqExt;
......@@ -262,8 +247,7 @@ struct volDescPtr
} __attribute__ ((packed));
/* Implementation Use Volume Descriptor (ECMA 167r3 3/10.4) */
struct impUseVolDesc
{
struct impUseVolDesc {
tag descTag;
__le32 volDescSeqNum;
regid impIdent;
......@@ -271,8 +255,7 @@ struct impUseVolDesc
} __attribute__ ((packed));
/* Partition Descriptor (ECMA 167r3 3/10.5) */
struct partitionDesc
{
struct partitionDesc {
tag descTag;
__le32 volDescSeqNum;
__le16 partitionFlags;
......@@ -307,8 +290,7 @@ struct partitionDesc
#define PD_ACCESS_TYPE_OVERWRITABLE 0x00000004
/* Logical Volume Descriptor (ECMA 167r3 3/10.6) */
struct logicalVolDesc
{
struct logicalVolDesc {
tag descTag;
__le32 volDescSeqNum;
charspec descCharSet;
......@@ -325,8 +307,7 @@ struct logicalVolDesc
} __attribute__ ((packed));
/* Generic Partition Map (ECMA 167r3 3/10.7.1) */
struct genericPartitionMap
{
struct genericPartitionMap {
uint8_t partitionMapType;
uint8_t partitionMapLength;
uint8_t partitionMapping[0];
......@@ -338,8 +319,7 @@ struct genericPartitionMap
#define GP_PARTITION_MAP_TYPE_2 0x02
/* Type 1 Partition Map (ECMA 167r3 3/10.7.2) */
struct genericPartitionMap1
{
struct genericPartitionMap1 {
uint8_t partitionMapType;
uint8_t partitionMapLength;
__le16 volSeqNum;
......@@ -347,16 +327,14 @@ struct genericPartitionMap1
} __attribute__ ((packed));
/* Type 2 Partition Map (ECMA 167r3 3/10.7.3) */
struct genericPartitionMap2
{
struct genericPartitionMap2 {
uint8_t partitionMapType;
uint8_t partitionMapLength;
uint8_t partitionIdent[62];
} __attribute__ ((packed));
/* Unallocated Space Descriptor (ECMA 167r3 3/10.8) */
struct unallocSpaceDesc
{
struct unallocSpaceDesc {
tag descTag;
__le32 volDescSeqNum;
__le32 numAllocDescs;
......@@ -364,15 +342,13 @@ struct unallocSpaceDesc
} __attribute__ ((packed));
/* Terminating Descriptor (ECMA 167r3 3/10.9) */
struct terminatingDesc
{
struct terminatingDesc {
tag descTag;
uint8_t reserved[496];
} __attribute__ ((packed));
/* Logical Volume Integrity Descriptor (ECMA 167r3 3/10.10) */
struct logicalVolIntegrityDesc
{
struct logicalVolIntegrityDesc {
tag descTag;
timestamp recordingDateAndTime;
__le32 integrityType;
......@@ -390,52 +366,45 @@ struct logicalVolIntegrityDesc
#define LVID_INTEGRITY_TYPE_CLOSE 0x00000001
/* Recorded Address (ECMA 167r3 4/7.1) */
typedef struct
{
typedef struct {
__le32 logicalBlockNum;
__le16 partitionReferenceNum;
} __attribute__ ((packed)) lb_addr;
/* ... and its in-core analog */
typedef struct
{
typedef struct {
uint32_t logicalBlockNum;
uint16_t partitionReferenceNum;
} kernel_lb_addr;
/* Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */
typedef struct
{
typedef struct {
__le32 extLength;
__le32 extPosition;
} __attribute__ ((packed)) short_ad;
/* Long Allocation Descriptor (ECMA 167r3 4/14.14.2) */
typedef struct
{
typedef struct {
__le32 extLength;
lb_addr extLocation;
uint8_t impUse[6];
} __attribute__ ((packed)) long_ad;
typedef struct
{
typedef struct {
uint32_t extLength;
kernel_lb_addr extLocation;
uint8_t impUse[6];
} kernel_long_ad;
/* Extended Allocation Descriptor (ECMA 167r3 4/14.14.3) */
typedef struct
{
typedef struct {
__le32 extLength;
__le32 recordedLength;
__le32 informationLength;
lb_addr extLocation;
} __attribute__ ((packed)) ext_ad;
typedef struct
{
typedef struct {
uint32_t extLength;
uint32_t recordedLength;
uint32_t informationLength;
......@@ -458,8 +427,7 @@ typedef struct
#define TAG_IDENT_EFE 0x010A
/* File Set Descriptor (ECMA 167r3 4/14.1) */
struct fileSetDesc
{
struct fileSetDesc {
tag descTag;
timestamp recordingDateAndTime;
__le16 interchangeLvl;
......@@ -482,8 +450,7 @@ struct fileSetDesc
} __attribute__ ((packed));
/* Partition Header Descriptor (ECMA 167r3 4/14.3) */
struct partitionHeaderDesc
{
struct partitionHeaderDesc {
short_ad unallocSpaceTable;
short_ad unallocSpaceBitmap;
short_ad partitionIntegrityTable;
......@@ -493,8 +460,7 @@ struct partitionHeaderDesc
} __attribute__ ((packed));
/* File Identifier Descriptor (ECMA 167r3 4/14.4) */
struct fileIdentDesc
{
struct fileIdentDesc {
tag descTag;
__le16 fileVersionNum;
uint8_t fileCharacteristics;
......@@ -514,16 +480,14 @@ struct fileIdentDesc
#define FID_FILE_CHAR_METADATA 0x10
/* Allocation Ext Descriptor (ECMA 167r3 4/14.5) */
struct allocExtDesc
{
struct allocExtDesc {
tag descTag;
__le32 previousAllocExtLocation;
__le32 lengthAllocDescs;
} __attribute__ ((packed));
/* ICB Tag (ECMA 167r3 4/14.6) */
typedef struct
{
typedef struct {
__le32 priorRecordedNumDirectEntries;
__le16 strategyType;
__le16 strategyParameter;
......@@ -576,23 +540,20 @@ typedef struct
#define ICBTAG_FLAG_STREAM 0x2000
/* Indirect Entry (ECMA 167r3 4/14.7) */
struct indirectEntry
{
struct indirectEntry {
tag descTag;
icbtag icbTag;
long_ad indirectICB;
} __attribute__ ((packed));
/* Terminal Entry (ECMA 167r3 4/14.8) */
struct terminalEntry
{
struct terminalEntry {
tag descTag;
icbtag icbTag;
} __attribute__ ((packed));
/* File Entry (ECMA 167r3 4/14.9) */
struct fileEntry
{
struct fileEntry {
tag descTag;
icbtag icbTag;
__le32 uid;
......@@ -655,16 +616,14 @@ struct fileEntry
#define FE_RECORD_DISPLAY_ATTR_3 0x03
/* Extended Attribute Header Descriptor (ECMA 167r3 4/14.10.1) */
struct extendedAttrHeaderDesc
{
struct extendedAttrHeaderDesc {
tag descTag;
__le32 impAttrLocation;
__le32 appAttrLocation;
} __attribute__ ((packed));
/* Generic Format (ECMA 167r3 4/14.10.2) */
struct genericFormat
{
struct genericFormat {
__le32 attrType;
uint8_t attrSubtype;
uint8_t reserved[3];
......@@ -673,8 +632,7 @@ struct genericFormat
} __attribute__ ((packed));
/* Character Set Information (ECMA 167r3 4/14.10.3) */
struct charSetInfo
{
struct charSetInfo {
__le32 attrType;
uint8_t attrSubtype;
uint8_t reserved[3];
......@@ -685,8 +643,7 @@ struct charSetInfo
} __attribute__ ((packed));
/* Alternate Permissions (ECMA 167r3 4/14.10.4) */
struct altPerms
{
struct altPerms {
__le32 attrType;
uint8_t attrSubtype;
uint8_t reserved[3];
......@@ -697,8 +654,7 @@ struct altPerms
} __attribute__ ((packed));
/* File Times Extended Attribute (ECMA 167r3 4/14.10.5) */
struct fileTimesExtAttr
{
struct fileTimesExtAttr {
__le32 attrType;
uint8_t attrSubtype;
uint8_t reserved[3];
......@@ -715,8 +671,7 @@ struct fileTimesExtAttr
#define FTE_BACKUP 0x00000002
/* Information Times Extended Attribute (ECMA 167r3 4/14.10.6) */
struct infoTimesExtAttr
{
struct infoTimesExtAttr {
__le32 attrType;
uint8_t attrSubtype;
uint8_t reserved[3];
......@@ -727,8 +682,7 @@ struct infoTimesExtAttr
} __attribute__ ((packed));
/* Device Specification (ECMA 167r3 4/14.10.7) */
struct deviceSpec
{
struct deviceSpec {
__le32 attrType;
uint8_t attrSubtype;
uint8_t reserved[3];
......@@ -740,8 +694,7 @@ struct deviceSpec
} __attribute__ ((packed));
/* Implementation Use Extended Attr (ECMA 167r3 4/14.10.8) */
struct impUseExtAttr
{
struct impUseExtAttr {
__le32 attrType;
uint8_t attrSubtype;
uint8_t reserved[3];
......@@ -752,8 +705,7 @@ struct impUseExtAttr
} __attribute__ ((packed));
/* Application Use Extended Attribute (ECMA 167r3 4/14.10.9) */
struct appUseExtAttr
{
struct appUseExtAttr {
__le32 attrType;
uint8_t attrSubtype;
uint8_t reserved[3];
......@@ -771,10 +723,8 @@ struct appUseExtAttr
#define EXTATTR_IMP_USE 2048
#define EXTATTR_APP_USE 65536
/* Unallocated Space Entry (ECMA 167r3 4/14.11) */
struct unallocSpaceEntry
{
struct unallocSpaceEntry {
tag descTag;
icbtag icbTag;
__le32 lengthAllocDescs;
......@@ -782,8 +732,7 @@ struct unallocSpaceEntry
} __attribute__ ((packed));
/* Space Bitmap Descriptor (ECMA 167r3 4/14.12) */
struct spaceBitmapDesc
{
struct spaceBitmapDesc {
tag descTag;
__le32 numOfBits;
__le32 numOfBytes;
......@@ -791,8 +740,7 @@ struct spaceBitmapDesc
} __attribute__ ((packed));
/* Partition Integrity Entry (ECMA 167r3 4/14.13) */
struct partitionIntegrityEntry
{
struct partitionIntegrityEntry {
tag descTag;
icbtag icbTag;
timestamp recordingDateAndTime;
......@@ -815,15 +763,13 @@ struct partitionIntegrityEntry
/* Extended Allocation Descriptor (ECMA 167r3 4/14.14.3) */
/* Logical Volume Header Descriptor (ECMA 167r3 4/14.15) */
struct logicalVolHeaderDesc
{
struct logicalVolHeaderDesc {
__le64 uniqueID;
uint8_t reserved[24];
} __attribute__ ((packed));
/* Path Component (ECMA 167r3 4/14.16.1) */
struct pathComponent
{
struct pathComponent {
uint8_t componentType;
uint8_t lengthComponentIdent;
__le16 componentFileVersionNum;
......@@ -831,8 +777,7 @@ struct pathComponent
} __attribute__ ((packed));
/* File Entry (ECMA 167r3 4/14.17) */
struct extendedFileEntry
{
struct extendedFileEntry {
tag descTag;
icbtag icbTag;
__le32 uid;
......
......@@ -41,7 +41,7 @@
#include "udf_i.h"
#include "udf_sb.h"
static int udf_adinicb_readpage(struct file *file, struct page * page)
static int udf_adinicb_readpage(struct file *file, struct page *page)
{
struct inode *inode = page->mapping->host;
char *kaddr;
......@@ -58,7 +58,8 @@ static int udf_adinicb_readpage(struct file *file, struct page * page)
return 0;
}
static int udf_adinicb_writepage(struct page *page, struct writeback_control *wbc)
static int udf_adinicb_writepage(struct page *page,
struct writeback_control *wbc)
{
struct inode *inode = page->mapping->host;
char *kaddr;
......@@ -74,13 +75,15 @@ static int udf_adinicb_writepage(struct page *page, struct writeback_control *wb
return 0;
}
static int udf_adinicb_prepare_write(struct file *file, struct page *page, unsigned offset, unsigned to)
static int udf_adinicb_prepare_write(struct file *file, struct page *page,
unsigned offset, unsigned to)
{
kmap(page);
return 0;
}
static int udf_adinicb_commit_write(struct file *file, struct page *page, unsigned offset, unsigned to)
static int udf_adinicb_commit_write(struct file *file, struct page *page,
unsigned offset, unsigned to)
{
struct inode *inode = page->mapping->host;
char *kaddr = page_address(page);
......@@ -113,25 +116,20 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
int err, pos;
size_t count = iocb->ki_left;
if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB)
{
if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) {
if (file->f_flags & O_APPEND)
pos = inode->i_size;
else
pos = ppos;
if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) +
pos + count))
{
if (inode->i_sb->s_blocksize <
(udf_file_entry_alloc_offset(inode) + pos + count)) {
udf_expand_file_adinicb(inode, pos + count, &err);
if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB)
{
if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) {
udf_debug("udf_expand_adinicb: err=%d\n", err);
return err;
}
}
else
{
} else {
if (pos + count > inode->i_size)
UDF_I_LENALLOC(inode) = pos + count;
else
......@@ -185,30 +183,29 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
{
int result = -EINVAL;
if ( file_permission(filp, MAY_READ) != 0 )
{
udf_debug("no permission to access inode %lu\n",
inode->i_ino);
if (file_permission(filp, MAY_READ) != 0) {
udf_debug("no permission to access inode %lu\n", inode->i_ino);
return -EPERM;
}
if ( !arg )
{
if (!arg) {
udf_debug("invalid argument to udf_ioctl\n");
return -EINVAL;
}
switch (cmd)
{
switch (cmd) {
case UDF_GETVOLIDENT:
return copy_to_user((char __user *)arg,
UDF_SB_VOLIDENT(inode->i_sb), 32) ? -EFAULT : 0;
UDF_SB_VOLIDENT(inode->i_sb),
32) ? -EFAULT : 0;
case UDF_RELOCATE_BLOCKS:
{
long old, new;
if (!capable(CAP_SYS_ADMIN)) return -EACCES;
if (get_user(old, (long __user *)arg)) return -EFAULT;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
if (get_user(old, (long __user *)arg))
return -EFAULT;
if ((result = udf_relocate_blocks(inode->i_sb,
old, &new)) == 0)
result = put_user(new, (long __user *)arg);
......@@ -240,10 +237,9 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
* HISTORY
*
*/
static int udf_release_file(struct inode * inode, struct file * filp)
static int udf_release_file(struct inode *inode, struct file *filp)
{
if (filp->f_mode & FMODE_WRITE)
{
if (filp->f_mode & FMODE_WRITE) {
lock_kernel();
udf_discard_prealloc(inode);
unlock_kernel();
......
......@@ -29,7 +29,7 @@ static int udf_fsync_inode(struct inode *, int);
* even pass file to fsync ?
*/
int udf_fsync_file(struct file * file, struct dentry *dentry, int datasync)
int udf_fsync_file(struct file *file, struct dentry *dentry, int datasync)
{
struct inode *inode = dentry->d_inode;
return udf_fsync_inode(inode, datasync);
......@@ -45,6 +45,6 @@ static int udf_fsync_inode(struct inode *inode, int datasync)
if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
return err;
err |= udf_sync_inode (inode);
err |= udf_sync_inode(inode);
return err ? -EIO : 0;
}
......@@ -28,7 +28,7 @@
#include "udf_i.h"
#include "udf_sb.h"
void udf_free_inode(struct inode * inode)
void udf_free_inode(struct inode *inode)
{
struct super_block *sb = inode->i_sb;
struct udf_sb_info *sbi = UDF_SB(sb);
......@@ -46,10 +46,12 @@ void udf_free_inode(struct inode * inode)
if (sbi->s_lvidbh) {
if (S_ISDIR(inode->i_mode))
UDF_SB_LVIDIU(sb)->numDirs =
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) - 1);
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)
- 1);
else
UDF_SB_LVIDIU(sb)->numFiles =
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) - 1);
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles)
- 1);
mark_buffer_dirty(sbi->s_lvidbh);
}
......@@ -58,18 +60,17 @@ void udf_free_inode(struct inode * inode)
udf_free_blocks(sb, NULL, UDF_I_LOCATION(inode), 0, 1);
}
struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
{
struct super_block *sb = dir->i_sb;
struct udf_sb_info *sbi = UDF_SB(sb);
struct inode * inode;
struct inode *inode;
int block;
uint32_t start = UDF_I_LOCATION(dir).logicalBlockNum;
inode = new_inode(sb);
if (!inode)
{
if (!inode) {
*err = -ENOMEM;
return NULL;
}
......@@ -81,26 +82,30 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
UDF_I_NEXT_ALLOC_GOAL(inode) = 0;
UDF_I_STRAT4096(inode) = 0;
block = udf_new_block(dir->i_sb, NULL, UDF_I_LOCATION(dir).partitionReferenceNum,
start, err);
if (*err)
{
block =
udf_new_block(dir->i_sb, NULL,
UDF_I_LOCATION(dir).partitionReferenceNum, start,
err);
if (*err) {
iput(inode);
return NULL;
}
mutex_lock(&sbi->s_alloc_mutex);
if (UDF_SB_LVIDBH(sb))
{
if (UDF_SB_LVIDBH(sb)) {
struct logicalVolHeaderDesc *lvhd;
uint64_t uniqueID;
lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->logicalVolContentsUse);
lvhd =
(struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->
logicalVolContentsUse);
if (S_ISDIR(mode))
UDF_SB_LVIDIU(sb)->numDirs =
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) + 1);
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)
+ 1);
else
UDF_SB_LVIDIU(sb)->numFiles =
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + 1);
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles)
+ 1);
UDF_I_UNIQUE(inode) = uniqueID = le64_to_cpu(lvhd->uniqueID);
if (!(++uniqueID & 0x00000000FFFFFFFFUL))
uniqueID += 16;
......@@ -109,35 +114,34 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
}
inode->i_mode = mode;
inode->i_uid = current->fsuid;
if (dir->i_mode & S_ISGID)
{
if (dir->i_mode & S_ISGID) {
inode->i_gid = dir->i_gid;
if (S_ISDIR(mode))
mode |= S_ISGID;
}
else
} else
inode->i_gid = current->fsgid;
UDF_I_LOCATION(inode).logicalBlockNum = block;
UDF_I_LOCATION(inode).partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum;
UDF_I_LOCATION(inode).partitionReferenceNum =
UDF_I_LOCATION(dir).partitionReferenceNum;
inode->i_ino = udf_get_lb_pblock(sb, UDF_I_LOCATION(inode), 0);
inode->i_blocks = 0;
UDF_I_LENEATTR(inode) = 0;
UDF_I_LENALLOC(inode) = 0;
UDF_I_USE(inode) = 0;
if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE))
{
if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) {
UDF_I_EFE(inode) = 1;
UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE);
UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL);
}
else
{
UDF_I_DATA(inode) =
kzalloc(inode->i_sb->s_blocksize -
sizeof(struct extendedFileEntry), GFP_KERNEL);
} else {
UDF_I_EFE(inode) = 0;
UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL);
UDF_I_DATA(inode) =
kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry),
GFP_KERNEL);
}
if (!UDF_I_DATA(inode))
{
if (!UDF_I_DATA(inode)) {
iput(inode);
*err = -ENOMEM;
mutex_unlock(&sbi->s_alloc_mutex);
......@@ -155,8 +159,7 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
mark_inode_dirty(inode);
mutex_unlock(&sbi->s_alloc_mutex);
if (DQUOT_ALLOC_INODE(inode))
{
if (DQUOT_ALLOC_INODE(inode)) {
DQUOT_DROP(inode);
inode->i_flags |= S_NOQUOTA;
inode->i_nlink = 0;
......
此差异已折叠。
......@@ -26,43 +26,38 @@
#include <linux/udf_fs.h>
#include "udf_sb.h"
unsigned int
udf_get_last_session(struct super_block *sb)
unsigned int udf_get_last_session(struct super_block *sb)
{
struct cdrom_multisession ms_info;
unsigned int vol_desc_start;
struct block_device *bdev = sb->s_bdev;
int i;
vol_desc_start=0;
ms_info.addr_format=CDROM_LBA;
i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long) &ms_info);
vol_desc_start = 0;
ms_info.addr_format = CDROM_LBA;
i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long)&ms_info);
#define WE_OBEY_THE_WRITTEN_STANDARDS 1
if (i == 0)
{
if (i == 0) {
udf_debug("XA disk: %s, vol_desc_start=%d\n",
(ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba);
#if WE_OBEY_THE_WRITTEN_STANDARDS
if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */
#endif
vol_desc_start = ms_info.addr.lba;
}
else
{
} else {
udf_debug("CDROMMULTISESSION not supported: rc=%d\n", i);
}
return vol_desc_start;
}
unsigned long
udf_get_last_block(struct super_block *sb)
unsigned long udf_get_last_block(struct super_block *sb)
{
struct block_device *bdev = sb->s_bdev;
unsigned long lblock = 0;
if (ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long) &lblock))
if (ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long)&lblock))
lblock = bdev->bd_inode->i_size >> sb->s_blocksize_bits;
if (lblock)
......
此差异已折叠。
此差异已折叠。
......@@ -65,30 +65,26 @@
#define IS_DF_HARD_WRITE_PROTECT 0x01
#define IS_DF_SOFT_WRITE_PROTECT 0x02
struct UDFIdentSuffix
{
struct UDFIdentSuffix {
__le16 UDFRevision;
uint8_t OSClass;
uint8_t OSIdentifier;
uint8_t reserved[4];
} __attribute__ ((packed));
struct impIdentSuffix
{
struct impIdentSuffix {
uint8_t OSClass;
uint8_t OSIdentifier;
uint8_t reserved[6];
} __attribute__ ((packed));
struct appIdentSuffix
{
struct appIdentSuffix {
uint8_t impUse[8];
} __attribute__ ((packed));
/* Logical Volume Integrity Descriptor (UDF 2.50 2.2.6) */
/* Implementation Use (UDF 2.50 2.2.6.4) */
struct logicalVolIntegrityDescImpUse
{
struct logicalVolIntegrityDescImpUse {
regid impIdent;
__le32 numFiles;
__le32 numDirs;
......@@ -100,8 +96,7 @@ struct logicalVolIntegrityDescImpUse
/* Implementation Use Volume Descriptor (UDF 2.50 2.2.7) */
/* Implementation Use (UDF 2.50 2.2.7.2) */
struct impUseVolDescImpUse
{
struct impUseVolDescImpUse {
charspec LVICharset;
dstring logicalVolIdent[128];
dstring LVInfo1[36];
......@@ -111,8 +106,7 @@ struct impUseVolDescImpUse
uint8_t impUse[128];
} __attribute__ ((packed));
struct udfPartitionMap2
{
struct udfPartitionMap2 {
uint8_t partitionMapType;
uint8_t partitionMapLength;
uint8_t reserved1[2];
......@@ -122,8 +116,7 @@ struct udfPartitionMap2
} __attribute__ ((packed));
/* Virtual Partition Map (UDF 2.50 2.2.8) */
struct virtualPartitionMap
{
struct virtualPartitionMap {
uint8_t partitionMapType;
uint8_t partitionMapLength;
uint8_t reserved1[2];
......@@ -134,8 +127,7 @@ struct virtualPartitionMap
} __attribute__ ((packed));
/* Sparable Partition Map (UDF 2.50 2.2.9) */
struct sparablePartitionMap
{
struct sparablePartitionMap {
uint8_t partitionMapType;
uint8_t partitionMapLength;
uint8_t reserved1[2];
......@@ -150,8 +142,7 @@ struct sparablePartitionMap
} __attribute__ ((packed));
/* Metadata Partition Map (UDF 2.4.0 2.2.10) */
struct metadataPartitionMap
{
struct metadataPartitionMap {
uint8_t partitionMapType;
uint8_t partitionMapLength;
uint8_t reserved1[2];
......@@ -168,8 +159,7 @@ struct metadataPartitionMap
} __attribute__ ((packed));
/* Virtual Allocation Table (UDF 1.5 2.2.10) */
struct virtualAllocationTable15
{
struct virtualAllocationTable15 {
__le32 VirtualSector[0];
regid vatIdent;
__le32 previousVATICBLoc;
......@@ -178,8 +168,7 @@ struct virtualAllocationTable15
#define ICBTAG_FILE_TYPE_VAT15 0x00U
/* Virtual Allocation Table (UDF 2.50 2.2.11) */
struct virtualAllocationTable20
{
struct virtualAllocationTable20 {
__le16 lengthHeader;
__le16 lengthImpUse;
dstring logicalVolIdent[128];
......@@ -197,14 +186,12 @@ struct virtualAllocationTable20
#define ICBTAG_FILE_TYPE_VAT20 0xF8U
/* Sparing Table (UDF 2.50 2.2.12) */
struct sparingEntry
{
struct sparingEntry {
__le32 origLocation;
__le32 mappedLocation;
} __attribute__ ((packed));
struct sparingTable
{
struct sparingTable {
tag descTag;
regid sparingIdent;
__le16 reallocationTableLen;
......@@ -220,8 +207,7 @@ struct sparingTable
#define ICBTAG_FILE_TYPE_BITMAP 0xFC
/* struct long_ad ICB - ADImpUse (UDF 2.50 2.2.4.3) */
struct allocDescImpUse
{
struct allocDescImpUse {
__le16 flags;
uint8_t impUse[4];
} __attribute__ ((packed));
......@@ -233,15 +219,13 @@ struct allocDescImpUse
/* Implementation Use Extended Attribute (UDF 2.50 3.3.4.5) */
/* FreeEASpace (UDF 2.50 3.3.4.5.1.1) */
struct freeEaSpace
{
struct freeEaSpace {
__le16 headerChecksum;
uint8_t freeEASpace[0];
} __attribute__ ((packed));
/* DVD Copyright Management Information (UDF 2.50 3.3.4.5.1.2) */
struct DVDCopyrightImpUse
{
struct DVDCopyrightImpUse {
__le16 headerChecksum;
uint8_t CGMSInfo;
uint8_t dataType;
......@@ -250,8 +234,7 @@ struct DVDCopyrightImpUse
/* Application Use Extended Attribute (UDF 2.50 3.3.4.6) */
/* FreeAppEASpace (UDF 2.50 3.3.4.6.1) */
struct freeAppEASpace
{
struct freeAppEASpace {
__le16 headerChecksum;
uint8_t freeEASpace[0];
} __attribute__ ((packed));
......
此差异已折叠。
此差异已折叠。
......@@ -33,20 +33,18 @@
#include <linux/buffer_head.h>
#include "udf_i.h"
static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen, char *to)
static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen,
char *to)
{
struct pathComponent *pc;
int elen = 0;
char *p = to;
while (elen < fromlen)
{
while (elen < fromlen) {
pc = (struct pathComponent *)(from + elen);
switch (pc->componentType)
{
switch (pc->componentType) {
case 1:
if (pc->lengthComponentIdent == 0)
{
if (pc->lengthComponentIdent == 0) {
p = to;
*p++ = '/';
}
......@@ -61,13 +59,14 @@ static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen, char
/* that would be . - just ignore */
break;
case 5:
p += udf_get_filename(sb, pc->componentIdent, p, pc->lengthComponentIdent);
p += udf_get_filename(sb, pc->componentIdent, p,
pc->lengthComponentIdent);
*p++ = '/';
break;
}
elen += sizeof(struct pathComponent) + pc->lengthComponentIdent;
}
if (p > to+1)
if (p > to + 1)
p[-1] = '\0';
else
p[0] = '\0';
......@@ -84,8 +83,7 @@ static int udf_symlink_filler(struct file *file, struct page *page)
lock_kernel();
if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB)
symlink = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode);
else
{
else {
bh = sb_bread(inode->i_sb, udf_block_map(inode, 0));
if (!bh)
......@@ -102,7 +100,7 @@ static int udf_symlink_filler(struct file *file, struct page *page)
kunmap(page);
unlock_page(page);
return 0;
out:
out:
unlock_kernel();
SetPageError(page);
kunmap(page);
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册