Commit 28de7948 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Linus Torvalds

UDF: coding style conversion - lindent fixups

This patch fixes up sources after conversion by Lindent.
Signed-off-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
Cc: Jan Kara <jack@ucw.cz>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 71133027
This diff is collapsed.
...@@ -83,8 +83,7 @@ int udf_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -83,8 +83,7 @@ int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
lock_kernel(); lock_kernel();
if (filp->f_pos == 0) { if (filp->f_pos == 0) {
if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) < if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) < 0) {
0) {
unlock_kernel(); unlock_kernel();
return 0; return 0;
} }
...@@ -125,21 +124,20 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir, ...@@ -125,21 +124,20 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
if (nf_pos == 0) if (nf_pos == 0)
nf_pos = (udf_ext0_offset(dir) >> 2); nf_pos = (udf_ext0_offset(dir) >> 2);
fibh.soffset = fibh.eoffset = fibh.soffset = fibh.eoffset = (nf_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
(nf_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
fibh.sbh = fibh.ebh = NULL; fibh.sbh = fibh.ebh = NULL;
else if (inode_bmap(dir, nf_pos >> (dir->i_sb->s_blocksize_bits - 2), } else if (inode_bmap(dir, nf_pos >> (dir->i_sb->s_blocksize_bits - 2),
&epos, &eloc, &elen, &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
&offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
block = udf_get_lb_pblock(dir->i_sb, eloc, offset); 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) if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
epos.offset -= sizeof(short_ad); epos.offset -= sizeof(short_ad);
else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
epos.offset -= sizeof(long_ad); epos.offset -= sizeof(long_ad);
} else } else {
offset = 0; 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); brelse(epos.bh);
...@@ -149,15 +147,11 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir, ...@@ -149,15 +147,11 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
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); i = 16 >> (dir->i_sb->s_blocksize_bits - 9);
if (i + offset > (elen >> dir->i_sb->s_blocksize_bits)) if (i + offset > (elen >> dir->i_sb->s_blocksize_bits))
i = (elen >> dir->i_sb->s_blocksize_bits) - i = (elen >> dir->i_sb->s_blocksize_bits) - offset;
offset;
for (num = 0; i > 0; i--) { for (num = 0; i > 0; i--) {
block = block = udf_get_lb_pblock(dir->i_sb, eloc, offset + i);
udf_get_lb_pblock(dir->i_sb, eloc,
offset + i);
tmp = udf_tgetblk(dir->i_sb, block); tmp = udf_tgetblk(dir->i_sb, block);
if (tmp && !buffer_uptodate(tmp) if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp))
&& !buffer_locked(tmp))
bha[num++] = tmp; bha[num++] = tmp;
else else
brelse(tmp); brelse(tmp);
...@@ -178,7 +172,6 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir, ...@@ -178,7 +172,6 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
fi = udf_fileident_read(dir, &nf_pos, &fibh, &cfi, &epos, &eloc, fi = udf_fileident_read(dir, &nf_pos, &fibh, &cfi, &epos, &eloc,
&elen, &offset); &elen, &offset);
if (!fi) { if (!fi) {
if (fibh.sbh != fibh.ebh) if (fibh.sbh != fibh.ebh)
brelse(fibh.ebh); brelse(fibh.ebh);
...@@ -190,19 +183,16 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir, ...@@ -190,19 +183,16 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
liu = le16_to_cpu(cfi.lengthOfImpUse); liu = le16_to_cpu(cfi.lengthOfImpUse);
lfi = cfi.lengthFileIdent; lfi = cfi.lengthFileIdent;
if (fibh.sbh == fibh.ebh) if (fibh.sbh == fibh.ebh) {
nameptr = fi->fileIdent + liu; nameptr = fi->fileIdent + liu;
else { } else {
int poffset; /* Unpaded ending offset */ int poffset; /* Unpaded ending offset */
poffset = poffset = fibh.soffset + sizeof(struct fileIdentDesc) + liu + lfi;
fibh.soffset + sizeof(struct fileIdentDesc) + liu +
lfi;
if (poffset >= lfi) if (poffset >= lfi) {
nameptr = nameptr = (char *)(fibh.ebh->b_data + poffset - lfi);
(char *)(fibh.ebh->b_data + poffset - lfi); } else {
else {
nameptr = fname; nameptr = fname;
memcpy(nameptr, fi->fileIdent + liu, memcpy(nameptr, fi->fileIdent + liu,
lfi - poffset); lfi - poffset);
...@@ -235,9 +225,7 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir, ...@@ -235,9 +225,7 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
} }
if (flen) { if (flen) {
if (filldir if (filldir(dirent, fname, flen, filp->f_pos, iblock, dt_type) < 0) {
(dirent, fname, flen, filp->f_pos, iblock,
dt_type) < 0) {
if (fibh.sbh != fibh.ebh) if (fibh.sbh != fibh.ebh)
brelse(fibh.ebh); brelse(fibh.ebh);
brelse(fibh.sbh); brelse(fibh.sbh);
......
...@@ -31,7 +31,7 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad, ...@@ -31,7 +31,7 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad,
*error = 0; *error = 0;
ad = (uint8_t *) (*bh)->b_data + *offset; ad = (uint8_t *)(*bh)->b_data + *offset;
*offset += ad_size; *offset += ad_size;
if (!ad) { if (!ad) {
...@@ -51,7 +51,7 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad, ...@@ -51,7 +51,7 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad,
ad = tmpad; ad = tmpad;
remainder = dir->i_sb->s_blocksize - loffset; 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); brelse(*bh);
block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos); block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos);
...@@ -60,10 +60,10 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad, ...@@ -60,10 +60,10 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad,
if (!((*bh) = udf_tread(dir->i_sb, block))) if (!((*bh) = udf_tread(dir->i_sb, block)))
return NULL; return NULL;
memcpy((uint8_t *) ad + remainder, (*bh)->b_data, memcpy((uint8_t *)ad + remainder, (*bh)->b_data, ad_size - remainder);
ad_size - remainder);
*offset = ad_size - remainder; *offset = ad_size - remainder;
} }
return ad; return ad;
} }
#endif #endif
...@@ -86,15 +86,13 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos, ...@@ -86,15 +86,13 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
(UDF_I_EFE(dir) ? (UDF_I_EFE(dir) ?
sizeof(struct extendedFileEntry) : sizeof(struct extendedFileEntry) :
sizeof(struct fileEntry)), sizeof(struct fileEntry)),
dir->i_sb->s_blocksize, dir->i_sb->s_blocksize, &(fibh->eoffset));
&(fibh->eoffset));
if (!fi) if (!fi)
return NULL; return NULL;
*nf_pos += ((fibh->eoffset - fibh->soffset) >> 2); *nf_pos += ((fibh->eoffset - fibh->soffset) >> 2);
memcpy((uint8_t *) cfi, (uint8_t *) fi, memcpy((uint8_t *)cfi, (uint8_t *)fi,
sizeof(struct fileIdentDesc)); sizeof(struct fileIdentDesc));
return fi; return fi;
...@@ -121,21 +119,14 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos, ...@@ -121,21 +119,14 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
return NULL; return NULL;
fibh->soffset = fibh->eoffset = 0; fibh->soffset = fibh->eoffset = 0;
if (! if (!(*offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1))) {
(*offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1)))
{
i = 16 >> (dir->i_sb->s_blocksize_bits - 9); i = 16 >> (dir->i_sb->s_blocksize_bits - 9);
if (i + *offset > if (i + *offset > (*elen >> dir->i_sb->s_blocksize_bits))
(*elen >> dir->i_sb->s_blocksize_bits)) i = (*elen >> dir->i_sb->s_blocksize_bits)-*offset;
i = (*elen >> dir->i_sb->s_blocksize_bits) -
*offset;
for (num = 0; i > 0; i--) { for (num = 0; i > 0; i--) {
block = block = udf_get_lb_pblock(dir->i_sb, *eloc, *offset + i);
udf_get_lb_pblock(dir->i_sb, *eloc,
*offset + i);
tmp = udf_tgetblk(dir->i_sb, block); tmp = udf_tgetblk(dir->i_sb, block);
if (tmp && !buffer_uptodate(tmp) if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp))
&& !buffer_locked(tmp))
bha[num++] = tmp; bha[num++] = tmp;
else else
brelse(tmp); brelse(tmp);
...@@ -160,7 +151,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos, ...@@ -160,7 +151,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
*nf_pos += ((fibh->eoffset - fibh->soffset) >> 2); *nf_pos += ((fibh->eoffset - fibh->soffset) >> 2);
if (fibh->eoffset <= dir->i_sb->s_blocksize) { if (fibh->eoffset <= dir->i_sb->s_blocksize) {
memcpy((uint8_t *) cfi, (uint8_t *) fi, memcpy((uint8_t *)cfi, (uint8_t *)fi,
sizeof(struct fileIdentDesc)); sizeof(struct fileIdentDesc));
} else if (fibh->eoffset > dir->i_sb->s_blocksize) { } else if (fibh->eoffset > dir->i_sb->s_blocksize) {
int lextoffset = epos->offset; int lextoffset = epos->offset;
...@@ -187,21 +178,17 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos, ...@@ -187,21 +178,17 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
if (sizeof(struct fileIdentDesc) > -fibh->soffset) { if (sizeof(struct fileIdentDesc) > -fibh->soffset) {
int fi_len; int fi_len;
memcpy((uint8_t *) cfi, (uint8_t *) fi, -fibh->soffset); memcpy((uint8_t *)cfi, (uint8_t *)fi, -fibh->soffset);
memcpy((uint8_t *) cfi - fibh->soffset, memcpy((uint8_t *)cfi - fibh->soffset, fibh->ebh->b_data,
fibh->ebh->b_data,
sizeof(struct fileIdentDesc) + fibh->soffset); sizeof(struct fileIdentDesc) + fibh->soffset);
fi_len = fi_len = (sizeof(struct fileIdentDesc) + cfi->lengthFileIdent +
(sizeof(struct fileIdentDesc) +
cfi->lengthFileIdent +
le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3; le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3;
*nf_pos += *nf_pos += ((fi_len - (fibh->eoffset - fibh->soffset)) >> 2);
((fi_len - (fibh->eoffset - fibh->soffset)) >> 2);
fibh->eoffset = fibh->soffset + fi_len; fibh->eoffset = fibh->soffset + fi_len;
} else { } else {
memcpy((uint8_t *) cfi, (uint8_t *) fi, memcpy((uint8_t *)cfi, (uint8_t *)fi,
sizeof(struct fileIdentDesc)); sizeof(struct fileIdentDesc));
} }
} }
...@@ -237,9 +224,10 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset) ...@@ -237,9 +224,10 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
} }
if ((*offset + sizeof(struct fileIdentDesc)) > bufsize) { if ((*offset + sizeof(struct fileIdentDesc)) > bufsize) {
lengthThisIdent = sizeof(struct fileIdentDesc); lengthThisIdent = sizeof(struct fileIdentDesc);
} else } else {
lengthThisIdent = sizeof(struct fileIdentDesc) + lengthThisIdent = sizeof(struct fileIdentDesc) +
fi->lengthFileIdent + le16_to_cpu(fi->lengthOfImpUse); fi->lengthFileIdent + le16_to_cpu(fi->lengthOfImpUse);
}
/* we need to figure padding, too! */ /* we need to figure padding, too! */
padlen = lengthThisIdent % UDF_NAME_PAD; padlen = lengthThisIdent % UDF_NAME_PAD;
...@@ -270,22 +258,20 @@ static extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset) ...@@ -270,22 +258,20 @@ static extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset)
return NULL; return NULL;
} }
ptr = ptr = (uint8_t *)(fe->extendedAttr) + le32_to_cpu(fe->lengthExtendedAttr);
(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; ptr += *offset;
} }
ext = (extent_ad *) ptr; ext = (extent_ad *)ptr;
*offset = *offset + sizeof(extent_ad); *offset = *offset + sizeof(extent_ad);
return ext; return ext;
} }
#endif #endif
short_ad *udf_get_fileshortad(uint8_t * ptr, int maxoffset, int *offset, short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, int *offset,
int inc) int inc)
{ {
short_ad *sa; short_ad *sa;
...@@ -297,7 +283,7 @@ short_ad *udf_get_fileshortad(uint8_t * ptr, int maxoffset, int *offset, ...@@ -297,7 +283,7 @@ short_ad *udf_get_fileshortad(uint8_t * ptr, int maxoffset, int *offset,
if ((*offset < 0) || ((*offset + sizeof(short_ad)) > maxoffset)) if ((*offset < 0) || ((*offset + sizeof(short_ad)) > maxoffset))
return NULL; return NULL;
else if ((sa = (short_ad *) ptr)->extLength == 0) else if ((sa = (short_ad *)ptr)->extLength == 0)
return NULL; return NULL;
if (inc) if (inc)
...@@ -305,7 +291,7 @@ short_ad *udf_get_fileshortad(uint8_t * ptr, int maxoffset, int *offset, ...@@ -305,7 +291,7 @@ short_ad *udf_get_fileshortad(uint8_t * ptr, int maxoffset, int *offset,
return sa; 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; long_ad *la;
...@@ -316,7 +302,7 @@ long_ad *udf_get_filelongad(uint8_t * ptr, int maxoffset, int *offset, int inc) ...@@ -316,7 +302,7 @@ long_ad *udf_get_filelongad(uint8_t * ptr, int maxoffset, int *offset, int inc)
if ((*offset < 0) || ((*offset + sizeof(long_ad)) > maxoffset)) if ((*offset < 0) || ((*offset + sizeof(long_ad)) > maxoffset))
return NULL; return NULL;
else if ((la = (long_ad *) ptr)->extLength == 0) else if ((la = (long_ad *)ptr)->extLength == 0)
return NULL; return NULL;
if (inc) if (inc)
......
...@@ -55,11 +55,11 @@ static int udf_adinicb_readpage(struct file *file, struct page *page) ...@@ -55,11 +55,11 @@ static int udf_adinicb_readpage(struct file *file, struct page *page)
SetPageUptodate(page); SetPageUptodate(page);
kunmap(page); kunmap(page);
unlock_page(page); unlock_page(page);
return 0; return 0;
} }
static int udf_adinicb_writepage(struct page *page, static int udf_adinicb_writepage(struct page *page, struct writeback_control *wbc)
struct writeback_control *wbc)
{ {
struct inode *inode = page->mapping->host; struct inode *inode = page->mapping->host;
char *kaddr; char *kaddr;
...@@ -72,6 +72,7 @@ static int udf_adinicb_writepage(struct page *page, ...@@ -72,6 +72,7 @@ static int udf_adinicb_writepage(struct page *page,
SetPageUptodate(page); SetPageUptodate(page);
kunmap(page); kunmap(page);
unlock_page(page); unlock_page(page);
return 0; return 0;
} }
...@@ -122,8 +123,8 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -122,8 +123,8 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
else else
pos = ppos; pos = ppos;
if (inode->i_sb->s_blocksize < if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) +
(udf_file_entry_alloc_offset(inode) + pos + count)) { pos + count)) {
udf_expand_file_adinicb(inode, pos + count, &err); 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); udf_debug("udf_expand_adinicb: err=%d\n", err);
...@@ -138,9 +139,9 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -138,9 +139,9 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
} }
retval = generic_file_aio_write(iocb, iov, nr_segs, ppos); retval = generic_file_aio_write(iocb, iov, nr_segs, ppos);
if (retval > 0) if (retval > 0)
mark_inode_dirty(inode); mark_inode_dirty(inode);
return retval; return retval;
} }
...@@ -181,10 +182,12 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -181,10 +182,12 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
long old_block, new_block;
int result = -EINVAL; int result = -EINVAL;
if (file_permission(filp, MAY_READ) != 0) { if (file_permission(filp, MAY_READ) != 0) {
udf_debug("no permission to access inode %lu\n", inode->i_ino); udf_debug("no permission to access inode %lu\n",
inode->i_ino);
return -EPERM; return -EPERM;
} }
...@@ -196,26 +199,19 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, ...@@ -196,26 +199,19 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
switch (cmd) { switch (cmd) {
case UDF_GETVOLIDENT: case UDF_GETVOLIDENT:
return copy_to_user((char __user *)arg, return copy_to_user((char __user *)arg,
UDF_SB_VOLIDENT(inode->i_sb), UDF_SB_VOLIDENT(inode->i_sb), 32) ? -EFAULT : 0;
32) ? -EFAULT : 0;
case UDF_RELOCATE_BLOCKS: case UDF_RELOCATE_BLOCKS:
{
long old, new;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EACCES; return -EACCES;
if (get_user(old, (long __user *)arg)) if (get_user(old_block, (long __user *)arg))
return -EFAULT; return -EFAULT;
if ((result = udf_relocate_blocks(inode->i_sb, if ((result = udf_relocate_blocks(inode->i_sb,
old, &new)) == 0) old_block, &new_block)) == 0)
result = put_user(new, (long __user *)arg); result = put_user(new_block, (long __user *)arg);
return result; return result;
}
case UDF_GETEASIZE: case UDF_GETEASIZE:
result = put_user(UDF_I_LENEATTR(inode), (int __user *)arg); result = put_user(UDF_I_LENEATTR(inode), (int __user *)arg);
break; break;
case UDF_GETEABLOCK: case UDF_GETEABLOCK:
result = copy_to_user((char __user *)arg, UDF_I_DATA(inode), result = copy_to_user((char __user *)arg, UDF_I_DATA(inode),
UDF_I_LENEATTR(inode)) ? -EFAULT : 0; UDF_I_LENEATTR(inode)) ? -EFAULT : 0;
......
...@@ -32,6 +32,7 @@ static int udf_fsync_inode(struct inode *, int); ...@@ -32,6 +32,7 @@ static int udf_fsync_inode(struct inode *, int);
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; struct inode *inode = dentry->d_inode;
return udf_fsync_inode(inode, datasync); return udf_fsync_inode(inode, datasync);
} }
...@@ -46,5 +47,6 @@ static int udf_fsync_inode(struct inode *inode, int datasync) ...@@ -46,5 +47,6 @@ static int udf_fsync_inode(struct inode *inode, int datasync)
return err; return err;
err |= udf_sync_inode(inode); err |= udf_sync_inode(inode);
return err ? -EIO : 0; return err ? -EIO : 0;
} }
...@@ -46,12 +46,10 @@ void udf_free_inode(struct inode *inode) ...@@ -46,12 +46,10 @@ void udf_free_inode(struct inode *inode)
if (sbi->s_lvidbh) { if (sbi->s_lvidbh) {
if (S_ISDIR(inode->i_mode)) if (S_ISDIR(inode->i_mode))
UDF_SB_LVIDIU(sb)->numDirs = UDF_SB_LVIDIU(sb)->numDirs =
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) - 1);
- 1);
else else
UDF_SB_LVIDIU(sb)->numFiles = UDF_SB_LVIDIU(sb)->numFiles =
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) - 1);
- 1);
mark_buffer_dirty(sbi->s_lvidbh); mark_buffer_dirty(sbi->s_lvidbh);
} }
...@@ -82,10 +80,8 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) ...@@ -82,10 +80,8 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
UDF_I_NEXT_ALLOC_GOAL(inode) = 0; UDF_I_NEXT_ALLOC_GOAL(inode) = 0;
UDF_I_STRAT4096(inode) = 0; UDF_I_STRAT4096(inode) = 0;
block = block = udf_new_block(dir->i_sb, NULL, UDF_I_LOCATION(dir).partitionReferenceNum,
udf_new_block(dir->i_sb, NULL, start, err);
UDF_I_LOCATION(dir).partitionReferenceNum, start,
err);
if (*err) { if (*err) {
iput(inode); iput(inode);
return NULL; return NULL;
...@@ -95,17 +91,13 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) ...@@ -95,17 +91,13 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
if (UDF_SB_LVIDBH(sb)) { if (UDF_SB_LVIDBH(sb)) {
struct logicalVolHeaderDesc *lvhd; struct logicalVolHeaderDesc *lvhd;
uint64_t uniqueID; uint64_t uniqueID;
lvhd = lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->logicalVolContentsUse);
(struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->
logicalVolContentsUse);
if (S_ISDIR(mode)) if (S_ISDIR(mode))
UDF_SB_LVIDIU(sb)->numDirs = UDF_SB_LVIDIU(sb)->numDirs =
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) + 1);
+ 1);
else else
UDF_SB_LVIDIU(sb)->numFiles = UDF_SB_LVIDIU(sb)->numFiles =
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + 1);
+ 1);
UDF_I_UNIQUE(inode) = uniqueID = le64_to_cpu(lvhd->uniqueID); UDF_I_UNIQUE(inode) = uniqueID = le64_to_cpu(lvhd->uniqueID);
if (!(++uniqueID & 0x00000000FFFFFFFFUL)) if (!(++uniqueID & 0x00000000FFFFFFFFUL))
uniqueID += 16; uniqueID += 16;
...@@ -118,12 +110,12 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) ...@@ -118,12 +110,12 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
inode->i_gid = dir->i_gid; inode->i_gid = dir->i_gid;
if (S_ISDIR(mode)) if (S_ISDIR(mode))
mode |= S_ISGID; mode |= S_ISGID;
} else } else {
inode->i_gid = current->fsgid; inode->i_gid = current->fsgid;
}
UDF_I_LOCATION(inode).logicalBlockNum = block; UDF_I_LOCATION(inode).logicalBlockNum = block;
UDF_I_LOCATION(inode).partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum;
UDF_I_LOCATION(dir).partitionReferenceNum;
inode->i_ino = udf_get_lb_pblock(sb, UDF_I_LOCATION(inode), 0); inode->i_ino = udf_get_lb_pblock(sb, UDF_I_LOCATION(inode), 0);
inode->i_blocks = 0; inode->i_blocks = 0;
UDF_I_LENEATTR(inode) = 0; UDF_I_LENEATTR(inode) = 0;
...@@ -132,14 +124,10 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) ...@@ -132,14 +124,10 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
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_I_EFE(inode) = 1;
UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE); UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE);
UDF_I_DATA(inode) = UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL);
kzalloc(inode->i_sb->s_blocksize -
sizeof(struct extendedFileEntry), GFP_KERNEL);
} else { } else {
UDF_I_EFE(inode) = 0; UDF_I_EFE(inode) = 0;
UDF_I_DATA(inode) = UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL);
kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry),
GFP_KERNEL);
} }
if (!UDF_I_DATA(inode)) { if (!UDF_I_DATA(inode)) {
iput(inode); iput(inode);
......
This diff is collapsed.
...@@ -57,7 +57,7 @@ unsigned long udf_get_last_block(struct super_block *sb) ...@@ -57,7 +57,7 @@ unsigned long udf_get_last_block(struct super_block *sb)
struct block_device *bdev = sb->s_bdev; struct block_device *bdev = sb->s_bdev;
unsigned long lblock = 0; 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; lblock = bdev->bd_inode->i_size >> sb->s_blocksize_bits;
if (lblock) if (lblock)
......
...@@ -54,9 +54,9 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, ...@@ -54,9 +54,9 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
int i; int i;
ea = UDF_I_DATA(inode); ea = UDF_I_DATA(inode);
if (UDF_I_LENEATTR(inode)) if (UDF_I_LENEATTR(inode)) {
ad = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode); ad = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode);
else { } else {
ad = ea; ad = ea;
size += sizeof(struct extendedAttrHeaderDesc); size += sizeof(struct extendedAttrHeaderDesc);
} }
...@@ -76,56 +76,45 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, ...@@ -76,56 +76,45 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
if (UDF_I_LENEATTR(inode)) { if (UDF_I_LENEATTR(inode)) {
/* check checksum/crc */ /* check checksum/crc */
if (le16_to_cpu(eahd->descTag.tagIdent) != if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD ||
TAG_IDENT_EAHD le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum) {
|| le32_to_cpu(eahd->descTag.tagLocation) !=
UDF_I_LOCATION(inode).logicalBlockNum) {
return NULL; return NULL;
} }
} else { } else {
size -= sizeof(struct extendedAttrHeaderDesc); size -= sizeof(struct extendedAttrHeaderDesc);
UDF_I_LENEATTR(inode) += UDF_I_LENEATTR(inode) += sizeof(struct extendedAttrHeaderDesc);
sizeof(struct extendedAttrHeaderDesc);
eahd->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EAHD); eahd->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EAHD);
if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200) if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200)
eahd->descTag.descVersion = cpu_to_le16(3); eahd->descTag.descVersion = cpu_to_le16(3);
else else
eahd->descTag.descVersion = cpu_to_le16(2); eahd->descTag.descVersion = cpu_to_le16(2);
eahd->descTag.tagSerialNum = eahd->descTag.tagSerialNum = cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb));
cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb)); eahd->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum);
eahd->descTag.tagLocation =
cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum);
eahd->impAttrLocation = cpu_to_le32(0xFFFFFFFF); eahd->impAttrLocation = cpu_to_le32(0xFFFFFFFF);
eahd->appAttrLocation = cpu_to_le32(0xFFFFFFFF); eahd->appAttrLocation = cpu_to_le32(0xFFFFFFFF);
} }
offset = UDF_I_LENEATTR(inode); offset = UDF_I_LENEATTR(inode);
if (type < 2048) { if (type < 2048) {
if (le32_to_cpu(eahd->appAttrLocation) < if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode)) {
UDF_I_LENEATTR(inode)) { uint32_t aal = le32_to_cpu(eahd->appAttrLocation);
uint32_t aal = memmove(&ea[offset - aal + size],
le32_to_cpu(eahd->appAttrLocation); &ea[aal], offset - aal);
memmove(&ea[offset - aal + size], &ea[aal],
offset - aal);
offset -= aal; offset -= aal;
eahd->appAttrLocation = cpu_to_le32(aal + size); eahd->appAttrLocation = cpu_to_le32(aal + size);
} }
if (le32_to_cpu(eahd->impAttrLocation) < if (le32_to_cpu(eahd->impAttrLocation) < UDF_I_LENEATTR(inode)) {
UDF_I_LENEATTR(inode)) { uint32_t ial = le32_to_cpu(eahd->impAttrLocation);
uint32_t ial = memmove(&ea[offset - ial + size],
le32_to_cpu(eahd->impAttrLocation); &ea[ial], offset - ial);
memmove(&ea[offset - ial + size], &ea[ial],
offset - ial);
offset -= ial; offset -= ial;
eahd->impAttrLocation = cpu_to_le32(ial + size); eahd->impAttrLocation = cpu_to_le32(ial + size);
} }
} else if (type < 65536) { } else if (type < 65536) {
if (le32_to_cpu(eahd->appAttrLocation) < if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode)) {
UDF_I_LENEATTR(inode)) { uint32_t aal = le32_to_cpu(eahd->appAttrLocation);
uint32_t aal = memmove(&ea[offset - aal + size],
le32_to_cpu(eahd->appAttrLocation); &ea[aal], offset - aal);
memmove(&ea[offset - aal + size], &ea[aal],
offset - aal);
offset -= aal; offset -= aal;
eahd->appAttrLocation = cpu_to_le32(aal + size); eahd->appAttrLocation = cpu_to_le32(aal + size);
} }
...@@ -133,18 +122,18 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, ...@@ -133,18 +122,18 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
/* rewrite CRC + checksum of eahd */ /* rewrite CRC + checksum of eahd */
crclen = sizeof(struct extendedAttrHeaderDesc) - sizeof(tag); crclen = sizeof(struct extendedAttrHeaderDesc) - sizeof(tag);
eahd->descTag.descCRCLength = cpu_to_le16(crclen); eahd->descTag.descCRCLength = cpu_to_le16(crclen);
eahd->descTag.descCRC = eahd->descTag.descCRC = cpu_to_le16(udf_crc((char *)eahd +
cpu_to_le16(udf_crc((char *)eahd + sizeof(tag), crclen, 0)); sizeof(tag), crclen, 0));
eahd->descTag.tagChecksum = 0; eahd->descTag.tagChecksum = 0;
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
if (i != 4) if (i != 4)
eahd->descTag.tagChecksum += eahd->descTag.tagChecksum += ((uint8_t *)&(eahd->descTag))[i];
((uint8_t *) & (eahd->descTag))[i];
UDF_I_LENEATTR(inode) += size; UDF_I_LENEATTR(inode) += size;
return (struct genericFormat *)&ea[offset]; return (struct genericFormat *)&ea[offset];
} }
if (loc & 0x02) { if (loc & 0x02) {
} }
return NULL; return NULL;
} }
...@@ -163,8 +152,7 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type, ...@@ -163,8 +152,7 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
/* check checksum/crc */ /* check checksum/crc */
if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD || if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD ||
le32_to_cpu(eahd->descTag.tagLocation) != le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum) {
UDF_I_LOCATION(inode).logicalBlockNum) {
return NULL; return NULL;
} }
...@@ -177,13 +165,13 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type, ...@@ -177,13 +165,13 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
while (offset < UDF_I_LENEATTR(inode)) { while (offset < UDF_I_LENEATTR(inode)) {
gaf = (struct genericFormat *)&ea[offset]; gaf = (struct genericFormat *)&ea[offset];
if (le32_to_cpu(gaf->attrType) == type if (le32_to_cpu(gaf->attrType) == type && gaf->attrSubtype == subtype)
&& gaf->attrSubtype == subtype)
return gaf; return gaf;
else else
offset += le32_to_cpu(gaf->attrLength); offset += le32_to_cpu(gaf->attrLength);
} }
} }
return NULL; return NULL;
} }
...@@ -216,23 +204,22 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, ...@@ -216,23 +204,22 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
return NULL; return NULL;
} }
tag_p = (tag *) (bh->b_data); tag_p = (tag *)(bh->b_data);
*ident = le16_to_cpu(tag_p->tagIdent); *ident = le16_to_cpu(tag_p->tagIdent);
if (location != le32_to_cpu(tag_p->tagLocation)) { if (location != le32_to_cpu(tag_p->tagLocation)) {
udf_debug("location mismatch block %u, tag %u != %u\n", udf_debug("location mismatch block %u, tag %u != %u\n",
block + UDF_SB_SESSION(sb), block + UDF_SB_SESSION(sb), le32_to_cpu(tag_p->tagLocation), location);
le32_to_cpu(tag_p->tagLocation), location);
goto error_out; goto error_out;
} }
/* Verify the tag checksum */ /* Verify the tag checksum */
checksum = 0U; checksum = 0U;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
checksum += (uint8_t) (bh->b_data[i]); checksum += (uint8_t)(bh->b_data[i]);
for (i = 5; i < 16; i++) for (i = 5; i < 16; i++)
checksum += (uint8_t) (bh->b_data[i]); checksum += (uint8_t)(bh->b_data[i]);
if (checksum != tag_p->tagChecksum) { if (checksum != tag_p->tagChecksum) {
printk(KERN_ERR "udf: tag checksum failed block %d\n", block); printk(KERN_ERR "udf: tag checksum failed block %d\n", block);
goto error_out; goto error_out;
...@@ -249,16 +236,14 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, ...@@ -249,16 +236,14 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
/* Verify the descriptor CRC */ /* Verify the descriptor CRC */
if (le16_to_cpu(tag_p->descCRCLength) + sizeof(tag) > sb->s_blocksize || if (le16_to_cpu(tag_p->descCRCLength) + sizeof(tag) > sb->s_blocksize ||
le16_to_cpu(tag_p->descCRC) == udf_crc(bh->b_data + sizeof(tag), le16_to_cpu(tag_p->descCRC) == udf_crc(bh->b_data + sizeof(tag),
le16_to_cpu(tag_p-> le16_to_cpu(tag_p->descCRCLength), 0)) {
descCRCLength),
0)) {
return bh; return bh;
} }
udf_debug("Crc failure block %d: crc = %d, crclen = %d\n", udf_debug("Crc failure block %d: crc = %d, crclen = %d\n",
block + UDF_SB_SESSION(sb), le16_to_cpu(tag_p->descCRC), block + UDF_SB_SESSION(sb), le16_to_cpu(tag_p->descCRC),
le16_to_cpu(tag_p->descCRCLength)); le16_to_cpu(tag_p->descCRCLength));
error_out: error_out:
brelse(bh); brelse(bh);
return NULL; return NULL;
} }
...@@ -272,7 +257,7 @@ struct buffer_head *udf_read_ptagged(struct super_block *sb, kernel_lb_addr loc, ...@@ -272,7 +257,7 @@ struct buffer_head *udf_read_ptagged(struct super_block *sb, kernel_lb_addr loc,
void udf_update_tag(char *data, int length) void udf_update_tag(char *data, int length)
{ {
tag *tptr = (tag *) data; tag *tptr = (tag *)data;
int i; int i;
length -= sizeof(tag); length -= sizeof(tag);
...@@ -283,13 +268,13 @@ void udf_update_tag(char *data, int length) ...@@ -283,13 +268,13 @@ void udf_update_tag(char *data, int length)
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
if (i != 4) if (i != 4)
tptr->tagChecksum += (uint8_t) (data[i]); tptr->tagChecksum += (uint8_t)(data[i]);
} }
void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum, void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
uint32_t loc, int length) uint32_t loc, int length)
{ {
tag *tptr = (tag *) data; tag *tptr = (tag *)data;
tptr->tagIdent = cpu_to_le16(ident); tptr->tagIdent = cpu_to_le16(ident);
tptr->descVersion = cpu_to_le16(version); tptr->descVersion = cpu_to_le16(version);
tptr->tagSerialNum = cpu_to_le16(snum); tptr->tagSerialNum = cpu_to_le16(snum);
......
This diff is collapsed.
...@@ -32,19 +32,17 @@ inline uint32_t udf_get_pblock(struct super_block *sb, uint32_t block, ...@@ -32,19 +32,17 @@ inline uint32_t udf_get_pblock(struct super_block *sb, uint32_t block,
uint16_t partition, uint32_t offset) uint16_t partition, uint32_t offset)
{ {
if (partition >= UDF_SB_NUMPARTS(sb)) { if (partition >= UDF_SB_NUMPARTS(sb)) {
udf_debug udf_debug("block=%d, partition=%d, offset=%d: invalid partition\n",
("block=%d, partition=%d, offset=%d: invalid partition\n",
block, partition, offset); block, partition, offset);
return 0xFFFFFFFF; return 0xFFFFFFFF;
} }
if (UDF_SB_PARTFUNC(sb, partition)) if (UDF_SB_PARTFUNC(sb, partition))
return UDF_SB_PARTFUNC(sb, partition) (sb, block, partition, return UDF_SB_PARTFUNC(sb, partition)(sb, block, partition, offset);
offset);
else else
return UDF_SB_PARTROOT(sb, partition) + block + offset; return UDF_SB_PARTROOT(sb, partition) + block + offset;
} }
uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block, uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,
uint16_t partition, uint32_t offset) uint16_t partition, uint32_t offset)
{ {
struct buffer_head *bh = NULL; struct buffer_head *bh = NULL;
...@@ -52,14 +50,11 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block, ...@@ -52,14 +50,11 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block,
uint32_t index; uint32_t index;
uint32_t loc; uint32_t loc;
index = index = (sb->s_blocksize - UDF_SB_TYPEVIRT(sb,partition).s_start_offset) / sizeof(uint32_t);
(sb->s_blocksize -
UDF_SB_TYPEVIRT(sb, partition).s_start_offset) / sizeof(uint32_t);
if (block > UDF_SB_TYPEVIRT(sb, partition).s_num_entries) { if (block > UDF_SB_TYPEVIRT(sb,partition).s_num_entries) {
udf_debug udf_debug("Trying to access block beyond end of VAT (%d max %d)\n",
("Trying to access block beyond end of VAT (%d max %d)\n", block, UDF_SB_TYPEVIRT(sb,partition).s_num_entries);
block, UDF_SB_TYPEVIRT(sb, partition).s_num_entries);
return 0xFFFFFFFF; return 0xFFFFFFFF;
} }
...@@ -69,10 +64,7 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block, ...@@ -69,10 +64,7 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block,
index = block % (sb->s_blocksize / sizeof(uint32_t)); index = block % (sb->s_blocksize / sizeof(uint32_t));
} else { } else {
newblock = 0; newblock = 0;
index = index = UDF_SB_TYPEVIRT(sb,partition).s_start_offset / sizeof(uint32_t) + block;
UDF_SB_TYPEVIRT(sb,
partition).s_start_offset /
sizeof(uint32_t) + block;
} }
loc = udf_block_map(UDF_SB_VAT(sb), newblock); loc = udf_block_map(UDF_SB_VAT(sb), newblock);
...@@ -83,7 +75,7 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block, ...@@ -83,7 +75,7 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block,
return 0xFFFFFFFF; return 0xFFFFFFFF;
} }
loc = le32_to_cpu(((__le32 *) bh->b_data)[index]); loc = le32_to_cpu(((__le32 *)bh->b_data)[index]);
brelse(bh); brelse(bh);
...@@ -93,8 +85,8 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block, ...@@ -93,8 +85,8 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block,
} }
return udf_get_pblock(sb, loc, return udf_get_pblock(sb, loc,
UDF_I_LOCATION(UDF_SB_VAT(sb)). UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum,
partitionReferenceNum, offset); offset);
} }
inline uint32_t udf_get_pblock_virt20(struct super_block * sb, uint32_t block, inline uint32_t udf_get_pblock_virt20(struct super_block * sb, uint32_t block,
...@@ -108,40 +100,29 @@ uint32_t udf_get_pblock_spar15(struct super_block * sb, uint32_t block, ...@@ -108,40 +100,29 @@ uint32_t udf_get_pblock_spar15(struct super_block * sb, uint32_t block,
{ {
int i; int i;
struct sparingTable *st = NULL; struct sparingTable *st = NULL;
uint32_t packet = uint32_t packet = (block + offset) & ~(UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1);
(block + offset) & ~(UDF_SB_TYPESPAR(sb, partition).s_packet_len -
1);
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (UDF_SB_TYPESPAR(sb, partition).s_spar_map[i] != NULL) { if (UDF_SB_TYPESPAR(sb,partition).s_spar_map[i] != NULL) {
st = (struct sparingTable *)UDF_SB_TYPESPAR(sb, st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,partition).s_spar_map[i]->b_data;
partition).
s_spar_map[i]->b_data;
break; break;
} }
} }
if (st) { if (st) {
for (i = 0; i < le16_to_cpu(st->reallocationTableLen); i++) { for (i = 0; i < le16_to_cpu(st->reallocationTableLen); i++) {
if (le32_to_cpu(st->mapEntry[i].origLocation) >= if (le32_to_cpu(st->mapEntry[i].origLocation) >= 0xFFFFFFF0) {
0xFFFFFFF0)
break; break;
else if (le32_to_cpu(st->mapEntry[i].origLocation) == } else if (le32_to_cpu(st->mapEntry[i].origLocation) == packet) {
packet) { return le32_to_cpu(st->mapEntry[i].mappedLocation) +
return le32_to_cpu(st->mapEntry[i]. ((block + offset) & (UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1));
mappedLocation) + ((block + } else if (le32_to_cpu(st->mapEntry[i].origLocation) > packet) {
offset) &
(UDF_SB_TYPESPAR
(sb,
partition).
s_packet_len
- 1));
} else if (le32_to_cpu(st->mapEntry[i].origLocation) >
packet)
break; break;
} }
} }
return UDF_SB_PARTROOT(sb, partition) + block + offset; }
return UDF_SB_PARTROOT(sb,partition) + block + offset;
} }
int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
...@@ -153,20 +134,14 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) ...@@ -153,20 +134,14 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
int i, j, k, l; int i, j, k, l;
for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) {
if (old_block > UDF_SB_PARTROOT(sb, i) && if (old_block > UDF_SB_PARTROOT(sb,i) &&
old_block < UDF_SB_PARTROOT(sb, i) + UDF_SB_PARTLEN(sb, i)) old_block < UDF_SB_PARTROOT(sb,i) + UDF_SB_PARTLEN(sb,i)) {
{ sdata = &UDF_SB_TYPESPAR(sb,i);
sdata = &UDF_SB_TYPESPAR(sb, i); packet = (old_block - UDF_SB_PARTROOT(sb,i)) & ~(sdata->s_packet_len - 1);
packet =
(old_block -
UDF_SB_PARTROOT(sb,
i)) & ~(sdata->s_packet_len - 1);
for (j = 0; j < 4; j++) { for (j = 0; j < 4; j++) {
if (UDF_SB_TYPESPAR(sb, i).s_spar_map[j] != if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL) {
NULL) { st = (struct sparingTable *)sdata->s_spar_map[j]->b_data;
st = (struct sparingTable *)sdata->
s_spar_map[j]->b_data;
break; break;
} }
} }
...@@ -174,122 +149,51 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) ...@@ -174,122 +149,51 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
if (!st) if (!st)
return 1; return 1;
for (k = 0; k < le16_to_cpu(st->reallocationTableLen); for (k = 0; k < le16_to_cpu(st->reallocationTableLen); k++) {
k++) { if (le32_to_cpu(st->mapEntry[k].origLocation) == 0xFFFFFFFF) {
if (le32_to_cpu(st->mapEntry[k].origLocation) ==
0xFFFFFFFF) {
for (; j < 4; j++) { for (; j < 4; j++) {
if (sdata->s_spar_map[j]) { if (sdata->s_spar_map[j]) {
st = (struct st = (struct sparingTable *)sdata->s_spar_map[j]->b_data;
sparingTable *) st->mapEntry[k].origLocation = cpu_to_le32(packet);
sdata-> udf_update_tag((char *)st, sizeof(struct sparingTable) + le16_to_cpu(st->reallocationTableLen) * sizeof(struct sparingEntry));
s_spar_map[j]-> mark_buffer_dirty(sdata->s_spar_map[j]);
b_data;
st->mapEntry[k].
origLocation =
cpu_to_le32(packet);
udf_update_tag((char *)
st,
sizeof
(struct
sparingTable)
+
le16_to_cpu
(st->
reallocationTableLen)
*
sizeof
(struct
sparingEntry));
mark_buffer_dirty
(sdata->
s_spar_map[j]);
} }
} }
*new_block = *new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) +
le32_to_cpu(st->mapEntry[k]. ((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1));
mappedLocation) +
((old_block -
UDF_SB_PARTROOT(sb,
i)) & (sdata->
s_packet_len
- 1));
return 0; return 0;
} else } else if (le32_to_cpu(st->mapEntry[k].origLocation) == packet) {
if (le32_to_cpu *new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) +
(st->mapEntry[k].origLocation) == ((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1));
packet) {
*new_block =
le32_to_cpu(st->mapEntry[k].
mappedLocation) +
((old_block -
UDF_SB_PARTROOT(sb,
i)) & (sdata->
s_packet_len
- 1));
return 0; return 0;
} else } else if (le32_to_cpu(st->mapEntry[k].origLocation) > packet) {
if (le32_to_cpu
(st->mapEntry[k].origLocation) > packet)
break; break;
} }
for (l = k; l < le16_to_cpu(st->reallocationTableLen); }
l++) {
if (le32_to_cpu(st->mapEntry[l].origLocation) == for (l = k; l < le16_to_cpu(st->reallocationTableLen); l++) {
0xFFFFFFFF) { if (le32_to_cpu(st->mapEntry[l].origLocation) == 0xFFFFFFFF) {
for (; j < 4; j++) { for (; j < 4; j++) {
if (sdata->s_spar_map[j]) { if (sdata->s_spar_map[j]) {
st = (struct st = (struct sparingTable *)sdata->s_spar_map[j]->b_data;
sparingTable *) mapEntry = st->mapEntry[l];
sdata-> mapEntry.origLocation = cpu_to_le32(packet);
s_spar_map[j]-> memmove(&st->mapEntry[k + 1], &st->mapEntry[k], (l - k) * sizeof(struct sparingEntry));
b_data; st->mapEntry[k] = mapEntry;
mapEntry = udf_update_tag((char *)st, sizeof(struct sparingTable) + le16_to_cpu(st->reallocationTableLen) * sizeof(struct sparingEntry));
st->mapEntry[l]; mark_buffer_dirty(sdata->s_spar_map[j]);
mapEntry.origLocation =
cpu_to_le32(packet);
memmove(&st->
mapEntry[k + 1],
&st->
mapEntry[k],
(l -
k) *
sizeof(struct
sparingEntry));
st->mapEntry[k] =
mapEntry;
udf_update_tag((char *)
st,
sizeof
(struct
sparingTable)
+
le16_to_cpu
(st->
reallocationTableLen)
*
sizeof
(struct
sparingEntry));
mark_buffer_dirty
(sdata->
s_spar_map[j]);
} }
} }
*new_block = *new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) +
le32_to_cpu(st->mapEntry[k]. ((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1));
mappedLocation) +
((old_block -
UDF_SB_PARTROOT(sb,
i)) & (sdata->
s_packet_len
- 1));
return 0; return 0;
} }
} }
return 1; return 1;
} /* if old_block */
} }
}
if (i == UDF_SB_NUMPARTS(sb)) { if (i == UDF_SB_NUMPARTS(sb)) {
/* outside of partitions */ /* outside of partitions */
/* for now, fail =) */ /* for now, fail =) */
......
This diff is collapsed.
...@@ -33,8 +33,7 @@ ...@@ -33,8 +33,7 @@
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include "udf_i.h" #include "udf_i.h"
static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen, static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen, char *to)
char *to)
{ {
struct pathComponent *pc; struct pathComponent *pc;
int elen = 0; int elen = 0;
...@@ -81,9 +80,9 @@ static int udf_symlink_filler(struct file *file, struct page *page) ...@@ -81,9 +80,9 @@ static int udf_symlink_filler(struct file *file, struct page *page)
char *p = kmap(page); char *p = kmap(page);
lock_kernel(); lock_kernel();
if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) {
symlink = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode); symlink = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode);
else { } else {
bh = sb_bread(inode->i_sb, udf_block_map(inode, 0)); bh = sb_bread(inode->i_sb, udf_block_map(inode, 0));
if (!bh) if (!bh)
...@@ -100,7 +99,8 @@ static int udf_symlink_filler(struct file *file, struct page *page) ...@@ -100,7 +99,8 @@ static int udf_symlink_filler(struct file *file, struct page *page)
kunmap(page); kunmap(page);
unlock_page(page); unlock_page(page);
return 0; return 0;
out:
out:
unlock_kernel(); unlock_kernel();
SetPageError(page); SetPageError(page);
kunmap(page); kunmap(page);
......
...@@ -32,13 +32,11 @@ static void extent_trunc(struct inode *inode, struct extent_position *epos, ...@@ -32,13 +32,11 @@ static void extent_trunc(struct inode *inode, struct extent_position *epos,
kernel_lb_addr eloc, int8_t etype, uint32_t elen, kernel_lb_addr eloc, int8_t etype, uint32_t elen,
uint32_t nelen) uint32_t nelen)
{ {
kernel_lb_addr neloc = { 0, 0 }; kernel_lb_addr neloc = {};
int last_block = int last_block = (elen + inode->i_sb->s_blocksize - 1) >>
(elen + inode->i_sb->s_blocksize - inode->i_sb->s_blocksize_bits;
1) >> inode->i_sb->s_blocksize_bits; int first_block = (nelen + inode->i_sb->s_blocksize - 1) >>
int first_block = inode->i_sb->s_blocksize_bits;
(nelen + inode->i_sb->s_blocksize -
1) >> inode->i_sb->s_blocksize_bits;
if (nelen) { if (nelen) {
if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) {
...@@ -70,7 +68,7 @@ static void extent_trunc(struct inode *inode, struct extent_position *epos, ...@@ -70,7 +68,7 @@ static void extent_trunc(struct inode *inode, struct extent_position *epos,
*/ */
void udf_truncate_tail_extent(struct inode *inode) void udf_truncate_tail_extent(struct inode *inode)
{ {
struct extent_position epos = { NULL, 0, {0, 0} }; struct extent_position epos = {};
kernel_lb_addr eloc; kernel_lb_addr eloc;
uint32_t elen, nelen; uint32_t elen, nelen;
uint64_t lbcount = 0; uint64_t lbcount = 0;
...@@ -164,8 +162,8 @@ void udf_discard_prealloc(struct inode *inode) ...@@ -164,8 +162,8 @@ void udf_discard_prealloc(struct inode *inode)
aed->lengthAllocDescs = aed->lengthAllocDescs =
cpu_to_le32(epos.offset - cpu_to_le32(epos.offset -
sizeof(struct allocExtDesc)); sizeof(struct allocExtDesc));
if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) ||
|| UDF_SB_UDFREV(inode->i_sb) >= 0x0201) UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
udf_update_tag(epos.bh->b_data, epos.offset); udf_update_tag(epos.bh->b_data, epos.offset);
else else
udf_update_tag(epos.bh->b_data, udf_update_tag(epos.bh->b_data,
...@@ -182,7 +180,7 @@ void udf_discard_prealloc(struct inode *inode) ...@@ -182,7 +180,7 @@ void udf_discard_prealloc(struct inode *inode)
void udf_truncate_extents(struct inode *inode) void udf_truncate_extents(struct inode *inode)
{ {
struct extent_position epos; struct extent_position epos;
kernel_lb_addr eloc, neloc = { 0, 0 }; kernel_lb_addr eloc, neloc = {};
uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc; uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc;
int8_t etype; int8_t etype;
struct super_block *sb = inode->i_sb; struct super_block *sb = inode->i_sb;
...@@ -198,8 +196,7 @@ void udf_truncate_extents(struct inode *inode) ...@@ -198,8 +196,7 @@ void udf_truncate_extents(struct inode *inode)
BUG(); BUG();
etype = inode_bmap(inode, first_block, &epos, &eloc, &elen, &offset); etype = inode_bmap(inode, first_block, &epos, &eloc, &elen, &offset);
byte_offset = byte_offset = (offset << sb->s_blocksize_bits) +
(offset << sb->s_blocksize_bits) +
(inode->i_size & (sb->s_blocksize - 1)); (inode->i_size & (sb->s_blocksize - 1));
if (etype != -1) { if (etype != -1) {
epos.offset -= adsize; epos.offset -= adsize;
...@@ -215,9 +212,7 @@ void udf_truncate_extents(struct inode *inode) ...@@ -215,9 +212,7 @@ void udf_truncate_extents(struct inode *inode)
else else
lenalloc -= sizeof(struct allocExtDesc); lenalloc -= sizeof(struct allocExtDesc);
while ((etype = while ((etype = udf_current_aext(inode, &epos, &eloc, &elen, 0)) != -1) {
udf_current_aext(inode, &epos, &eloc, &elen,
0)) != -1) {
if (etype == (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) { if (etype == (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) {
udf_write_aext(inode, &epos, neloc, nelen, 0); udf_write_aext(inode, &epos, neloc, nelen, 0);
if (indirect_ext_len) { if (indirect_ext_len) {
...@@ -229,52 +224,35 @@ void udf_truncate_extents(struct inode *inode) ...@@ -229,52 +224,35 @@ void udf_truncate_extents(struct inode *inode)
0, indirect_ext_len); 0, indirect_ext_len);
} else { } else {
if (!epos.bh) { if (!epos.bh) {
UDF_I_LENALLOC(inode) = UDF_I_LENALLOC(inode) = lenalloc;
lenalloc;
mark_inode_dirty(inode); mark_inode_dirty(inode);
} else { } else {
struct allocExtDesc *aed = struct allocExtDesc *aed =
(struct allocExtDesc (struct allocExtDesc *)(epos.bh->b_data);
*)(epos.bh->b_data);
aed->lengthAllocDescs = aed->lengthAllocDescs =
cpu_to_le32(lenalloc); cpu_to_le32(lenalloc);
if (!UDF_QUERY_FLAG if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) ||
(sb, UDF_FLAG_STRICT) UDF_SB_UDFREV(sb) >= 0x0201)
|| UDF_SB_UDFREV(sb) >= udf_update_tag(epos.bh->b_data,
0x0201) lenalloc +
udf_update_tag(epos.bh-> sizeof(struct allocExtDesc));
b_data,
lenalloc
+
sizeof
(struct
allocExtDesc));
else else
udf_update_tag(epos.bh-> udf_update_tag(epos.bh->b_data,
b_data, sizeof(struct allocExtDesc));
sizeof mark_buffer_dirty_inode(epos.bh, inode);
(struct
allocExtDesc));
mark_buffer_dirty_inode(epos.bh,
inode);
} }
} }
brelse(epos.bh); brelse(epos.bh);
epos.offset = sizeof(struct allocExtDesc); epos.offset = sizeof(struct allocExtDesc);
epos.block = eloc; epos.block = eloc;
epos.bh = epos.bh = udf_tread(sb, udf_get_lb_pblock(sb, eloc, 0));
udf_tread(sb,
udf_get_lb_pblock(sb, eloc, 0));
if (elen) if (elen)
indirect_ext_len = (elen + indirect_ext_len = (elen + sb->s_blocksize -1) >>
sb->s_blocksize - sb->s_blocksize_bits;
1) >> sb->
s_blocksize_bits;
else else
indirect_ext_len = 1; indirect_ext_len = 1;
} else { } else {
extent_trunc(inode, &epos, eloc, etype, elen, extent_trunc(inode, &epos, eloc, etype, elen, 0);
0);
epos.offset += adsize; epos.offset += adsize;
} }
} }
...@@ -292,16 +270,13 @@ void udf_truncate_extents(struct inode *inode) ...@@ -292,16 +270,13 @@ void udf_truncate_extents(struct inode *inode)
struct allocExtDesc *aed = struct allocExtDesc *aed =
(struct allocExtDesc *)(epos.bh->b_data); (struct allocExtDesc *)(epos.bh->b_data);
aed->lengthAllocDescs = cpu_to_le32(lenalloc); aed->lengthAllocDescs = cpu_to_le32(lenalloc);
if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) ||
|| UDF_SB_UDFREV(sb) >= 0x0201) UDF_SB_UDFREV(sb) >= 0x0201)
udf_update_tag(epos.bh->b_data, udf_update_tag(epos.bh->b_data,
lenalloc + lenalloc + sizeof(struct allocExtDesc));
sizeof(struct
allocExtDesc));
else else
udf_update_tag(epos.bh->b_data, udf_update_tag(epos.bh->b_data,
sizeof(struct sizeof(struct allocExtDesc));
allocExtDesc));
mark_buffer_dirty_inode(epos.bh, inode); mark_buffer_dirty_inode(epos.bh, inode);
} }
} }
...@@ -314,21 +289,14 @@ void udf_truncate_extents(struct inode *inode) ...@@ -314,21 +289,14 @@ void udf_truncate_extents(struct inode *inode)
* no extent above inode->i_size => truncate is * no extent above inode->i_size => truncate is
* extending the file by 'offset' blocks. * extending the file by 'offset' blocks.
*/ */
if ((!epos.bh if ((!epos.bh &&
&& epos.offset == epos.offset == udf_file_entry_alloc_offset(inode)) ||
udf_file_entry_alloc_offset(inode)) || (epos.bh (epos.bh && epos.offset == sizeof(struct allocExtDesc))) {
&& epos.
offset ==
sizeof
(struct
allocExtDesc)))
{
/* File has no extents at all or has empty last /* File has no extents at all or has empty last
* indirect extent! Create a fake extent... */ * indirect extent! Create a fake extent... */
extent.extLocation.logicalBlockNum = 0; extent.extLocation.logicalBlockNum = 0;
extent.extLocation.partitionReferenceNum = 0; extent.extLocation.partitionReferenceNum = 0;
extent.extLength = extent.extLength = EXT_NOT_RECORDED_NOT_ALLOCATED;
EXT_NOT_RECORDED_NOT_ALLOCATED;
} else { } else {
epos.offset -= adsize; epos.offset -= adsize;
etype = udf_next_aext(inode, &epos, etype = udf_next_aext(inode, &epos,
...@@ -337,10 +305,7 @@ void udf_truncate_extents(struct inode *inode) ...@@ -337,10 +305,7 @@ void udf_truncate_extents(struct inode *inode)
extent.extLength |= etype << 30; extent.extLength |= etype << 30;
} }
udf_extend_file(inode, &epos, &extent, udf_extend_file(inode, &epos, &extent,
offset + offset + ((inode->i_size & (sb->s_blocksize - 1)) != 0));
((inode->
i_size & (sb->s_blocksize - 1)) !=
0));
} }
} }
UDF_I_LENEXTENTS(inode) = inode->i_size; UDF_I_LENEXTENTS(inode) = inode->i_size;
......
...@@ -41,8 +41,7 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb) ...@@ -41,8 +41,7 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
#define UDF_SB_FREE(X)\ #define UDF_SB_FREE(X)\
{\ {\
if (UDF_SB(X))\ if (UDF_SB(X)) {\
{\
kfree(UDF_SB_PARTMAPS(X));\ kfree(UDF_SB_PARTMAPS(X));\
UDF_SB_PARTMAPS(X) = NULL;\ UDF_SB_PARTMAPS(X) = NULL;\
}\ }\
...@@ -51,13 +50,10 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb) ...@@ -51,13 +50,10 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
#define UDF_SB_ALLOC_PARTMAPS(X,Y)\ #define UDF_SB_ALLOC_PARTMAPS(X,Y)\
{\ {\
UDF_SB_PARTMAPS(X) = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\ UDF_SB_PARTMAPS(X) = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
if (UDF_SB_PARTMAPS(X) != NULL)\ if (UDF_SB_PARTMAPS(X) != NULL) {\
{\
UDF_SB_NUMPARTS(X) = Y;\ UDF_SB_NUMPARTS(X) = Y;\
memset(UDF_SB_PARTMAPS(X), 0x00, sizeof(struct udf_part_map) * Y);\ memset(UDF_SB_PARTMAPS(X), 0x00, sizeof(struct udf_part_map) * Y);\
}\ } else {\
else\
{\
UDF_SB_NUMPARTS(X) = 0;\ UDF_SB_NUMPARTS(X) = 0;\
udf_error(X, __FUNCTION__, "Unable to allocate space for %d partition maps", Y);\ udf_error(X, __FUNCTION__, "Unable to allocate space for %d partition maps", Y);\
}\ }\
...@@ -72,15 +68,12 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb) ...@@ -72,15 +68,12 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = kmalloc(size, GFP_KERNEL);\ UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = kmalloc(size, GFP_KERNEL);\
else\ else\
UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = vmalloc(size);\ UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = vmalloc(size);\
if (UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap != NULL)\ if (UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap != NULL) {\
{\
memset(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap, 0x00, size);\ memset(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap, 0x00, size);\
UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_block_bitmap =\ UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_block_bitmap =\
(struct buffer_head **)(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap + 1);\ (struct buffer_head **)(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap + 1);\
UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_nr_groups = nr_groups;\ UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_nr_groups = nr_groups;\
}\ } else {\
else\
{\
udf_error(X, __FUNCTION__, "Unable to allocate space for bitmap and %d buffer_head pointers", nr_groups);\ udf_error(X, __FUNCTION__, "Unable to allocate space for bitmap and %d buffer_head pointers", nr_groups);\
}\ }\
} }
...@@ -90,8 +83,7 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb) ...@@ -90,8 +83,7 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
int i;\ int i;\
int nr_groups = UDF_SB_BITMAP_NR_GROUPS(X,Y,Z);\ int nr_groups = UDF_SB_BITMAP_NR_GROUPS(X,Y,Z);\
int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * nr_groups);\ int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * nr_groups);\
for (i=0; i<nr_groups; i++)\ for (i = 0; i < nr_groups; i++) {\
{\
if (UDF_SB_BITMAP(X,Y,Z,i))\ if (UDF_SB_BITMAP(X,Y,Z,i))\
brelse(UDF_SB_BITMAP(X,Y,Z,i));\ brelse(UDF_SB_BITMAP(X,Y,Z,i));\
}\ }\
......
...@@ -7,74 +7,92 @@ ...@@ -7,74 +7,92 @@
static inline kernel_lb_addr lelb_to_cpu(lb_addr in) static inline kernel_lb_addr lelb_to_cpu(lb_addr in)
{ {
kernel_lb_addr out; kernel_lb_addr out;
out.logicalBlockNum = le32_to_cpu(in.logicalBlockNum); out.logicalBlockNum = le32_to_cpu(in.logicalBlockNum);
out.partitionReferenceNum = le16_to_cpu(in.partitionReferenceNum); out.partitionReferenceNum = le16_to_cpu(in.partitionReferenceNum);
return out; return out;
} }
static inline lb_addr cpu_to_lelb(kernel_lb_addr in) static inline lb_addr cpu_to_lelb(kernel_lb_addr in)
{ {
lb_addr out; lb_addr out;
out.logicalBlockNum = cpu_to_le32(in.logicalBlockNum); out.logicalBlockNum = cpu_to_le32(in.logicalBlockNum);
out.partitionReferenceNum = cpu_to_le16(in.partitionReferenceNum); out.partitionReferenceNum = cpu_to_le16(in.partitionReferenceNum);
return out; return out;
} }
static inline kernel_timestamp lets_to_cpu(timestamp in) static inline kernel_timestamp lets_to_cpu(timestamp in)
{ {
kernel_timestamp out; kernel_timestamp out;
memcpy(&out, &in, sizeof(timestamp)); memcpy(&out, &in, sizeof(timestamp));
out.typeAndTimezone = le16_to_cpu(in.typeAndTimezone); out.typeAndTimezone = le16_to_cpu(in.typeAndTimezone);
out.year = le16_to_cpu(in.year); out.year = le16_to_cpu(in.year);
return out; return out;
} }
static inline short_ad lesa_to_cpu(short_ad in) static inline short_ad lesa_to_cpu(short_ad in)
{ {
short_ad out; short_ad out;
out.extLength = le32_to_cpu(in.extLength); out.extLength = le32_to_cpu(in.extLength);
out.extPosition = le32_to_cpu(in.extPosition); out.extPosition = le32_to_cpu(in.extPosition);
return out; return out;
} }
static inline short_ad cpu_to_lesa(short_ad in) static inline short_ad cpu_to_lesa(short_ad in)
{ {
short_ad out; short_ad out;
out.extLength = cpu_to_le32(in.extLength); out.extLength = cpu_to_le32(in.extLength);
out.extPosition = cpu_to_le32(in.extPosition); out.extPosition = cpu_to_le32(in.extPosition);
return out; return out;
} }
static inline kernel_long_ad lela_to_cpu(long_ad in) static inline kernel_long_ad lela_to_cpu(long_ad in)
{ {
kernel_long_ad out; kernel_long_ad out;
out.extLength = le32_to_cpu(in.extLength); out.extLength = le32_to_cpu(in.extLength);
out.extLocation = lelb_to_cpu(in.extLocation); out.extLocation = lelb_to_cpu(in.extLocation);
return out; return out;
} }
static inline long_ad cpu_to_lela(kernel_long_ad in) static inline long_ad cpu_to_lela(kernel_long_ad in)
{ {
long_ad out; long_ad out;
out.extLength = cpu_to_le32(in.extLength); out.extLength = cpu_to_le32(in.extLength);
out.extLocation = cpu_to_lelb(in.extLocation); out.extLocation = cpu_to_lelb(in.extLocation);
return out; return out;
} }
static inline kernel_extent_ad leea_to_cpu(extent_ad in) static inline kernel_extent_ad leea_to_cpu(extent_ad in)
{ {
kernel_extent_ad out; kernel_extent_ad out;
out.extLength = le32_to_cpu(in.extLength); out.extLength = le32_to_cpu(in.extLength);
out.extLocation = le32_to_cpu(in.extLocation); out.extLocation = le32_to_cpu(in.extLocation);
return out; return out;
} }
static inline timestamp cpu_to_lets(kernel_timestamp in) static inline timestamp cpu_to_lets(kernel_timestamp in)
{ {
timestamp out; timestamp out;
memcpy(&out, &in, sizeof(timestamp)); memcpy(&out, &in, sizeof(timestamp));
out.typeAndTimezone = cpu_to_le16(in.typeAndTimezone); out.typeAndTimezone = cpu_to_le16(in.typeAndTimezone);
out.year = cpu_to_le16(in.year); out.year = cpu_to_le16(in.year);
return out; return out;
} }
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
* blf 09/27/99: ripped out all the old code and inserted new table from * blf 09/27/99: ripped out all the old code and inserted new table from
* John Brockmeyer (without leap second corrections) * John Brockmeyer (without leap second corrections)
* rewrote udf_stamp_to_time and fixed timezone accounting in * rewrote udf_stamp_to_time and fixed timezone accounting in
udf_time_to_stamp. * udf_time_to_stamp.
*/ */
/* /*
...@@ -57,25 +57,25 @@ static const unsigned short int __mon_yday[2][13] = { ...@@ -57,25 +57,25 @@ static const unsigned short int __mon_yday[2][13] = {
#define SPD 0x15180 /*3600*24 */ #define SPD 0x15180 /*3600*24 */
#define SPY(y,l,s) (SPD * (365*y+l)+s) #define SPY(y,l,s) (SPD * (365*y+l)+s)
static time_t year_seconds[MAX_YEAR_SECONDS] = { static time_t year_seconds[MAX_YEAR_SECONDS]= {
/*1970*/ SPY(0, 0, 0), SPY(1, 0, 0), SPY(2, 0, 0), SPY(3, 1, 0), /*1970*/ SPY( 0, 0,0), SPY( 1, 0,0), SPY( 2, 0,0), SPY( 3, 1,0),
/*1974*/ SPY(4, 1, 0), SPY(5, 1, 0), SPY(6, 1, 0), SPY(7, 2, 0), /*1974*/ SPY( 4, 1,0), SPY( 5, 1,0), SPY( 6, 1,0), SPY( 7, 2,0),
/*1978*/ SPY(8, 2, 0), SPY(9, 2, 0), SPY(10, 2, 0), SPY(11, 3, 0), /*1978*/ SPY( 8, 2,0), SPY( 9, 2,0), SPY(10, 2,0), SPY(11, 3,0),
/*1982*/ SPY(12, 3, 0), SPY(13, 3, 0), SPY(14, 3, 0), SPY(15, 4, 0), /*1982*/ SPY(12, 3,0), SPY(13, 3,0), SPY(14, 3,0), SPY(15, 4,0),
/*1986*/ SPY(16, 4, 0), SPY(17, 4, 0), SPY(18, 4, 0), SPY(19, 5, 0), /*1986*/ SPY(16, 4,0), SPY(17, 4,0), SPY(18, 4,0), SPY(19, 5,0),
/*1990*/ SPY(20, 5, 0), SPY(21, 5, 0), SPY(22, 5, 0), SPY(23, 6, 0), /*1990*/ SPY(20, 5,0), SPY(21, 5,0), SPY(22, 5,0), SPY(23, 6,0),
/*1994*/ SPY(24, 6, 0), SPY(25, 6, 0), SPY(26, 6, 0), SPY(27, 7, 0), /*1994*/ SPY(24, 6,0), SPY(25, 6,0), SPY(26, 6,0), SPY(27, 7,0),
/*1998*/ SPY(28, 7, 0), SPY(29, 7, 0), SPY(30, 7, 0), SPY(31, 8, 0), /*1998*/ SPY(28, 7,0), SPY(29, 7,0), SPY(30, 7,0), SPY(31, 8,0),
/*2002*/ SPY(32, 8, 0), SPY(33, 8, 0), SPY(34, 8, 0), SPY(35, 9, 0), /*2002*/ SPY(32, 8,0), SPY(33, 8,0), SPY(34, 8,0), SPY(35, 9,0),
/*2006*/ SPY(36, 9, 0), SPY(37, 9, 0), SPY(38, 9, 0), SPY(39, 10, 0), /*2006*/ SPY(36, 9,0), SPY(37, 9,0), SPY(38, 9,0), SPY(39,10,0),
/*2010*/ SPY(40, 10, 0), SPY(41, 10, 0), SPY(42, 10, 0), SPY(43, 11, 0), /*2010*/ SPY(40,10,0), SPY(41,10,0), SPY(42,10,0), SPY(43,11,0),
/*2014*/ SPY(44, 11, 0), SPY(45, 11, 0), SPY(46, 11, 0), SPY(47, 12, 0), /*2014*/ SPY(44,11,0), SPY(45,11,0), SPY(46,11,0), SPY(47,12,0),
/*2018*/ SPY(48, 12, 0), SPY(49, 12, 0), SPY(50, 12, 0), SPY(51, 13, 0), /*2018*/ SPY(48,12,0), SPY(49,12,0), SPY(50,12,0), SPY(51,13,0),
/*2022*/ SPY(52, 13, 0), SPY(53, 13, 0), SPY(54, 13, 0), SPY(55, 14, 0), /*2022*/ SPY(52,13,0), SPY(53,13,0), SPY(54,13,0), SPY(55,14,0),
/*2026*/ SPY(56, 14, 0), SPY(57, 14, 0), SPY(58, 14, 0), SPY(59, 15, 0), /*2026*/ SPY(56,14,0), SPY(57,14,0), SPY(58,14,0), SPY(59,15,0),
/*2030*/ SPY(60, 15, 0), SPY(61, 15, 0), SPY(62, 15, 0), SPY(63, 16, 0), /*2030*/ SPY(60,15,0), SPY(61,15,0), SPY(62,15,0), SPY(63,16,0),
/*2034*/ SPY(64, 16, 0), SPY(65, 16, 0), SPY(66, 16, 0), SPY(67, 17, 0), /*2034*/ SPY(64,16,0), SPY(65,16,0), SPY(66,16,0), SPY(67,17,0),
/*2038*/ SPY(68, 17, 0) /*2038*/ SPY(68,17,0)
}; };
extern struct timezone sys_tz; extern struct timezone sys_tz;
...@@ -83,7 +83,7 @@ extern struct timezone sys_tz; ...@@ -83,7 +83,7 @@ extern struct timezone sys_tz;
#define SECS_PER_HOUR (60 * 60) #define SECS_PER_HOUR (60 * 60)
#define SECS_PER_DAY (SECS_PER_HOUR * 24) #define SECS_PER_DAY (SECS_PER_HOUR * 24)
time_t *udf_stamp_to_time(time_t * dest, long *dest_usec, kernel_timestamp src) time_t *udf_stamp_to_time(time_t *dest, long *dest_usec, kernel_timestamp src)
{ {
int yday; int yday;
uint8_t type = src.typeAndTimezone >> 12; uint8_t type = src.typeAndTimezone >> 12;
...@@ -95,8 +95,9 @@ time_t *udf_stamp_to_time(time_t * dest, long *dest_usec, kernel_timestamp src) ...@@ -95,8 +95,9 @@ time_t *udf_stamp_to_time(time_t * dest, long *dest_usec, kernel_timestamp src)
offset = (offset >> 4); offset = (offset >> 4);
if (offset == -2047) /* unspecified offset */ if (offset == -2047) /* unspecified offset */
offset = 0; offset = 0;
} else } else {
offset = 0; offset = 0;
}
if ((src.year < EPOCH_YEAR) || if ((src.year < EPOCH_YEAR) ||
(src.year >= EPOCH_YEAR + MAX_YEAR_SECONDS)) { (src.year >= EPOCH_YEAR + MAX_YEAR_SECONDS)) {
...@@ -107,12 +108,10 @@ time_t *udf_stamp_to_time(time_t * dest, long *dest_usec, kernel_timestamp src) ...@@ -107,12 +108,10 @@ time_t *udf_stamp_to_time(time_t * dest, long *dest_usec, kernel_timestamp src)
*dest = year_seconds[src.year - EPOCH_YEAR]; *dest = year_seconds[src.year - EPOCH_YEAR];
*dest -= offset * 60; *dest -= offset * 60;
yday = ((__mon_yday[__isleap(src.year)] yday = ((__mon_yday[__isleap (src.year)]
[src.month - 1]) + (src.day - 1)); [src.month - 1]) + (src.day - 1));
*dest += (((yday * 24) + src.hour) * 60 + src.minute) * 60 + src.second; *dest += ( ( (yday * 24) + src.hour ) * 60 + src.minute ) * 60 + src.second;
*dest_usec = *dest_usec = src.centiseconds * 10000 + src.hundredsOfMicroseconds * 100 + src.microseconds;
src.centiseconds * 10000 + src.hundredsOfMicroseconds * 100 +
src.microseconds;
return dest; return dest;
} }
...@@ -145,8 +144,9 @@ kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts) ...@@ -145,8 +144,9 @@ kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts)
long int yg = y + days / 365 - (days % 365 < 0); long int yg = y + days / 365 - (days % 365 < 0);
/* Adjust DAYS and Y to match the guessed year. */ /* Adjust DAYS and Y to match the guessed year. */
days -= ((yg - y) * 365 + LEAPS_THRU_END_OF(yg - 1) days -= ((yg - y) * 365
- LEAPS_THRU_END_OF(y - 1)); + LEAPS_THRU_END_OF (yg - 1)
- LEAPS_THRU_END_OF (y - 1));
y = yg; y = yg;
} }
dest->year = y; dest->year = y;
...@@ -158,10 +158,8 @@ kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts) ...@@ -158,10 +158,8 @@ kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts)
dest->day = days + 1; dest->day = days + 1;
dest->centiseconds = ts.tv_nsec / 10000000; dest->centiseconds = ts.tv_nsec / 10000000;
dest->hundredsOfMicroseconds = dest->hundredsOfMicroseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000) / 100;
(ts.tv_nsec / 1000 - dest->centiseconds * 10000) / 100; dest->microseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000 -
dest->microseconds =
(ts.tv_nsec / 1000 - dest->centiseconds * 10000 -
dest->hundredsOfMicroseconds * 100); dest->hundredsOfMicroseconds * 100);
return dest; return dest;
} }
......
This diff is collapsed.
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