Commit 03c3fa0a authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-udf-2.6

* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-udf-2.6:
  udf: Don't write integrity descriptor too often
  udf: Try anchor in block 256 first
  udf: Some type fixes and cleanups
  udf: use hardware sector size
  udf: fix novrs mount option
  udf: Fix oops when invalid character in filename occurs
  udf: return f_fsid for statfs(2)
  udf: Add checks to not underflow sector_t
  udf: fix default mode and dmode options handling
  udf: fix sparse warnings:
  udf: unsigned last[i] cannot be less than 0
  udf: implement mode and dmode mounting options
  udf: reduce stack usage of udf_get_filename
  udf: reduce stack usage of udf_load_pvoldesc
  Fix the udf code not to pass structs on stack where possible.
  Remove struct typedefs from fs/udf/ecma_167.h et al.
parents 3e850509 146bca72
...@@ -24,6 +24,8 @@ The following mount options are supported: ...@@ -24,6 +24,8 @@ The following mount options are supported:
gid= Set the default group. gid= Set the default group.
umask= Set the default umask. umask= Set the default umask.
mode= Set the default file permissions.
dmode= Set the default directory permissions.
uid= Set the default user. uid= Set the default user.
bs= Set the block size. bs= Set the block size.
unhide Show otherwise hidden files. unhide Show otherwise hidden files.
......
This diff is collapsed.
...@@ -51,7 +51,7 @@ static int do_udf_readdir(struct inode *dir, struct file *filp, ...@@ -51,7 +51,7 @@ static int do_udf_readdir(struct inode *dir, struct file *filp,
uint8_t lfi; uint8_t lfi;
loff_t size = udf_ext0_offset(dir) + dir->i_size; loff_t size = udf_ext0_offset(dir) + dir->i_size;
struct buffer_head *tmp, *bha[16]; struct buffer_head *tmp, *bha[16];
kernel_lb_addr eloc; struct kernel_lb_addr eloc;
uint32_t elen; uint32_t elen;
sector_t offset; sector_t offset;
int i, num, ret = 0; int i, num, ret = 0;
...@@ -80,13 +80,13 @@ static int do_udf_readdir(struct inode *dir, struct file *filp, ...@@ -80,13 +80,13 @@ static int do_udf_readdir(struct inode *dir, struct file *filp,
ret = -ENOENT; ret = -ENOENT;
goto out; goto out;
} }
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 (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
epos.offset -= sizeof(short_ad); epos.offset -= sizeof(struct short_ad);
else if (iinfo->i_alloc_type == else if (iinfo->i_alloc_type ==
ICBTAG_FLAG_AD_LONG) ICBTAG_FLAG_AD_LONG)
epos.offset -= sizeof(long_ad); epos.offset -= sizeof(struct long_ad);
} else { } else {
offset = 0; offset = 0;
} }
...@@ -101,7 +101,7 @@ static int do_udf_readdir(struct inode *dir, struct file *filp, ...@@ -101,7 +101,7 @@ static int do_udf_readdir(struct inode *dir, struct file *filp,
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) - offset; i = (elen >> dir->i_sb->s_blocksize_bits) - offset;
for (num = 0; i > 0; i--) { for (num = 0; i > 0; i--) {
block = udf_get_lb_pblock(dir->i_sb, eloc, offset + i); block = 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) && !buffer_locked(tmp)) if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp))
bha[num++] = tmp; bha[num++] = tmp;
...@@ -161,9 +161,9 @@ static int do_udf_readdir(struct inode *dir, struct file *filp, ...@@ -161,9 +161,9 @@ static int do_udf_readdir(struct inode *dir, struct file *filp,
memcpy(fname, "..", flen); memcpy(fname, "..", flen);
dt_type = DT_DIR; dt_type = DT_DIR;
} else { } else {
kernel_lb_addr tloc = lelb_to_cpu(cfi.icb.extLocation); struct kernel_lb_addr tloc = lelb_to_cpu(cfi.icb.extLocation);
iblock = udf_get_lb_pblock(dir->i_sb, tloc, 0); iblock = udf_get_lb_pblock(dir->i_sb, &tloc, 0);
flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi); flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi);
dt_type = DT_UNKNOWN; dt_type = DT_UNKNOWN;
} }
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#if 0 #if 0
static uint8_t *udf_filead_read(struct inode *dir, uint8_t *tmpad, static uint8_t *udf_filead_read(struct inode *dir, uint8_t *tmpad,
uint8_t ad_size, kernel_lb_addr fe_loc, uint8_t ad_size, struct kernel_lb_addr fe_loc,
int *pos, int *offset, struct buffer_head **bh, int *pos, int *offset, struct buffer_head **bh,
int *error) int *error)
{ {
...@@ -75,7 +75,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos, ...@@ -75,7 +75,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
struct udf_fileident_bh *fibh, struct udf_fileident_bh *fibh,
struct fileIdentDesc *cfi, struct fileIdentDesc *cfi,
struct extent_position *epos, struct extent_position *epos,
kernel_lb_addr *eloc, uint32_t *elen, struct kernel_lb_addr *eloc, uint32_t *elen,
sector_t *offset) sector_t *offset)
{ {
struct fileIdentDesc *fi; struct fileIdentDesc *fi;
...@@ -111,7 +111,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos, ...@@ -111,7 +111,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
(EXT_RECORDED_ALLOCATED >> 30)) (EXT_RECORDED_ALLOCATED >> 30))
return NULL; return NULL;
block = udf_get_lb_pblock(dir->i_sb, *eloc, *offset); block = udf_get_lb_pblock(dir->i_sb, eloc, *offset);
(*offset)++; (*offset)++;
...@@ -131,7 +131,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos, ...@@ -131,7 +131,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
if (i + *offset > (*elen >> blocksize_bits)) if (i + *offset > (*elen >> blocksize_bits))
i = (*elen >> blocksize_bits)-*offset; i = (*elen >> blocksize_bits)-*offset;
for (num = 0; i > 0; i--) { for (num = 0; i > 0; i--) {
block = udf_get_lb_pblock(dir->i_sb, *eloc, block = udf_get_lb_pblock(dir->i_sb, eloc,
*offset + i); *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) &&
...@@ -169,7 +169,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos, ...@@ -169,7 +169,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
(EXT_RECORDED_ALLOCATED >> 30)) (EXT_RECORDED_ALLOCATED >> 30))
return NULL; return NULL;
block = udf_get_lb_pblock(dir->i_sb, *eloc, *offset); block = udf_get_lb_pblock(dir->i_sb, eloc, *offset);
(*offset)++; (*offset)++;
...@@ -249,9 +249,9 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset) ...@@ -249,9 +249,9 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
} }
#if 0 #if 0
static extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset) static struct extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset)
{ {
extent_ad *ext; struct extent_ad *ext;
struct fileEntry *fe; struct fileEntry *fe;
uint8_t *ptr; uint8_t *ptr;
...@@ -274,54 +274,54 @@ static extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset) ...@@ -274,54 +274,54 @@ static extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset)
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 = (struct extent_ad *)ptr;
*offset = *offset + sizeof(extent_ad); *offset = *offset + sizeof(struct extent_ad);
return ext; return ext;
} }
#endif #endif
short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offset, struct short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offset,
int inc) int inc)
{ {
short_ad *sa; struct short_ad *sa;
if ((!ptr) || (!offset)) { if ((!ptr) || (!offset)) {
printk(KERN_ERR "udf: udf_get_fileshortad() invalidparms\n"); printk(KERN_ERR "udf: udf_get_fileshortad() invalidparms\n");
return NULL; return NULL;
} }
if ((*offset + sizeof(short_ad)) > maxoffset) if ((*offset + sizeof(struct short_ad)) > maxoffset)
return NULL; return NULL;
else { else {
sa = (short_ad *)ptr; sa = (struct short_ad *)ptr;
if (sa->extLength == 0) if (sa->extLength == 0)
return NULL; return NULL;
} }
if (inc) if (inc)
*offset += sizeof(short_ad); *offset += sizeof(struct short_ad);
return sa; return sa;
} }
long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, uint32_t *offset, int inc) struct long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, uint32_t *offset, int inc)
{ {
long_ad *la; struct long_ad *la;
if ((!ptr) || (!offset)) { if ((!ptr) || (!offset)) {
printk(KERN_ERR "udf: udf_get_filelongad() invalidparms\n"); printk(KERN_ERR "udf: udf_get_filelongad() invalidparms\n");
return NULL; return NULL;
} }
if ((*offset + sizeof(long_ad)) > maxoffset) if ((*offset + sizeof(struct long_ad)) > maxoffset)
return NULL; return NULL;
else { else {
la = (long_ad *)ptr; la = (struct long_ad *)ptr;
if (la->extLength == 0) if (la->extLength == 0)
return NULL; return NULL;
} }
if (inc) if (inc)
*offset += sizeof(long_ad); *offset += sizeof(struct long_ad);
return la; return la;
} }
This diff is collapsed.
...@@ -49,12 +49,11 @@ void udf_free_inode(struct inode *inode) ...@@ -49,12 +49,11 @@ void udf_free_inode(struct inode *inode)
le32_add_cpu(&lvidiu->numDirs, -1); le32_add_cpu(&lvidiu->numDirs, -1);
else else
le32_add_cpu(&lvidiu->numFiles, -1); le32_add_cpu(&lvidiu->numFiles, -1);
udf_updated_lvid(sb);
mark_buffer_dirty(sbi->s_lvid_bh);
} }
mutex_unlock(&sbi->s_alloc_mutex); mutex_unlock(&sbi->s_alloc_mutex);
udf_free_blocks(sb, NULL, UDF_I(inode)->i_location, 0, 1); udf_free_blocks(sb, NULL, &UDF_I(inode)->i_location, 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)
...@@ -122,7 +121,7 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) ...@@ -122,7 +121,7 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
if (!(++uniqueID & 0x00000000FFFFFFFFUL)) if (!(++uniqueID & 0x00000000FFFFFFFFUL))
uniqueID += 16; uniqueID += 16;
lvhd->uniqueID = cpu_to_le64(uniqueID); lvhd->uniqueID = cpu_to_le64(uniqueID);
mark_buffer_dirty(sbi->s_lvid_bh); udf_updated_lvid(sb);
} }
mutex_unlock(&sbi->s_alloc_mutex); mutex_unlock(&sbi->s_alloc_mutex);
inode->i_mode = mode; inode->i_mode = mode;
...@@ -138,7 +137,7 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err) ...@@ -138,7 +137,7 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
iinfo->i_location.logicalBlockNum = block; iinfo->i_location.logicalBlockNum = block;
iinfo->i_location.partitionReferenceNum = iinfo->i_location.partitionReferenceNum =
dinfo->i_location.partitionReferenceNum; dinfo->i_location.partitionReferenceNum;
inode->i_ino = udf_get_lb_pblock(sb, iinfo->i_location, 0); inode->i_ino = udf_get_lb_pblock(sb, &iinfo->i_location, 0);
inode->i_blocks = 0; inode->i_blocks = 0;
iinfo->i_lenEAttr = 0; iinfo->i_lenEAttr = 0;
iinfo->i_lenAlloc = 0; iinfo->i_lenAlloc = 0;
......
This diff is collapsed.
...@@ -134,10 +134,10 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, ...@@ -134,10 +134,10 @@ 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(struct tag);
eahd->descTag.descCRCLength = cpu_to_le16(crclen); eahd->descTag.descCRCLength = cpu_to_le16(crclen);
eahd->descTag.descCRC = cpu_to_le16(crc_itu_t(0, (char *)eahd + eahd->descTag.descCRC = cpu_to_le16(crc_itu_t(0, (char *)eahd +
sizeof(tag), crclen)); sizeof(struct tag), crclen));
eahd->descTag.tagChecksum = udf_tag_checksum(&eahd->descTag); eahd->descTag.tagChecksum = udf_tag_checksum(&eahd->descTag);
iinfo->i_lenEAttr += size; iinfo->i_lenEAttr += size;
return (struct genericFormat *)&ea[offset]; return (struct genericFormat *)&ea[offset];
...@@ -202,7 +202,7 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type, ...@@ -202,7 +202,7 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
uint32_t location, uint16_t *ident) uint32_t location, uint16_t *ident)
{ {
tag *tag_p; struct tag *tag_p;
struct buffer_head *bh = NULL; struct buffer_head *bh = NULL;
/* Read the block */ /* Read the block */
...@@ -216,7 +216,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, ...@@ -216,7 +216,7 @@ 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 = (struct tag *)(bh->b_data);
*ident = le16_to_cpu(tag_p->tagIdent); *ident = le16_to_cpu(tag_p->tagIdent);
...@@ -241,9 +241,9 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, ...@@ -241,9 +241,9 @@ 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(struct tag) > sb->s_blocksize ||
le16_to_cpu(tag_p->descCRC) == crc_itu_t(0, le16_to_cpu(tag_p->descCRC) == crc_itu_t(0,
bh->b_data + sizeof(tag), bh->b_data + sizeof(struct tag),
le16_to_cpu(tag_p->descCRCLength))) le16_to_cpu(tag_p->descCRCLength)))
return bh; return bh;
...@@ -255,27 +255,28 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block, ...@@ -255,27 +255,28 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
return NULL; return NULL;
} }
struct buffer_head *udf_read_ptagged(struct super_block *sb, kernel_lb_addr loc, struct buffer_head *udf_read_ptagged(struct super_block *sb,
struct kernel_lb_addr *loc,
uint32_t offset, uint16_t *ident) uint32_t offset, uint16_t *ident)
{ {
return udf_read_tagged(sb, udf_get_lb_pblock(sb, loc, offset), return udf_read_tagged(sb, udf_get_lb_pblock(sb, loc, offset),
loc.logicalBlockNum + offset, ident); loc->logicalBlockNum + offset, ident);
} }
void udf_update_tag(char *data, int length) void udf_update_tag(char *data, int length)
{ {
tag *tptr = (tag *)data; struct tag *tptr = (struct tag *)data;
length -= sizeof(tag); length -= sizeof(struct tag);
tptr->descCRCLength = cpu_to_le16(length); tptr->descCRCLength = cpu_to_le16(length);
tptr->descCRC = cpu_to_le16(crc_itu_t(0, data + sizeof(tag), length)); tptr->descCRC = cpu_to_le16(crc_itu_t(0, data + sizeof(struct tag), length));
tptr->tagChecksum = udf_tag_checksum(tptr); tptr->tagChecksum = udf_tag_checksum(tptr);
} }
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; struct tag *tptr = (struct 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);
...@@ -283,12 +284,12 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum, ...@@ -283,12 +284,12 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
udf_update_tag(data, length); udf_update_tag(data, length);
} }
u8 udf_tag_checksum(const tag *t) u8 udf_tag_checksum(const struct tag *t)
{ {
u8 *data = (u8 *)t; u8 *data = (u8 *)t;
u8 checksum = 0; u8 checksum = 0;
int i; int i;
for (i = 0; i < sizeof(tag); ++i) for (i = 0; i < sizeof(struct tag); ++i)
if (i != 4) /* position of checksum */ if (i != 4) /* position of checksum */
checksum += data[i]; checksum += data[i];
return checksum; return checksum;
......
This diff is collapsed.
...@@ -85,7 +85,7 @@ struct appIdentSuffix { ...@@ -85,7 +85,7 @@ struct appIdentSuffix {
/* Logical Volume Integrity Descriptor (UDF 2.50 2.2.6) */ /* Logical Volume Integrity Descriptor (UDF 2.50 2.2.6) */
/* Implementation Use (UDF 2.50 2.2.6.4) */ /* Implementation Use (UDF 2.50 2.2.6.4) */
struct logicalVolIntegrityDescImpUse { struct logicalVolIntegrityDescImpUse {
regid impIdent; struct regid impIdent;
__le32 numFiles; __le32 numFiles;
__le32 numDirs; __le32 numDirs;
__le16 minUDFReadRev; __le16 minUDFReadRev;
...@@ -97,12 +97,12 @@ struct logicalVolIntegrityDescImpUse { ...@@ -97,12 +97,12 @@ struct logicalVolIntegrityDescImpUse {
/* Implementation Use Volume Descriptor (UDF 2.50 2.2.7) */ /* Implementation Use Volume Descriptor (UDF 2.50 2.2.7) */
/* Implementation Use (UDF 2.50 2.2.7.2) */ /* Implementation Use (UDF 2.50 2.2.7.2) */
struct impUseVolDescImpUse { struct impUseVolDescImpUse {
charspec LVICharset; struct charspec LVICharset;
dstring logicalVolIdent[128]; dstring logicalVolIdent[128];
dstring LVInfo1[36]; dstring LVInfo1[36];
dstring LVInfo2[36]; dstring LVInfo2[36];
dstring LVInfo3[36]; dstring LVInfo3[36];
regid impIdent; struct regid impIdent;
uint8_t impUse[128]; uint8_t impUse[128];
} __attribute__ ((packed)); } __attribute__ ((packed));
...@@ -110,7 +110,7 @@ struct udfPartitionMap2 { ...@@ -110,7 +110,7 @@ struct udfPartitionMap2 {
uint8_t partitionMapType; uint8_t partitionMapType;
uint8_t partitionMapLength; uint8_t partitionMapLength;
uint8_t reserved1[2]; uint8_t reserved1[2];
regid partIdent; struct regid partIdent;
__le16 volSeqNum; __le16 volSeqNum;
__le16 partitionNum; __le16 partitionNum;
} __attribute__ ((packed)); } __attribute__ ((packed));
...@@ -120,7 +120,7 @@ struct virtualPartitionMap { ...@@ -120,7 +120,7 @@ struct virtualPartitionMap {
uint8_t partitionMapType; uint8_t partitionMapType;
uint8_t partitionMapLength; uint8_t partitionMapLength;
uint8_t reserved1[2]; uint8_t reserved1[2];
regid partIdent; struct regid partIdent;
__le16 volSeqNum; __le16 volSeqNum;
__le16 partitionNum; __le16 partitionNum;
uint8_t reserved2[24]; uint8_t reserved2[24];
...@@ -131,7 +131,7 @@ struct sparablePartitionMap { ...@@ -131,7 +131,7 @@ struct sparablePartitionMap {
uint8_t partitionMapType; uint8_t partitionMapType;
uint8_t partitionMapLength; uint8_t partitionMapLength;
uint8_t reserved1[2]; uint8_t reserved1[2];
regid partIdent; struct regid partIdent;
__le16 volSeqNum; __le16 volSeqNum;
__le16 partitionNum; __le16 partitionNum;
__le16 packetLength; __le16 packetLength;
...@@ -146,7 +146,7 @@ struct metadataPartitionMap { ...@@ -146,7 +146,7 @@ struct metadataPartitionMap {
uint8_t partitionMapType; uint8_t partitionMapType;
uint8_t partitionMapLength; uint8_t partitionMapLength;
uint8_t reserved1[2]; uint8_t reserved1[2];
regid partIdent; struct regid partIdent;
__le16 volSeqNum; __le16 volSeqNum;
__le16 partitionNum; __le16 partitionNum;
__le32 metadataFileLoc; __le32 metadataFileLoc;
...@@ -161,7 +161,7 @@ struct metadataPartitionMap { ...@@ -161,7 +161,7 @@ struct metadataPartitionMap {
/* Virtual Allocation Table (UDF 1.5 2.2.10) */ /* Virtual Allocation Table (UDF 1.5 2.2.10) */
struct virtualAllocationTable15 { struct virtualAllocationTable15 {
__le32 VirtualSector[0]; __le32 VirtualSector[0];
regid vatIdent; struct regid vatIdent;
__le32 previousVATICBLoc; __le32 previousVATICBLoc;
} __attribute__ ((packed)); } __attribute__ ((packed));
...@@ -192,8 +192,8 @@ struct sparingEntry { ...@@ -192,8 +192,8 @@ struct sparingEntry {
} __attribute__ ((packed)); } __attribute__ ((packed));
struct sparingTable { struct sparingTable {
tag descTag; struct tag descTag;
regid sparingIdent; struct regid sparingIdent;
__le16 reallocationTableLen; __le16 reallocationTableLen;
__le16 reserved; __le16 reserved;
__le32 sequenceNum; __le32 sequenceNum;
...@@ -206,7 +206,7 @@ struct sparingTable { ...@@ -206,7 +206,7 @@ struct sparingTable {
#define ICBTAG_FILE_TYPE_MIRROR 0xFB #define ICBTAG_FILE_TYPE_MIRROR 0xFB
#define ICBTAG_FILE_TYPE_BITMAP 0xFC #define ICBTAG_FILE_TYPE_BITMAP 0xFC
/* struct long_ad ICB - ADImpUse (UDF 2.50 2.2.4.3) */ /* struct struct long_ad ICB - ADImpUse (UDF 2.50 2.2.4.3) */
struct allocDescImpUse { struct allocDescImpUse {
__le16 flags; __le16 flags;
uint8_t impUse[4]; uint8_t impUse[4];
......
...@@ -273,7 +273,7 @@ static uint32_t udf_try_read_meta(struct inode *inode, uint32_t block, ...@@ -273,7 +273,7 @@ static uint32_t udf_try_read_meta(struct inode *inode, uint32_t block,
{ {
struct super_block *sb = inode->i_sb; struct super_block *sb = inode->i_sb;
struct udf_part_map *map; struct udf_part_map *map;
kernel_lb_addr eloc; struct kernel_lb_addr eloc;
uint32_t elen; uint32_t elen;
sector_t ext_offset; sector_t ext_offset;
struct extent_position epos = {}; struct extent_position epos = {};
......
This diff is collapsed.
...@@ -28,10 +28,10 @@ ...@@ -28,10 +28,10 @@
#include "udf_sb.h" #include "udf_sb.h"
static void extent_trunc(struct inode *inode, struct extent_position *epos, static void extent_trunc(struct inode *inode, struct extent_position *epos,
kernel_lb_addr eloc, int8_t etype, uint32_t elen, struct kernel_lb_addr *eloc, int8_t etype, uint32_t elen,
uint32_t nelen) uint32_t nelen)
{ {
kernel_lb_addr neloc = {}; struct kernel_lb_addr neloc = {};
int last_block = (elen + inode->i_sb->s_blocksize - 1) >> int last_block = (elen + inode->i_sb->s_blocksize - 1) >>
inode->i_sb->s_blocksize_bits; inode->i_sb->s_blocksize_bits;
int first_block = (nelen + inode->i_sb->s_blocksize - 1) >> int first_block = (nelen + inode->i_sb->s_blocksize - 1) >>
...@@ -43,12 +43,12 @@ static void extent_trunc(struct inode *inode, struct extent_position *epos, ...@@ -43,12 +43,12 @@ static void extent_trunc(struct inode *inode, struct extent_position *epos,
last_block); last_block);
etype = (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30); etype = (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30);
} else } else
neloc = eloc; neloc = *eloc;
nelen = (etype << 30) | nelen; nelen = (etype << 30) | nelen;
} }
if (elen != nelen) { if (elen != nelen) {
udf_write_aext(inode, epos, neloc, nelen, 0); udf_write_aext(inode, epos, &neloc, nelen, 0);
if (last_block - first_block > 0) { if (last_block - first_block > 0) {
if (etype == (EXT_RECORDED_ALLOCATED >> 30)) if (etype == (EXT_RECORDED_ALLOCATED >> 30))
mark_inode_dirty(inode); mark_inode_dirty(inode);
...@@ -68,7 +68,7 @@ static void extent_trunc(struct inode *inode, struct extent_position *epos, ...@@ -68,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 = {}; struct extent_position epos = {};
kernel_lb_addr eloc; struct kernel_lb_addr eloc;
uint32_t elen, nelen; uint32_t elen, nelen;
uint64_t lbcount = 0; uint64_t lbcount = 0;
int8_t etype = -1, netype; int8_t etype = -1, netype;
...@@ -83,9 +83,9 @@ void udf_truncate_tail_extent(struct inode *inode) ...@@ -83,9 +83,9 @@ void udf_truncate_tail_extent(struct inode *inode)
return; return;
if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
adsize = sizeof(short_ad); adsize = sizeof(struct short_ad);
else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
adsize = sizeof(long_ad); adsize = sizeof(struct long_ad);
else else
BUG(); BUG();
...@@ -106,7 +106,7 @@ void udf_truncate_tail_extent(struct inode *inode) ...@@ -106,7 +106,7 @@ void udf_truncate_tail_extent(struct inode *inode)
(unsigned)elen); (unsigned)elen);
nelen = elen - (lbcount - inode->i_size); nelen = elen - (lbcount - inode->i_size);
epos.offset -= adsize; epos.offset -= adsize;
extent_trunc(inode, &epos, eloc, etype, elen, nelen); extent_trunc(inode, &epos, &eloc, etype, elen, nelen);
epos.offset += adsize; epos.offset += adsize;
if (udf_next_aext(inode, &epos, &eloc, &elen, 1) != -1) if (udf_next_aext(inode, &epos, &eloc, &elen, 1) != -1)
printk(KERN_ERR "udf_truncate_tail_extent(): " printk(KERN_ERR "udf_truncate_tail_extent(): "
...@@ -124,7 +124,7 @@ void udf_truncate_tail_extent(struct inode *inode) ...@@ -124,7 +124,7 @@ void udf_truncate_tail_extent(struct inode *inode)
void udf_discard_prealloc(struct inode *inode) void udf_discard_prealloc(struct inode *inode)
{ {
struct extent_position epos = { NULL, 0, {0, 0} }; struct extent_position epos = { NULL, 0, {0, 0} };
kernel_lb_addr eloc; struct kernel_lb_addr eloc;
uint32_t elen; uint32_t elen;
uint64_t lbcount = 0; uint64_t lbcount = 0;
int8_t etype = -1, netype; int8_t etype = -1, netype;
...@@ -136,9 +136,9 @@ void udf_discard_prealloc(struct inode *inode) ...@@ -136,9 +136,9 @@ void udf_discard_prealloc(struct inode *inode)
return; return;
if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
adsize = sizeof(short_ad); adsize = sizeof(struct short_ad);
else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
adsize = sizeof(long_ad); adsize = sizeof(struct long_ad);
else else
adsize = 0; adsize = 0;
...@@ -152,7 +152,7 @@ void udf_discard_prealloc(struct inode *inode) ...@@ -152,7 +152,7 @@ void udf_discard_prealloc(struct inode *inode)
if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) {
epos.offset -= adsize; epos.offset -= adsize;
lbcount -= elen; lbcount -= elen;
extent_trunc(inode, &epos, eloc, etype, elen, 0); extent_trunc(inode, &epos, &eloc, etype, elen, 0);
if (!epos.bh) { if (!epos.bh) {
iinfo->i_lenAlloc = iinfo->i_lenAlloc =
epos.offset - epos.offset -
...@@ -200,7 +200,7 @@ static void udf_update_alloc_ext_desc(struct inode *inode, ...@@ -200,7 +200,7 @@ static void udf_update_alloc_ext_desc(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 = {}; struct 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;
...@@ -210,9 +210,9 @@ void udf_truncate_extents(struct inode *inode) ...@@ -210,9 +210,9 @@ void udf_truncate_extents(struct inode *inode)
struct udf_inode_info *iinfo = UDF_I(inode); struct udf_inode_info *iinfo = UDF_I(inode);
if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
adsize = sizeof(short_ad); adsize = sizeof(struct short_ad);
else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
adsize = sizeof(long_ad); adsize = sizeof(struct long_ad);
else else
BUG(); BUG();
...@@ -221,7 +221,7 @@ void udf_truncate_extents(struct inode *inode) ...@@ -221,7 +221,7 @@ void udf_truncate_extents(struct inode *inode)
(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;
extent_trunc(inode, &epos, eloc, etype, elen, byte_offset); extent_trunc(inode, &epos, &eloc, etype, elen, byte_offset);
epos.offset += adsize; epos.offset += adsize;
if (byte_offset) if (byte_offset)
lenalloc = epos.offset; lenalloc = epos.offset;
...@@ -236,12 +236,12 @@ void udf_truncate_extents(struct inode *inode) ...@@ -236,12 +236,12 @@ void udf_truncate_extents(struct inode *inode)
while ((etype = udf_current_aext(inode, &epos, &eloc, while ((etype = udf_current_aext(inode, &epos, &eloc,
&elen, 0)) != -1) { &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) {
/* We managed to free all extents in the /* We managed to free all extents in the
* indirect extent - free it too */ * indirect extent - free it too */
BUG_ON(!epos.bh); BUG_ON(!epos.bh);
udf_free_blocks(sb, inode, epos.block, udf_free_blocks(sb, inode, &epos.block,
0, indirect_ext_len); 0, indirect_ext_len);
} else if (!epos.bh) { } else if (!epos.bh) {
iinfo->i_lenAlloc = lenalloc; iinfo->i_lenAlloc = lenalloc;
...@@ -253,7 +253,7 @@ void udf_truncate_extents(struct inode *inode) ...@@ -253,7 +253,7 @@ void udf_truncate_extents(struct inode *inode)
epos.offset = sizeof(struct allocExtDesc); epos.offset = sizeof(struct allocExtDesc);
epos.block = eloc; epos.block = eloc;
epos.bh = udf_tread(sb, epos.bh = udf_tread(sb,
udf_get_lb_pblock(sb, eloc, 0)); udf_get_lb_pblock(sb, &eloc, 0));
if (elen) if (elen)
indirect_ext_len = indirect_ext_len =
(elen + sb->s_blocksize - 1) >> (elen + sb->s_blocksize - 1) >>
...@@ -261,7 +261,7 @@ void udf_truncate_extents(struct inode *inode) ...@@ -261,7 +261,7 @@ void udf_truncate_extents(struct inode *inode)
else else
indirect_ext_len = 1; indirect_ext_len = 1;
} else { } else {
extent_trunc(inode, &epos, eloc, etype, extent_trunc(inode, &epos, &eloc, etype,
elen, 0); elen, 0);
epos.offset += adsize; epos.offset += adsize;
} }
...@@ -269,7 +269,7 @@ void udf_truncate_extents(struct inode *inode) ...@@ -269,7 +269,7 @@ void udf_truncate_extents(struct inode *inode)
if (indirect_ext_len) { if (indirect_ext_len) {
BUG_ON(!epos.bh); BUG_ON(!epos.bh);
udf_free_blocks(sb, inode, epos.block, 0, udf_free_blocks(sb, inode, &epos.block, 0,
indirect_ext_len); indirect_ext_len);
} else if (!epos.bh) { } else if (!epos.bh) {
iinfo->i_lenAlloc = lenalloc; iinfo->i_lenAlloc = lenalloc;
...@@ -278,7 +278,7 @@ void udf_truncate_extents(struct inode *inode) ...@@ -278,7 +278,7 @@ void udf_truncate_extents(struct inode *inode)
udf_update_alloc_ext_desc(inode, &epos, lenalloc); udf_update_alloc_ext_desc(inode, &epos, lenalloc);
} else if (inode->i_size) { } else if (inode->i_size) {
if (byte_offset) { if (byte_offset) {
kernel_long_ad extent; struct kernel_long_ad extent;
/* /*
* OK, there is not extent covering inode->i_size and * OK, there is not extent covering inode->i_size and
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
struct udf_inode_info { struct udf_inode_info {
struct timespec i_crtime; struct timespec i_crtime;
/* Physical address of inode */ /* Physical address of inode */
kernel_lb_addr i_location; struct kernel_lb_addr i_location;
__u64 i_unique; __u64 i_unique;
__u32 i_lenEAttr; __u32 i_lenEAttr;
__u32 i_lenAlloc; __u32 i_lenAlloc;
...@@ -17,8 +17,8 @@ struct udf_inode_info { ...@@ -17,8 +17,8 @@ struct udf_inode_info {
unsigned i_strat4096 : 1; unsigned i_strat4096 : 1;
unsigned reserved : 26; unsigned reserved : 26;
union { union {
short_ad *i_sad; struct short_ad *i_sad;
long_ad *i_lad; struct long_ad *i_lad;
__u8 *i_data; __u8 *i_data;
} i_ext; } i_ext;
struct inode vfs_inode; struct inode vfs_inode;
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#define UDF_FLAG_GID_SET 16 #define UDF_FLAG_GID_SET 16
#define UDF_FLAG_SESSION_SET 17 #define UDF_FLAG_SESSION_SET 17
#define UDF_FLAG_LASTBLOCK_SET 18 #define UDF_FLAG_LASTBLOCK_SET 18
#define UDF_FLAG_BLOCKSIZE_SET 19
#define UDF_PART_FLAG_UNALLOC_BITMAP 0x0001 #define UDF_PART_FLAG_UNALLOC_BITMAP 0x0001
#define UDF_PART_FLAG_UNALLOC_TABLE 0x0002 #define UDF_PART_FLAG_UNALLOC_TABLE 0x0002
...@@ -48,6 +49,8 @@ ...@@ -48,6 +49,8 @@
#define UDF_SPARABLE_MAP15 0x1522U #define UDF_SPARABLE_MAP15 0x1522U
#define UDF_METADATA_MAP25 0x2511U #define UDF_METADATA_MAP25 0x2511U
#define UDF_INVALID_MODE ((mode_t)-1)
#pragma pack(1) /* XXX(hch): Why? This file just defines in-core structures */ #pragma pack(1) /* XXX(hch): Why? This file just defines in-core structures */
struct udf_meta_data { struct udf_meta_data {
...@@ -114,7 +117,7 @@ struct udf_sb_info { ...@@ -114,7 +117,7 @@ struct udf_sb_info {
/* Sector headers */ /* Sector headers */
__s32 s_session; __s32 s_session;
__u32 s_anchor[3]; __u32 s_anchor;
__u32 s_last_block; __u32 s_last_block;
struct buffer_head *s_lvid_bh; struct buffer_head *s_lvid_bh;
...@@ -123,6 +126,8 @@ struct udf_sb_info { ...@@ -123,6 +126,8 @@ struct udf_sb_info {
mode_t s_umask; mode_t s_umask;
gid_t s_gid; gid_t s_gid;
uid_t s_uid; uid_t s_uid;
mode_t s_fmode;
mode_t s_dmode;
/* Root Info */ /* Root Info */
struct timespec s_record_time; struct timespec s_record_time;
...@@ -143,6 +148,8 @@ struct udf_sb_info { ...@@ -143,6 +148,8 @@ struct udf_sb_info {
struct inode *s_vat_inode; struct inode *s_vat_inode;
struct mutex s_alloc_mutex; struct mutex s_alloc_mutex;
/* Protected by s_alloc_mutex */
unsigned int s_lvid_dirty;
}; };
static inline struct udf_sb_info *UDF_SB(struct super_block *sb) static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
......
...@@ -62,10 +62,8 @@ static inline size_t udf_ext0_offset(struct inode *inode) ...@@ -62,10 +62,8 @@ static inline size_t udf_ext0_offset(struct inode *inode)
return 0; return 0;
} }
#define udf_get_lb_pblock(sb,loc,offset) udf_get_pblock((sb), (loc).logicalBlockNum, (loc).partitionReferenceNum, (offset))
/* computes tag checksum */ /* computes tag checksum */
u8 udf_tag_checksum(const tag *t); u8 udf_tag_checksum(const struct tag *t);
struct dentry; struct dentry;
struct inode; struct inode;
...@@ -95,7 +93,7 @@ struct udf_vds_record { ...@@ -95,7 +93,7 @@ struct udf_vds_record {
}; };
struct generic_desc { struct generic_desc {
tag descTag; struct tag descTag;
__le32 volDescSeqNum; __le32 volDescSeqNum;
}; };
...@@ -108,11 +106,22 @@ struct ustr { ...@@ -108,11 +106,22 @@ struct ustr {
struct extent_position { struct extent_position {
struct buffer_head *bh; struct buffer_head *bh;
uint32_t offset; uint32_t offset;
kernel_lb_addr block; struct kernel_lb_addr block;
}; };
/* super.c */ /* super.c */
extern void udf_warning(struct super_block *, const char *, const char *, ...); extern void udf_warning(struct super_block *, const char *, const char *, ...);
static inline void udf_updated_lvid(struct super_block *sb)
{
struct buffer_head *bh = UDF_SB(sb)->s_lvid_bh;
BUG_ON(!bh);
WARN_ON_ONCE(((struct logicalVolIntegrityDesc *)
bh->b_data)->integrityType !=
cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN));
sb->s_dirt = 1;
UDF_SB(sb)->s_lvid_dirty = 1;
}
/* namei.c */ /* namei.c */
extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *, extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *,
...@@ -124,7 +133,7 @@ extern int udf_ioctl(struct inode *, struct file *, unsigned int, ...@@ -124,7 +133,7 @@ extern int udf_ioctl(struct inode *, struct file *, unsigned int,
unsigned long); unsigned long);
/* inode.c */ /* inode.c */
extern struct inode *udf_iget(struct super_block *, kernel_lb_addr); extern struct inode *udf_iget(struct super_block *, struct kernel_lb_addr *);
extern int udf_sync_inode(struct inode *); extern int udf_sync_inode(struct inode *);
extern void udf_expand_file_adinicb(struct inode *, int, int *); extern void udf_expand_file_adinicb(struct inode *, int, int *);
extern struct buffer_head *udf_expand_dir_adinicb(struct inode *, int *, int *); extern struct buffer_head *udf_expand_dir_adinicb(struct inode *, int *, int *);
...@@ -136,19 +145,19 @@ extern void udf_clear_inode(struct inode *); ...@@ -136,19 +145,19 @@ extern void udf_clear_inode(struct inode *);
extern int udf_write_inode(struct inode *, int); extern int udf_write_inode(struct inode *, int);
extern long udf_block_map(struct inode *, sector_t); extern long udf_block_map(struct inode *, sector_t);
extern int udf_extend_file(struct inode *, struct extent_position *, extern int udf_extend_file(struct inode *, struct extent_position *,
kernel_long_ad *, sector_t); struct kernel_long_ad *, sector_t);
extern int8_t inode_bmap(struct inode *, sector_t, struct extent_position *, extern int8_t inode_bmap(struct inode *, sector_t, struct extent_position *,
kernel_lb_addr *, uint32_t *, sector_t *); struct kernel_lb_addr *, uint32_t *, sector_t *);
extern int8_t udf_add_aext(struct inode *, struct extent_position *, extern int8_t udf_add_aext(struct inode *, struct extent_position *,
kernel_lb_addr, uint32_t, int); struct kernel_lb_addr *, uint32_t, int);
extern int8_t udf_write_aext(struct inode *, struct extent_position *, extern int8_t udf_write_aext(struct inode *, struct extent_position *,
kernel_lb_addr, uint32_t, int); struct kernel_lb_addr *, uint32_t, int);
extern int8_t udf_delete_aext(struct inode *, struct extent_position, extern int8_t udf_delete_aext(struct inode *, struct extent_position,
kernel_lb_addr, uint32_t); struct kernel_lb_addr, uint32_t);
extern int8_t udf_next_aext(struct inode *, struct extent_position *, extern int8_t udf_next_aext(struct inode *, struct extent_position *,
kernel_lb_addr *, uint32_t *, int); struct kernel_lb_addr *, uint32_t *, int);
extern int8_t udf_current_aext(struct inode *, struct extent_position *, extern int8_t udf_current_aext(struct inode *, struct extent_position *,
kernel_lb_addr *, uint32_t *, int); struct kernel_lb_addr *, uint32_t *, int);
/* misc.c */ /* misc.c */
extern struct buffer_head *udf_tgetblk(struct super_block *, int); extern struct buffer_head *udf_tgetblk(struct super_block *, int);
...@@ -160,7 +169,7 @@ extern struct genericFormat *udf_get_extendedattr(struct inode *, uint32_t, ...@@ -160,7 +169,7 @@ extern struct genericFormat *udf_get_extendedattr(struct inode *, uint32_t,
extern struct buffer_head *udf_read_tagged(struct super_block *, uint32_t, extern struct buffer_head *udf_read_tagged(struct super_block *, uint32_t,
uint32_t, uint16_t *); uint32_t, uint16_t *);
extern struct buffer_head *udf_read_ptagged(struct super_block *, extern struct buffer_head *udf_read_ptagged(struct super_block *,
kernel_lb_addr, uint32_t, struct kernel_lb_addr *, uint32_t,
uint16_t *); uint16_t *);
extern void udf_update_tag(char *, int); extern void udf_update_tag(char *, int);
extern void udf_new_tag(char *, uint16_t, uint16_t, uint16_t, uint32_t, int); extern void udf_new_tag(char *, uint16_t, uint16_t, uint16_t, uint32_t, int);
...@@ -182,6 +191,14 @@ extern uint32_t udf_get_pblock_meta25(struct super_block *, uint32_t, uint16_t, ...@@ -182,6 +191,14 @@ extern uint32_t udf_get_pblock_meta25(struct super_block *, uint32_t, uint16_t,
uint32_t); uint32_t);
extern int udf_relocate_blocks(struct super_block *, long, long *); extern int udf_relocate_blocks(struct super_block *, long, long *);
static inline uint32_t
udf_get_lb_pblock(struct super_block *sb, struct kernel_lb_addr *loc,
uint32_t offset)
{
return udf_get_pblock(sb, loc->logicalBlockNum,
loc->partitionReferenceNum, offset);
}
/* unicode.c */ /* unicode.c */
extern int udf_get_filename(struct super_block *, uint8_t *, uint8_t *, int); extern int udf_get_filename(struct super_block *, uint8_t *, uint8_t *, int);
extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *, extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *,
...@@ -200,7 +217,7 @@ extern void udf_truncate_extents(struct inode *); ...@@ -200,7 +217,7 @@ extern void udf_truncate_extents(struct inode *);
/* balloc.c */ /* balloc.c */
extern void udf_free_blocks(struct super_block *, struct inode *, extern void udf_free_blocks(struct super_block *, struct inode *,
kernel_lb_addr, uint32_t, uint32_t); struct kernel_lb_addr *, uint32_t, uint32_t);
extern int udf_prealloc_blocks(struct super_block *, struct inode *, uint16_t, extern int udf_prealloc_blocks(struct super_block *, struct inode *, uint16_t,
uint32_t, uint32_t); uint32_t, uint32_t);
extern int udf_new_block(struct super_block *, struct inode *, uint16_t, extern int udf_new_block(struct super_block *, struct inode *, uint16_t,
...@@ -214,16 +231,16 @@ extern struct fileIdentDesc *udf_fileident_read(struct inode *, loff_t *, ...@@ -214,16 +231,16 @@ extern struct fileIdentDesc *udf_fileident_read(struct inode *, loff_t *,
struct udf_fileident_bh *, struct udf_fileident_bh *,
struct fileIdentDesc *, struct fileIdentDesc *,
struct extent_position *, struct extent_position *,
kernel_lb_addr *, uint32_t *, struct kernel_lb_addr *, uint32_t *,
sector_t *); sector_t *);
extern struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, extern struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize,
int *offset); int *offset);
extern long_ad *udf_get_filelongad(uint8_t *, int, uint32_t *, int); extern struct long_ad *udf_get_filelongad(uint8_t *, int, uint32_t *, int);
extern short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int); extern struct short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int);
/* udftime.c */ /* udftime.c */
extern struct timespec *udf_disk_stamp_to_time(struct timespec *dest, extern struct timespec *udf_disk_stamp_to_time(struct timespec *dest,
timestamp src); struct timestamp src);
extern timestamp *udf_time_to_disk_stamp(timestamp *dest, struct timespec src); extern struct timestamp *udf_time_to_disk_stamp(struct timestamp *dest, struct timespec src);
#endif /* __UDF_DECL_H */ #endif /* __UDF_DECL_H */
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include <linux/string.h> #include <linux/string.h>
static inline kernel_lb_addr lelb_to_cpu(lb_addr in) static inline struct kernel_lb_addr lelb_to_cpu(struct lb_addr in)
{ {
kernel_lb_addr out; struct 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);
...@@ -14,9 +14,9 @@ static inline kernel_lb_addr lelb_to_cpu(lb_addr in) ...@@ -14,9 +14,9 @@ static inline kernel_lb_addr lelb_to_cpu(lb_addr in)
return out; return out;
} }
static inline lb_addr cpu_to_lelb(kernel_lb_addr in) static inline struct lb_addr cpu_to_lelb(struct kernel_lb_addr in)
{ {
lb_addr out; struct 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);
...@@ -24,9 +24,9 @@ static inline lb_addr cpu_to_lelb(kernel_lb_addr in) ...@@ -24,9 +24,9 @@ static inline lb_addr cpu_to_lelb(kernel_lb_addr in)
return out; return out;
} }
static inline short_ad lesa_to_cpu(short_ad in) static inline struct short_ad lesa_to_cpu(struct short_ad in)
{ {
short_ad out; struct 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);
...@@ -34,9 +34,9 @@ static inline short_ad lesa_to_cpu(short_ad in) ...@@ -34,9 +34,9 @@ static inline short_ad lesa_to_cpu(short_ad in)
return out; return out;
} }
static inline short_ad cpu_to_lesa(short_ad in) static inline struct short_ad cpu_to_lesa(struct short_ad in)
{ {
short_ad out; struct 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);
...@@ -44,9 +44,9 @@ static inline short_ad cpu_to_lesa(short_ad in) ...@@ -44,9 +44,9 @@ static inline short_ad cpu_to_lesa(short_ad in)
return out; return out;
} }
static inline kernel_long_ad lela_to_cpu(long_ad in) static inline struct kernel_long_ad lela_to_cpu(struct long_ad in)
{ {
kernel_long_ad out; struct 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);
...@@ -54,9 +54,9 @@ static inline kernel_long_ad lela_to_cpu(long_ad in) ...@@ -54,9 +54,9 @@ static inline kernel_long_ad lela_to_cpu(long_ad in)
return out; return out;
} }
static inline long_ad cpu_to_lela(kernel_long_ad in) static inline struct long_ad cpu_to_lela(struct kernel_long_ad in)
{ {
long_ad out; struct 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);
...@@ -64,9 +64,9 @@ static inline long_ad cpu_to_lela(kernel_long_ad in) ...@@ -64,9 +64,9 @@ static inline long_ad cpu_to_lela(kernel_long_ad in)
return out; return out;
} }
static inline kernel_extent_ad leea_to_cpu(extent_ad in) static inline struct kernel_extent_ad leea_to_cpu(struct extent_ad in)
{ {
kernel_extent_ad out; struct 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);
......
...@@ -85,7 +85,8 @@ extern struct timezone sys_tz; ...@@ -85,7 +85,8 @@ 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)
struct timespec *udf_disk_stamp_to_time(struct timespec *dest, timestamp src) struct timespec *
udf_disk_stamp_to_time(struct timespec *dest, struct timestamp src)
{ {
int yday; int yday;
u16 typeAndTimezone = le16_to_cpu(src.typeAndTimezone); u16 typeAndTimezone = le16_to_cpu(src.typeAndTimezone);
...@@ -116,7 +117,8 @@ struct timespec *udf_disk_stamp_to_time(struct timespec *dest, timestamp src) ...@@ -116,7 +117,8 @@ struct timespec *udf_disk_stamp_to_time(struct timespec *dest, timestamp src)
return dest; return dest;
} }
timestamp *udf_time_to_disk_stamp(timestamp *dest, struct timespec ts) struct timestamp *
udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts)
{ {
long int days, rem, y; long int days, rem, y;
const unsigned short int *ip; const unsigned short int *ip;
......
...@@ -254,7 +254,7 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o, ...@@ -254,7 +254,7 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
{ {
const uint8_t *ocu; const uint8_t *ocu;
uint8_t cmp_id, ocu_len; uint8_t cmp_id, ocu_len;
int i; int i, len;
ocu_len = ocu_i->u_len; ocu_len = ocu_i->u_len;
...@@ -279,8 +279,13 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o, ...@@ -279,8 +279,13 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
if (cmp_id == 16) if (cmp_id == 16)
c = (c << 8) | ocu[i++]; c = (c << 8) | ocu[i++];
utf_o->u_len += nls->uni2char(c, &utf_o->u_name[utf_o->u_len], len = nls->uni2char(c, &utf_o->u_name[utf_o->u_len],
UDF_NAME_LEN - utf_o->u_len); UDF_NAME_LEN - utf_o->u_len);
/* Valid character? */
if (len >= 0)
utf_o->u_len += len;
else
utf_o->u_name[utf_o->u_len++] = '?';
} }
utf_o->u_cmpID = 8; utf_o->u_cmpID = 8;
...@@ -290,7 +295,8 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o, ...@@ -290,7 +295,8 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni, static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni,
int length) int length)
{ {
unsigned len, i, max_val; int len;
unsigned i, max_val;
uint16_t uni_char; uint16_t uni_char;
int u_len; int u_len;
...@@ -302,8 +308,13 @@ static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni, ...@@ -302,8 +308,13 @@ static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni,
u_len = 0U; u_len = 0U;
for (i = 0U; i < uni->u_len; i++) { for (i = 0U; i < uni->u_len; i++) {
len = nls->char2uni(&uni->u_name[i], uni->u_len - i, &uni_char); len = nls->char2uni(&uni->u_name[i], uni->u_len - i, &uni_char);
if (len <= 0) if (!len)
continue; continue;
/* Invalid character, deal with it */
if (len < 0) {
len = 1;
uni_char = '?';
}
if (uni_char > max_val) { if (uni_char > max_val) {
max_val = 0xffffU; max_val = 0xffffU;
...@@ -324,34 +335,43 @@ static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni, ...@@ -324,34 +335,43 @@ static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni,
int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname, int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname,
int flen) int flen)
{ {
struct ustr filename, unifilename; struct ustr *filename, *unifilename;
int len; int len = 0;
if (udf_build_ustr_exact(&unifilename, sname, flen)) filename = kmalloc(sizeof(struct ustr), GFP_NOFS);
if (!filename)
return 0; return 0;
unifilename = kmalloc(sizeof(struct ustr), GFP_NOFS);
if (!unifilename)
goto out1;
if (udf_build_ustr_exact(unifilename, sname, flen))
goto out2;
if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
if (!udf_CS0toUTF8(&filename, &unifilename)) { if (!udf_CS0toUTF8(filename, unifilename)) {
udf_debug("Failed in udf_get_filename: sname = %s\n", udf_debug("Failed in udf_get_filename: sname = %s\n",
sname); sname);
return 0; goto out2;
} }
} else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
if (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, &filename, if (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, filename,
&unifilename)) { unifilename)) {
udf_debug("Failed in udf_get_filename: sname = %s\n", udf_debug("Failed in udf_get_filename: sname = %s\n",
sname); sname);
return 0; goto out2;
} }
} else } else
return 0; goto out2;
len = udf_translate_to_linux(dname, filename.u_name, filename.u_len, len = udf_translate_to_linux(dname, filename->u_name, filename->u_len,
unifilename.u_name, unifilename.u_len); unifilename->u_name, unifilename->u_len);
if (len) out2:
return len; kfree(unifilename);
out1:
return 0; kfree(filename);
return len;
} }
int udf_put_filename(struct super_block *sb, const uint8_t *sname, int udf_put_filename(struct super_block *sb, const uint8_t *sname,
......
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