summaryrefslogtreecommitdiffstats
path: root/fs/udf
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-02-18 00:24:27 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-02-18 00:24:27 +0000
commitb9558d5f86c471a125abf1fb3a3882fb053b1f8c (patch)
tree707b53ec64e740a7da87d5f36485e3cd9b1c794e /fs/udf
parentb3ac367c7a3e6047abe74817db27e34e759f279f (diff)
Merge with Linux 2.3.41.
Diffstat (limited to 'fs/udf')
-rw-r--r--fs/udf/dir.c14
-rw-r--r--fs/udf/directory.c4
-rw-r--r--fs/udf/file.c317
-rw-r--r--fs/udf/fsync.c29
-rw-r--r--fs/udf/ialloc.c11
-rw-r--r--fs/udf/inode.c467
-rw-r--r--fs/udf/lowlevel.c26
-rw-r--r--fs/udf/misc.c19
-rw-r--r--fs/udf/namei.c62
-rw-r--r--fs/udf/partition.c275
-rw-r--r--fs/udf/super.c91
-rw-r--r--fs/udf/symlink.c62
-rw-r--r--fs/udf/truncate.c51
-rw-r--r--fs/udf/udf_i.h7
-rw-r--r--fs/udf/udf_sb.h4
-rw-r--r--fs/udf/udfdecl.h22
-rw-r--r--fs/udf/udftime.c2
-rw-r--r--fs/udf/unicode.c98
18 files changed, 779 insertions, 782 deletions
diff --git a/fs/udf/dir.c b/fs/udf/dir.c
index 7b7d065ff..916683186 100644
--- a/fs/udf/dir.c
+++ b/fs/udf/dir.c
@@ -67,13 +67,13 @@ static struct file_operations udf_dir_operations = {
struct inode_operations udf_dir_inode_operations = {
&udf_dir_operations,
-#ifdef CONFIG_UDF_RW
+#if CONFIG_UDF_RW == 1
udf_create, /* create */
#else
NULL, /* create */
#endif
udf_lookup, /* lookup */
-#ifdef CONFIG_UDF_RW
+#if CONFIG_UDF_RW == 1
udf_link, /* link */
udf_unlink, /* unlink */
udf_symlink, /* symlink */
@@ -139,7 +139,7 @@ int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
if ( filp->f_pos == 0 )
{
- if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino) < 0)
+ if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino))
return 0;
}
@@ -161,7 +161,7 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
char *nameptr;
Uint16 liu;
Uint8 lfi;
- loff_t size = (UDF_I_EXT0OFFS(dir) + dir->i_size) >> 2;
+ loff_t size = (udf_ext0_offset(dir) + dir->i_size) >> 2;
struct buffer_head * bh = NULL;
lb_addr bloc, eloc;
Uint32 extoffset, elen, offset;
@@ -170,7 +170,7 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
return 1;
if (nf_pos == 0)
- nf_pos = (UDF_I_EXT0OFFS(dir) >> 2);
+ nf_pos = (udf_ext0_offset(dir) >> 2);
fibh.soffset = fibh.eoffset = (nf_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
if (inode_bmap(dir, nf_pos >> (dir->i_sb->s_blocksize_bits - 2),
@@ -251,7 +251,7 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
if (!lfi) /* parent directory */
{
- if (filldir(dirent, "..", 2, filp->f_pos, filp->f_dentry->d_parent->d_inode->i_ino) < 0)
+ if (filldir(dirent, "..", 2, filp->f_pos, filp->f_dentry->d_parent->d_inode->i_ino))
{
if (fibh.sbh != fibh.ebh)
udf_release_data(fibh.ebh);
@@ -264,7 +264,7 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
{
if ((flen = udf_get_filename(nameptr, fname, lfi)))
{
- if (filldir(dirent, fname, flen, filp->f_pos, iblock) < 0)
+ if (filldir(dirent, fname, flen, filp->f_pos, iblock))
{
if (fibh.sbh != fibh.ebh)
udf_release_data(fibh.ebh);
diff --git a/fs/udf/directory.c b/fs/udf/directory.c
index b8a94e8f5..84c97ee9d 100644
--- a/fs/udf/directory.c
+++ b/fs/udf/directory.c
@@ -213,8 +213,8 @@ udf_get_fileident(void * buffer, int bufsize, int * offset)
#ifdef __KERNEL__
udf_debug("0x%x != TID_FILE_IDENT_DESC\n",
le16_to_cpu(fi->descTag.tagIdent));
- udf_debug("offset: %u sizeof: %u bufsize: %u\n",
- *offset, sizeof(struct FileIdentDesc), bufsize);
+ udf_debug("offset: %u sizeof: %lu bufsize: %u\n",
+ *offset, (unsigned long)sizeof(struct FileIdentDesc), bufsize);
#endif
return NULL;
}
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 81cddaa3f..8ea44d2a8 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -43,94 +43,6 @@
#include "udf_i.h"
#include "udf_sb.h"
-static loff_t udf_file_llseek(struct file *, loff_t, int);
-static ssize_t udf_file_read_adinicb (struct file *, char *, size_t, loff_t *);
-static ssize_t udf_file_write (struct file *, const char *, size_t, loff_t *);
-static int udf_open_file(struct inode *, struct file *);
-static int udf_release_file(struct inode *, struct file *);
-
-static struct file_operations udf_file_operations = {
- udf_file_llseek, /* llseek */
- generic_file_read, /* read */
- udf_file_write, /* write */
- NULL, /* readdir */
- NULL, /* poll */
- udf_ioctl, /* ioctl */
- generic_file_mmap, /* mmap */
- udf_open_file, /* open */
- NULL, /* flush */
- udf_release_file, /* release */
- udf_sync_file, /* fsync */
- NULL, /* fasync */
- NULL /* lock */
-};
-
-struct inode_operations udf_file_inode_operations = {
- &udf_file_operations,
- NULL, /* create */
- NULL, /* lookup */
- NULL, /* link */
- NULL, /* unlink */
- NULL, /* symlink */
- NULL, /* mkdir */
- NULL, /* rmdir */
- NULL, /* mknod */
- NULL, /* rename */
- NULL, /* readlink */
- NULL, /* follow_link */
- udf_get_block, /* get_block */
- block_read_full_page, /* readpage */
- block_write_full_page, /* writepage */
-#ifdef CONFIG_UDF_RW
- udf_truncate, /* truncate */
-#else
- NULL, /* truncate */
-#endif
- NULL, /* permission */
- NULL /* revalidate */
-};
-
-static struct file_operations udf_file_operations_adinicb = {
- udf_file_llseek, /* llseek */
- udf_file_read_adinicb,/* read */
- udf_file_write, /* write */
- NULL, /* readdir */
- NULL, /* poll */
- udf_ioctl, /* ioctl */
- NULL, /* mmap */
- NULL, /* open */
- NULL, /* flush */
- udf_release_file, /* release */
- udf_sync_file, /* fsync */
- NULL, /* fasync */
- NULL /* lock */
-};
-
-struct inode_operations udf_file_inode_operations_adinicb = {
- &udf_file_operations_adinicb,
- NULL, /* create */
- NULL, /* lookup */
- NULL, /* link */
- NULL, /* unlink */
- NULL, /* symlink */
- NULL, /* mkdir */
- NULL, /* rmdir */
- NULL, /* mknod */
- NULL, /* rename */
- NULL, /* readlink */
- NULL, /* follow_link */
- udf_get_block, /* get_block */
- block_read_full_page, /* readpage */
- block_write_full_page, /* writepage */
-#ifdef CONFIG_UDF_RW
- udf_truncate, /* truncate */
-#else
- NULL, /* truncate */
-#endif
- NULL, /* permission */
- NULL /* revalidate */
-};
-
/*
* Make sure the offset never goes beyond the 32-bit mark..
*/
@@ -181,104 +93,93 @@ static ssize_t udf_file_write(struct file * file, const char * buf,
{
ssize_t retval;
struct inode *inode = file->f_dentry->d_inode;
- remove_suid(inode);
-
- if (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_IN_ICB)
- {
- int i, err;
- struct buffer_head *bh;
-
- if ((bh = udf_expand_adinicb(inode, &i, 0, &err)))
- udf_release_data(bh);
- else if (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_IN_ICB)
- return err;
- }
retval = generic_file_write(file, buf, count, ppos, block_write_partial_page);
if (retval > 0)
{
+ remove_suid(inode);
inode->i_ctime = inode->i_mtime = CURRENT_TIME;
UDF_I_UCTIME(inode) = UDF_I_UMTIME(inode) = CURRENT_UTIME;
+ mark_inode_dirty(inode);
}
- mark_inode_dirty(inode);
return retval;
}
-/*
- * udf_file_read
- *
- * PURPOSE
- * Read from an open file.
- *
- * DESCRIPTION
- * Optional - sys_read() will return -EINVAL if this routine is not
- * available.
- *
- * Refer to sys_read() in fs/read_write.c
- * sys_read() -> .
- *
- * Note that you can use generic_file_read() instead, which requires that
- * udf_readpage() be available, but you can use generic_readpage(), which
- * requires that udf_block_map() be available. Reading will then be done by
- * memory-mapping the file a page at a time. This is not suitable for
- * devices that don't handle read-ahead [example: CD-R/RW that may have
- * blank sectors that shouldn't be read].
- *
- * Refer to generic_file_read() in mm/filemap.c and to generic_readpage()
- * in fs/buffer.c
- *
- * Block devices can use block_read() instead. Refer to fs/block_dev.c
- *
- * PRE-CONDITIONS
- * inode Pointer to inode to read from (never NULL).
- * filp Pointer to file to read from (never NULL).
- * buf Point to read buffer (validated).
- * bufsize Size of read buffer.
- *
- * POST-CONDITIONS
- * <return> Bytes read (>=0) or an error code (<0) that
- * sys_read() will return.
- *
- * HISTORY
- * July 1, 1997 - Andrew E. Mileski
- * Written, tested, and released.
- */
-static ssize_t udf_file_read_adinicb(struct file * filp, char * buf,
- size_t bufsize, loff_t * loff)
+int udf_write_partial_page_adinicb(struct file *file, struct page *page, unsigned long offset, unsigned long bytes, const char * buf)
{
- struct inode *inode = filp->f_dentry->d_inode;
- loff_t size, left, pos;
- Uint32 block;
- struct buffer_head *bh = NULL;
+ struct inode *inode = file->f_dentry->d_inode;
+ int err = 0, block;
+ struct buffer_head *bh;
+ unsigned long kaddr = 0;
+
+ if (!PageLocked(page))
+ BUG();
+ if (offset < 0 || offset >= (inode->i_sb->s_blocksize - udf_file_entry_alloc_offset(inode)))
+ BUG();
+ if (bytes+offset < 0 || bytes+offset > (inode->i_sb->s_blocksize - udf_file_entry_alloc_offset(inode)))
+ BUG();
+
+ kaddr = kmap(page);
+ block = udf_get_lb_pblock(inode->i_sb, UDF_I_LOCATION(inode), 0);
+ bh = getblk (inode->i_dev, block, inode->i_sb->s_blocksize);
+ if (!buffer_uptodate(bh))
+ {
+ ll_rw_block (READ, 1, &bh);
+ wait_on_buffer(bh);
+ }
+ err = copy_from_user((char *)kaddr + offset, buf, bytes);
+ memcpy(bh->b_data + udf_file_entry_alloc_offset(inode) + offset,
+ (char *)kaddr + offset, bytes);
+ mark_buffer_dirty(bh, 0);
+ brelse(bh);
+ kunmap(page);
+ SetPageUptodate(page);
+ return bytes;
+}
+
+static ssize_t udf_file_write_adinicb(struct file * file, const char * buf,
+ size_t count, loff_t *ppos)
+{
+ ssize_t retval;
+ struct inode *inode = file->f_dentry->d_inode;
+ int err, pos;
- size = inode->i_size;
- if (*loff > size)
- left = 0;
+ if (file->f_flags & O_APPEND)
+ pos = inode->i_size;
else
- left = size - *loff;
- if (left > bufsize)
- left = bufsize;
-
- if (left <= 0)
- return 0;
-
- pos = *loff + UDF_I_EXT0OFFS(inode);
- block = udf_block_map(inode, 0);
- if (!(bh = udf_tread(inode->i_sb,
- udf_get_lb_pblock(inode->i_sb, UDF_I_LOCATION(inode), 0),
- inode->i_sb->s_blocksize)))
+ pos = *ppos;
+
+ if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) +
+ pos + count))
{
- return 0;
+ udf_expand_file_adinicb(file, pos + count, &err);
+ if (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_IN_ICB)
+ {
+ udf_debug("udf_expand_adinicb: err=%d\n", err);
+ return err;
+ }
+ else
+ return udf_file_write(file, buf, count, ppos);
}
- if (!copy_to_user(buf, bh->b_data + pos, left))
- *loff += left;
else
- left = -EFAULT;
+ {
+ if (pos + count > inode->i_size)
+ UDF_I_LENALLOC(inode) = pos + count;
+ else
+ UDF_I_LENALLOC(inode) = inode->i_size;
+ }
- udf_release_data(bh);
+ retval = generic_file_write(file, buf, count, ppos, udf_write_partial_page_adinicb);
- return left;
+ if (retval > 0)
+ {
+ remove_suid(inode);
+ inode->i_ctime = inode->i_mtime = CURRENT_TIME;
+ UDF_I_UCTIME(inode) = UDF_I_UMTIME(inode) = CURRENT_UTIME;
+ mark_inode_dirty(inode);
+ }
+ return retval;
}
/*
@@ -435,3 +336,85 @@ static int udf_open_file(struct inode * inode, struct file * filp)
return -EFBIG;
return 0;
}
+
+static struct file_operations udf_file_operations = {
+ udf_file_llseek, /* llseek */
+ generic_file_read, /* read */
+ udf_file_write, /* write */
+ NULL, /* readdir */
+ NULL, /* poll */
+ udf_ioctl, /* ioctl */
+ generic_file_mmap, /* mmap */
+ udf_open_file, /* open */
+ NULL, /* flush */
+ udf_release_file, /* release */
+ udf_sync_file, /* fsync */
+ NULL, /* fasync */
+ NULL /* lock */
+};
+
+struct inode_operations udf_file_inode_operations = {
+ &udf_file_operations,
+ NULL, /* create */
+ NULL, /* lookup */
+ NULL, /* link */
+ NULL, /* unlink */
+ NULL, /* symlink */
+ NULL, /* mkdir */
+ NULL, /* rmdir */
+ NULL, /* mknod */
+ NULL, /* rename */
+ NULL, /* readlink */
+ NULL, /* follow_link */
+ udf_get_block, /* get_block */
+ block_read_full_page, /* readpage */
+ block_write_full_page, /* writepage */
+#if CONFIG_UDF_RW == 1
+ udf_truncate, /* truncate */
+#else
+ NULL, /* truncate */
+#endif
+ NULL, /* permission */
+ NULL /* revalidate */
+};
+
+static struct file_operations udf_file_operations_adinicb = {
+ udf_file_llseek, /* llseek */
+ generic_file_read, /* read */
+ udf_file_write_adinicb, /* write */
+ NULL, /* readdir */
+ NULL, /* poll */
+ udf_ioctl, /* ioctl */
+ NULL, /* mmap */
+ NULL, /* open */
+ NULL, /* flush */
+ udf_release_file, /* release */
+ udf_sync_file_adinicb, /* fsync */
+ NULL, /* fasync */
+ NULL /* lock */
+};
+
+struct inode_operations udf_file_inode_operations_adinicb = {
+ &udf_file_operations_adinicb,
+ NULL, /* create */
+ NULL, /* lookup */
+ NULL, /* link */
+ NULL, /* unlink */
+ NULL, /* symlink */
+ NULL, /* mkdir */
+ NULL, /* rmdir */
+ NULL, /* mknod */
+ NULL, /* rename */
+ NULL, /* readlink */
+ NULL, /* follow_link */
+ udf_get_block, /* get_block */
+ udf_readpage_adinicb, /* readpage */
+ udf_writepage_adinicb, /* writepage */
+#if CONFIG_UDF_RW == 1
+ udf_truncate_adinicb, /* truncate */
+#else
+ NULL, /* truncate */
+#endif
+ NULL, /* permission */
+ NULL /* revalidate */
+};
diff --git a/fs/udf/fsync.c b/fs/udf/fsync.c
index 3e2b95c19..b5c10c91b 100644
--- a/fs/udf/fsync.c
+++ b/fs/udf/fsync.c
@@ -15,18 +15,18 @@
* ftp://prep.ai.mit.edu/pub/gnu/GPL
* Each contributing author retains all rights to their own work.
*
- * (C) 1999 Ben Fennema
- * (C) 1999 Stelias Computing Inc
+ * (C) 1999-2000 Ben Fennema
+ * (C) 1999-2000 Stelias Computing Inc
*
* HISTORY
*
* 05/22/99 blf Created.
- *
*/
#include "udfdecl.h"
#include <linux/fs.h>
+#include <linux/locks.h>
#include <linux/udf_fs.h>
#include "udf_i.h"
@@ -40,10 +40,21 @@ static int sync_extent_block (struct inode * inode, Uint32 block, int wait)
if (!bh)
return 0;
if (wait && buffer_req(bh) && !buffer_uptodate(bh)) {
- brelse (bh);
- return -1;
+ /* There can be a parallell read(2) that started read-I/O
+ on the buffer so we can't assume that there's been
+ an I/O error without first waiting I/O completation. */
+ wait_on_buffer(bh);
+ if (!buffer_uptodate(bh))
+ {
+ brelse (bh);
+ return -1;
+ }
}
if (wait || !buffer_uptodate(bh) || !buffer_dirty(bh)) {
+ if (wait)
+ /* when we return from fsync all the blocks
+ must be _just_ stored on disk */
+ wait_on_buffer(bh);
brelse (bh);
return 0;
}
@@ -89,8 +100,7 @@ int udf_sync_file(struct file * file, struct dentry *dentry)
int wait, err = 0;
struct inode *inode = dentry->d_inode;
- if ((S_ISLNK(inode->i_mode) && !(inode->i_blocks)) ||
- UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_IN_ICB)
+ if (S_ISLNK(inode->i_mode) && !(inode->i_blocks))
{
/*
* Don't sync fast links! or ICB_FLAG_AD_IN_ICB
@@ -108,3 +118,8 @@ skip:
err |= udf_sync_inode (inode);
return err ? -EIO : 0;
}
+
+int udf_sync_file_adinicb(struct file * file, struct dentry *dentry)
+{
+ return udf_sync_inode(dentry->d_inode) ? -EIO : 0;
+}
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index 32f60fef5..8badac9d9 100644
--- a/fs/udf/ialloc.c
+++ b/fs/udf/ialloc.c
@@ -15,7 +15,7 @@
* ftp://prep.ai.mit.edu/pub/gnu/GPL
* Each contributing author retains all rights to their own work.
*
- * (C) 1998-1999 Ben Fennema
+ * (C) 1998-2000 Ben Fennema
*
* HISTORY
*
@@ -148,16 +148,7 @@ struct inode * udf_new_inode (const struct inode *dir, int mode, int * err)
inode->i_size = 0;
UDF_I_LENEATTR(inode) = 0;
UDF_I_LENALLOC(inode) = 0;
- UDF_I_EXT0LOC(inode) = UDF_I_LOCATION(inode);
- UDF_I_EXT0LEN(inode) = 0;
-#if 1
- UDF_I_EXT0OFFS(inode) = sizeof(struct FileEntry);
UDF_I_ALLOCTYPE(inode) = ICB_FLAG_AD_IN_ICB;
-#else
- UDF_I_EXT0OFFS(inode) = 0;
- UDF_I_ALLOCTYPE(inode) = ICB_FLAG_AD_LONG;
-#endif
-
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
UDF_I_UMTIME(inode) = UDF_I_UATIME(inode) = UDF_I_UCTIME(inode) = CURRENT_UTIME;
inode->i_op = NULL;
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index e2e12df8e..2ea1f980b 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -16,8 +16,8 @@
* Each contributing author retains all rights to their own work.
*
* (C) 1998 Dave Boynton
- * (C) 1998-1999 Ben Fennema
- * (C) 1999 Stelias Computing Inc
+ * (C) 1998-2000 Ben Fennema
+ * (C) 1999-2000 Stelias Computing Inc
*
* HISTORY
*
@@ -31,7 +31,6 @@
* 03/07/99 rewrote udf_block_map (again)
* New funcs, inode_bmap, udf_next_aext
* 04/19/99 Support for writing device EA's for major/minor #
- *
*/
#include "udfdecl.h"
@@ -58,8 +57,6 @@ static void udf_update_extents(struct inode *,
long_ad [EXTENT_MERGE_SIZE], int, int,
lb_addr, Uint32, struct buffer_head **);
-static DECLARE_MUTEX(read_semaphore);
-
/*
* udf_put_inode
*
@@ -99,56 +96,14 @@ void udf_delete_inode(struct inode * inode)
{
inode->i_size = 0;
if (inode->i_blocks)
- udf_truncate(inode);
+ inode->i_op->truncate(inode);
udf_free_inode(inode);
}
void udf_discard_prealloc(struct inode * inode)
{
-#ifdef UDF_PREALLOCATE
- lb_addr bloc, eloc;
- Uint32 extoffset, elen, nelen, offset, adsize = 0;
- struct buffer_head *bh = NULL;
-
- if ((inode->i_size > 0) &&
- (inode_bmap(inode, (inode->i_size-1) >> inode->i_sb->s_blocksize_bits,
- &bloc, &extoffset, &eloc, &elen, &offset, &bh) ==
- EXTENT_RECORDED_ALLOCATED))
- {
- if (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_SHORT)
- adsize = sizeof(short_ad);
- else if (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_LONG)
- adsize = sizeof(long_ad);
- else
- {
- udf_release_data(bh);
- return;
- }
-
- nelen = (EXTENT_RECORDED_ALLOCATED << 30) |
- ((((elen - 1) & ~(inode->i_sb->s_blocksize - 1)) |
- ((inode->i_size - 1) & (inode->i_sb->s_blocksize - 1))) + 1);
-
- if (nelen != ((EXTENT_RECORDED_ALLOCATED << 30) | elen))
- {
- extoffset -= adsize;
- udf_write_aext(inode, bloc, &extoffset, eloc, nelen, &bh, 1);
- }
-
- if (udf_next_aext(inode, &bloc, &extoffset, &eloc, &elen, &bh, 0) ==
- EXTENT_NOT_RECORDED_ALLOCATED)
- {
- udf_free_blocks(inode, eloc, 0, elen >> inode->i_sb->s_blocksize_bits);
- memset(&eloc, 0x00, sizeof(lb_addr));
- udf_write_aext(inode, bloc, &extoffset, eloc, 0, &bh, 1);
- UDF_I_LENALLOC(inode) -= adsize;
- udf_write_inode(inode);
- }
- udf_release_data(bh);
- }
- else if (bh)
- udf_release_data(bh);
-#endif
+ if (inode->i_size && UDF_I_ALLOCTYPE(inode) != ICB_FLAG_AD_IN_ICB)
+ udf_trunc(inode);
}
static int udf_alloc_block(struct inode *inode, Uint16 partition,
@@ -162,108 +117,138 @@ static int udf_alloc_block(struct inode *inode, Uint16 partition,
return result;
}
-struct buffer_head * udf_expand_adinicb(struct inode *inode, int *block, int isdir, int *err)
+void udf_expand_file_adinicb(struct file * filp, int newsize, int * err)
{
- if (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_IN_ICB)
- {
- long_ad newad;
- int newblock;
- struct buffer_head *sbh = NULL, *dbh = NULL;
+ struct inode * inode = filp->f_dentry->d_inode;
+ struct buffer_head *bh = NULL;
+ struct page *page;
+ unsigned long kaddr = 0;
- if (!UDF_I_LENALLOC(inode))
- {
- UDF_I_EXT0OFFS(inode) = 0;
- UDF_I_ALLOCTYPE(inode) = ICB_FLAG_AD_LONG;
- mark_inode_dirty(inode);
- if (inode->i_op == &udf_file_inode_operations_adinicb)
- inode->i_op = &udf_file_inode_operations;
- return NULL;
- }
+ if (!UDF_I_LENALLOC(inode))
+ {
+ UDF_I_ALLOCTYPE(inode) = ICB_FLAG_AD_LONG;
+ mark_inode_dirty(inode);
+ inode->i_op = &udf_file_inode_operations;
+ filp->f_op = inode->i_op->default_file_ops;
+ return;
+ }
- /* alloc block, and copy data to it */
- *block = udf_alloc_block(inode,
- UDF_I_LOCATION(inode).partitionReferenceNum,
- UDF_I_LOCATION(inode).logicalBlockNum, err);
+ bh = udf_tread(inode->i_sb, inode->i_ino, inode->i_sb->s_blocksize);
+ if (!bh)
+ return;
+ page = grab_cache_page(&inode->i_data, 0);
+ if (!PageLocked(page))
+ BUG();
+ if (!Page_Uptodate(page))
+ {
+ kaddr = kmap(page);
+ memset((char *)kaddr + UDF_I_LENALLOC(inode), 0x00,
+ PAGE_CACHE_SIZE - UDF_I_LENALLOC(inode));
+ memcpy((char *)kaddr, bh->b_data + udf_file_entry_alloc_offset(inode),
+ UDF_I_LENALLOC(inode));
+ kunmap(page);
+ }
+ memset(bh->b_data + udf_file_entry_alloc_offset(inode),
+ 0, UDF_I_LENALLOC(inode));
+ UDF_I_LENALLOC(inode) = 0;
+ UDF_I_ALLOCTYPE(inode) = ICB_FLAG_AD_LONG;
+ inode->i_blocks = inode->i_sb->s_blocksize / 512;
+ mark_buffer_dirty(bh, 1);
+ udf_release_data(bh);
- if (!(*block))
- return NULL;
- newblock = udf_get_pblock(inode->i_sb, *block,
- UDF_I_LOCATION(inode).partitionReferenceNum, 0);
- if (!newblock)
- return NULL;
- sbh = udf_tread(inode->i_sb, inode->i_ino, inode->i_sb->s_blocksize);
- if (!sbh)
- return NULL;
- dbh = udf_tread(inode->i_sb, newblock, inode->i_sb->s_blocksize);
- if (!dbh)
- return NULL;
-
- if (isdir)
- {
- struct udf_fileident_bh sfibh, dfibh;
- loff_t f_pos = UDF_I_EXT0OFFS(inode) >> 2;
- loff_t size = (UDF_I_EXT0OFFS(inode) + inode->i_size) >> 2;
- struct FileIdentDesc cfi, *sfi, *dfi;
-
- sfibh.soffset = sfibh.eoffset = (f_pos & ((inode->i_sb->s_blocksize - 1) >> 2)) << 2;
- sfibh.sbh = sfibh.ebh = sbh;
- dfibh.soffset = dfibh.eoffset = 0;
- dfibh.sbh = dfibh.ebh = dbh;
- while ( (f_pos < size) )
- {
- sfi = udf_fileident_read(inode, &f_pos, &sfibh, &cfi, NULL, NULL, NULL, NULL);
- if (!sfi)
- {
- udf_release_data(sbh);
- udf_release_data(dbh);
- return NULL;
- }
- sfi->descTag.tagLocation = *block;
- dfibh.soffset = dfibh.eoffset;
- dfibh.eoffset += (sfibh.eoffset - sfibh.soffset);
- dfi = (struct FileIdentDesc *)(dbh->b_data + dfibh.soffset);
- if (udf_write_fi(sfi, dfi, &dfibh, sfi->impUse,
- sfi->fileIdent + sfi->lengthOfImpUse))
- {
- udf_release_data(sbh);
- udf_release_data(dbh);
- return NULL;
- }
- }
- }
- else
- {
- memcpy(dbh->b_data, sbh->b_data + udf_file_entry_alloc_offset(inode),
- UDF_I_LENALLOC(inode));
- }
- mark_buffer_dirty(dbh, 1);
+ block_write_full_page(filp->f_dentry, page);
+ UnlockPage(page);
+ page_cache_release(page);
- memset(sbh->b_data + udf_file_entry_alloc_offset(inode),
- 0, UDF_I_LENALLOC(inode));
+ mark_inode_dirty(inode);
+ inode->i_version ++;
+ inode->i_op = &udf_file_inode_operations;
+ filp->f_op = inode->i_op->default_file_ops;
+}
- memset(&newad, 0x00, sizeof(long_ad));
- newad.extLength = UDF_I_EXT0LEN(inode) = inode->i_size;
- newad.extLocation.logicalBlockNum = *block;
- newad.extLocation.partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum;
- UDF_I_EXT0LOC(inode) = newad.extLocation;
- /* UniqueID stuff */
+struct buffer_head * udf_expand_dir_adinicb(struct inode *inode, int *block, int *err)
+{
+ long_ad newad;
+ int newblock;
+ struct buffer_head *sbh = NULL, *dbh = NULL;
- memcpy(sbh->b_data + udf_file_entry_alloc_offset(inode),
- &newad, sizeof(newad));
+ struct udf_fileident_bh sfibh, dfibh;
+ loff_t f_pos = udf_ext0_offset(inode) >> 2;
+ int size = (udf_ext0_offset(inode) + inode->i_size) >> 2;
+ struct FileIdentDesc cfi, *sfi, *dfi;
- UDF_I_LENALLOC(inode) = sizeof(newad);
- UDF_I_EXT0OFFS(inode) = 0;
+ if (!inode->i_size)
+ {
UDF_I_ALLOCTYPE(inode) = ICB_FLAG_AD_LONG;
- inode->i_blocks += inode->i_sb->s_blocksize / 512;
- udf_release_data(sbh);
mark_inode_dirty(inode);
- inode->i_version ++;
- if (inode->i_op == &udf_file_inode_operations_adinicb)
- inode->i_op = &udf_file_inode_operations;
- return dbh;
+ return NULL;
}
- else
+
+ /* alloc block, and copy data to it */
+ *block = udf_alloc_block(inode,
+ UDF_I_LOCATION(inode).partitionReferenceNum,
+ UDF_I_LOCATION(inode).logicalBlockNum, err);
+
+ if (!(*block))
+ return NULL;
+ newblock = udf_get_pblock(inode->i_sb, *block,
+ UDF_I_LOCATION(inode).partitionReferenceNum, 0);
+ if (!newblock)
return NULL;
+ sbh = udf_tread(inode->i_sb, inode->i_ino, inode->i_sb->s_blocksize);
+ if (!sbh)
+ return NULL;
+ dbh = udf_tread(inode->i_sb, newblock, inode->i_sb->s_blocksize);
+ if (!dbh)
+ return NULL;
+
+ sfibh.soffset = sfibh.eoffset = (f_pos & ((inode->i_sb->s_blocksize - 1) >> 2)) << 2;
+ sfibh.sbh = sfibh.ebh = sbh;
+ dfibh.soffset = dfibh.eoffset = 0;
+ dfibh.sbh = dfibh.ebh = dbh;
+ while ( (f_pos < size) )
+ {
+ sfi = udf_fileident_read(inode, &f_pos, &sfibh, &cfi, NULL, NULL, NULL, NULL);
+ if (!sfi)
+ {
+ udf_release_data(sbh);
+ udf_release_data(dbh);
+ return NULL;
+ }
+ sfi->descTag.tagLocation = *block;
+ dfibh.soffset = dfibh.eoffset;
+ dfibh.eoffset += (sfibh.eoffset - sfibh.soffset);
+ dfi = (struct FileIdentDesc *)(dbh->b_data + dfibh.soffset);
+ if (udf_write_fi(sfi, dfi, &dfibh, sfi->impUse,
+ sfi->fileIdent + sfi->lengthOfImpUse))
+ {
+ udf_release_data(sbh);
+ udf_release_data(dbh);
+ return NULL;
+ }
+ }
+ mark_buffer_dirty(dbh, 1);
+
+ memset(sbh->b_data + udf_file_entry_alloc_offset(inode),
+ 0, UDF_I_LENALLOC(inode));
+
+ memset(&newad, 0x00, sizeof(long_ad));
+ newad.extLength = inode->i_size;
+ newad.extLocation.logicalBlockNum = *block;
+ newad.extLocation.partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum;
+ /* UniqueID stuff */
+
+ memcpy(sbh->b_data + udf_file_entry_alloc_offset(inode),
+ &newad, sizeof(newad));
+
+ UDF_I_LENALLOC(inode) = sizeof(newad);
+ UDF_I_ALLOCTYPE(inode) = ICB_FLAG_AD_LONG;
+ inode->i_blocks = inode->i_sb->s_blocksize / 512;
+ mark_buffer_dirty(sbh, 1);
+ udf_release_data(sbh);
+ mark_inode_dirty(inode);
+ inode->i_version ++;
+ return dbh;
}
struct buffer_head * udf_getblk(struct inode * inode, long block,
@@ -282,6 +267,8 @@ struct buffer_head * udf_getblk(struct inode * inode, long block,
bh = getblk(dummy.b_dev, dummy.b_blocknr, inode->i_sb->s_blocksize);
if (buffer_new(&dummy))
{
+ if (!buffer_uptodate(bh))
+ wait_on_buffer(bh);
memset(bh->b_data, 0x00, inode->i_sb->s_blocksize);
mark_buffer_uptodate(bh, 1);
mark_buffer_dirty(bh, 1);
@@ -310,6 +297,8 @@ int udf_get_block(struct inode *inode, long block, struct buffer_head *bh_result
}
err = -EIO;
+ new = 0;
+ bh = NULL;
lock_kernel();
@@ -479,7 +468,7 @@ static struct buffer_head * inode_getblk(struct inode * inode, long block,
}
/* if the current extent is not recorded but allocated, get the
- block in the extent corresponding to the requested block */
+ block in the extent corresponding to the requested block */
if ((laarr[c].extLength >> 30) == EXTENT_NOT_RECORDED_ALLOCATED)
newblocknum = laarr[c].extLocation.logicalBlockNum + offset;
else /* otherwise, allocate a new block */
@@ -522,12 +511,6 @@ static struct buffer_head * inode_getblk(struct inode * inode, long block,
udf_release_data(pbh);
- if (pextoffset == udf_file_entry_alloc_offset(inode))
- {
- UDF_I_EXT0LEN(inode) = laarr[0].extLength;
- UDF_I_EXT0LOC(inode) = laarr[0].extLocation;
- }
-
if (!(newblock = udf_get_pblock(inode->i_sb, newblocknum,
UDF_I_LOCATION(inode).partitionReferenceNum, 0)))
{
@@ -541,11 +524,9 @@ static struct buffer_head * inode_getblk(struct inode * inode, long block,
inode->i_ctime = CURRENT_TIME;
UDF_I_UCTIME(inode) = CURRENT_UTIME;
inode->i_blocks += inode->i_sb->s_blocksize / 512;
-#if 0
- if (IS_SYNC(inode) || UDF_I_OSYNC(inode))
+ if (IS_SYNC(inode))
udf_sync_inode(inode);
else
-#endif
mark_inode_dirty(inode);
return result;
}
@@ -830,9 +811,16 @@ struct buffer_head * udf_bread(struct inode * inode, int block,
*
* 12/19/98 dgb Updated to fix size problems.
*/
+
void
udf_read_inode(struct inode *inode)
{
+ memset(&UDF_I_LOCATION(inode), 0xFF, sizeof(lb_addr));
+}
+
+void
+__udf_read_inode(struct inode *inode)
+{
struct buffer_head *bh = NULL;
struct FileEntry *fe;
Uint16 ident;
@@ -851,17 +839,9 @@ udf_read_inode(struct inode *inode)
* i_op = NULL;
*/
- inode->i_blksize = inode->i_sb->s_blocksize;
+ inode->i_blksize = PAGE_SIZE;
inode->i_version = 1;
- UDF_I_EXT0LEN(inode)=0;
- UDF_I_EXT0LOC(inode).logicalBlockNum = 0xFFFFFFFF;
- UDF_I_EXT0LOC(inode).partitionReferenceNum = 0xFFFF;
- UDF_I_EXT0OFFS(inode)=0;
- UDF_I_ALLOCTYPE(inode)=0;
-
- memcpy(&UDF_I_LOCATION(inode), &UDF_SB_LOCATION(inode->i_sb), sizeof(lb_addr));
-
bh = udf_read_ptagged(inode->i_sb, UDF_I_LOCATION(inode), 0, &ident);
if (!bh)
@@ -904,11 +884,11 @@ udf_read_inode(struct inode *inode)
if (ident == TID_FILE_ENTRY ||
ident == TID_EXTENDED_FILE_ENTRY)
{
- memcpy(&UDF_SB_LOCATION(inode->i_sb), &loc, sizeof(lb_addr));
+ memcpy(&UDF_I_LOCATION(inode), &loc, sizeof(lb_addr));
udf_release_data(bh);
udf_release_data(ibh);
udf_release_data(nbh);
- udf_read_inode(inode);
+ __udf_read_inode(inode);
return;
}
else
@@ -957,11 +937,11 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
else /* if (le16_to_cpu(fe->icbTag.strategyType) == 4096) */
UDF_I_STRAT4096(inode) = 1;
- inode->i_uid = udf_convert_uid(le32_to_cpu(fe->uid));
- if ( !inode->i_uid ) inode->i_uid = UDF_SB(inode->i_sb)->s_uid;
+ inode->i_uid = le32_to_cpu(fe->uid);
+ if ( inode->i_uid == -1 ) inode->i_uid = UDF_SB(inode->i_sb)->s_uid;
- inode->i_gid = udf_convert_gid(le32_to_cpu(fe->gid));
- if ( !inode->i_gid ) inode->i_gid = UDF_SB(inode->i_sb)->s_gid;
+ inode->i_gid = le32_to_cpu(fe->gid);
+ if ( inode->i_gid == -1 ) inode->i_gid = UDF_SB(inode->i_sb)->s_gid;
inode->i_nlink = le16_to_cpu(fe->fileLinkCount);
if (!inode->i_nlink)
@@ -976,12 +956,6 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
inode->i_mode = udf_convert_permissions(fe);
inode->i_mode &= ~UDF_SB(inode->i_sb)->s_umask;
-#ifdef UDF_PREALLOCATE
-#if 0
- UDF_I_PREALLOC_BLOCK(inode) = 0;
- UDF_I_PREALLOC_COUNT(inode) = 0;
-#endif
-#endif
UDF_I_NEXT_ALLOC_BLOCK(inode) = 0;
UDF_I_NEXT_ALLOC_GOAL(inode) = 0;
@@ -1074,58 +1048,6 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
alen = offset + UDF_I_LENALLOC(inode);
}
- switch (UDF_I_ALLOCTYPE(inode))
- {
- case ICB_FLAG_AD_SHORT:
- {
- short_ad * sa;
-
- sa = udf_get_fileshortad(fe, alen, &offset, 1);
- if (sa)
- {
- UDF_I_EXT0LEN(inode) = le32_to_cpu(sa->extLength);
- UDF_I_EXT0LOC(inode).logicalBlockNum = le32_to_cpu(sa->extPosition);
- UDF_I_EXT0LOC(inode).partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum;
- }
- break;
- }
- case ICB_FLAG_AD_LONG:
- {
- long_ad * la;
-
- la = udf_get_filelongad(fe, alen, &offset, 1);
- if (la)
- {
- UDF_I_EXT0LEN(inode) = le32_to_cpu(la->extLength);
- UDF_I_EXT0LOC(inode).logicalBlockNum = le32_to_cpu(la->extLocation.logicalBlockNum);
- UDF_I_EXT0LOC(inode).partitionReferenceNum = le16_to_cpu(la->extLocation.partitionReferenceNum);
- }
- break;
- }
- case ICB_FLAG_AD_EXTENDED:
- {
- extent_ad * ext;
-
- ext = udf_get_fileextent(fe, alen, &offset);
- if ( (ext) && (ext->extLength) )
- {
- UDF_I_EXT0LEN(inode) = le32_to_cpu(ext->extLength);
-#if 0
- UDF_I_EXT0LOC(inode) = ext->extLocation;
-#endif
- }
- break;
- }
- case ICB_FLAG_AD_IN_ICB: /* short directories */
- {
- UDF_I_EXT0LEN(inode) = le32_to_cpu(fe->lengthAllocDescs);
- UDF_I_EXT0LOC(inode) = UDF_I_LOCATION(inode);
- UDF_I_EXT0OFFS(inode) = sizeof(struct FileEntry) +
- le32_to_cpu(fe->lengthExtendedAttr);
- break;
- }
- } /* end switch ad_type */
-
switch (fe->icbTag.fileType)
{
case FILE_TYPE_DIRECTORY:
@@ -1162,7 +1084,6 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
}
case FILE_TYPE_SYMLINK:
{
- /* untested! */
inode->i_op = &udf_symlink_inode_operations;
inode->i_mode = S_IFLNK|S_IRWXUGO;
break;
@@ -1184,7 +1105,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
if (dsea)
{
- init_special_inode(inode, inode->i_mode,
+ init_special_inode(inode, inode->i_mode,
((le32_to_cpu(dsea->majorDeviceIdent)) << 8) |
(le32_to_cpu(dsea->minorDeviceIdent) & 0xFF));
/* Developer ID ??? */
@@ -1440,19 +1361,11 @@ udf_iget(struct super_block *sb, lb_addr ino)
block = udf_get_lb_pblock(sb, ino, 0);
- down(&read_semaphore); /* serialize access to UDF_SB_LOCATION() */
- /* This is really icky.. should fix -- blf */
-
- /* put the location where udf_read_inode can find it */
- memcpy(&UDF_SB_LOCATION(sb), &ino, sizeof(lb_addr));
-
/* Get the inode */
inode = iget(sb, block);
/* calls udf_read_inode() ! */
- up(&read_semaphore);
-
if (!inode)
{
printk(KERN_ERR "udf: iget() failed\n");
@@ -1463,6 +1376,12 @@ udf_iget(struct super_block *sb, lb_addr ino)
iput(inode);
return NULL;
}
+ else if (UDF_I_LOCATION(inode).logicalBlockNum == 0xFFFFFFFF &&
+ UDF_I_LOCATION(inode).partitionReferenceNum == 0xFFFF)
+ {
+ memcpy(&UDF_I_LOCATION(inode), &ino, sizeof(lb_addr));
+ __udf_read_inode(inode);
+ }
if ( ino.logicalBlockNum >= UDF_SB_PARTLEN(sb, ino.partitionReferenceNum) )
{
@@ -1732,6 +1651,14 @@ int udf_next_aext(struct inode *inode, lb_addr *bloc, int *extoffset,
}
break;
}
+ case ICB_FLAG_AD_IN_ICB:
+ {
+ *bloc = *eloc = UDF_I_LOCATION(inode);
+ *elen = UDF_I_LENALLOC(inode);
+ *extoffset = udf_file_entry_alloc_offset(inode);
+ etype = EXTENT_RECORDED_ALLOCATED;
+ break;
+ }
default:
{
udf_debug("alloc_type = %d unsupported\n", UDF_I_ALLOCTYPE(inode));
@@ -1741,7 +1668,8 @@ int udf_next_aext(struct inode *inode, lb_addr *bloc, int *extoffset,
if (*elen)
return etype;
- udf_debug("Empty Extent!\n");
+ udf_debug("Empty Extent, inode=%ld, alloctype=%d, elen=%d, etype=%d, extoffset=%d\n",
+ inode->i_ino, UDF_I_ALLOCTYPE(inode), *elen, etype, *extoffset);
if (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_SHORT)
*extoffset -= sizeof(short_ad);
else if (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_LONG)
@@ -1974,26 +1902,22 @@ int inode_bmap(struct inode *inode, int block, lb_addr *bloc, Uint32 *extoffset,
return -1;
}
+ *extoffset = udf_file_entry_alloc_offset(inode);
+ *elen = 0;
b_off = block << inode->i_sb->s_blocksize_bits;
*bloc = UDF_I_LOCATION(inode);
- *eloc = UDF_I_EXT0LOC(inode);
- *elen = UDF_I_EXT0LEN(inode) & UDF_EXTENT_LENGTH_MASK;
- *extoffset = udf_file_entry_alloc_offset(inode);
- if (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_SHORT)
- *extoffset += sizeof(short_ad);
- else if (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_LONG)
- *extoffset += sizeof(long_ad);
- etype = UDF_I_EXT0LEN(inode) >> 30;
- while (lbcount + *elen <= b_off)
+ do
{
lbcount += *elen;
+
if ((etype = udf_next_aext(inode, bloc, extoffset, eloc, elen, bh, 1)) == -1)
{
*offset = (b_off - lbcount) >> inode->i_sb->s_blocksize_bits;
return -1;
}
- }
+ } while (lbcount + *elen <= b_off);
+
*offset = (b_off - lbcount) >> inode->i_sb->s_blocksize_bits;
return etype;
@@ -2029,3 +1953,58 @@ long udf_block_map(struct inode *inode, long block)
unlock_kernel();
return ret;
}
+
+int udf_readpage_adinicb (struct dentry *dentry, struct page * page)
+{
+ struct inode *inode = dentry->d_inode;
+
+ struct buffer_head *bh;
+ int block;
+ unsigned long kaddr = 0;
+
+ if (!PageLocked(page))
+ PAGE_BUG(page);
+
+ kaddr = kmap(page);
+ memset((char *)kaddr, 0, PAGE_CACHE_SIZE);
+ block = udf_get_lb_pblock(inode->i_sb, UDF_I_LOCATION(inode), 0);
+ bh = getblk (inode->i_dev, block, inode->i_sb->s_blocksize);
+ ll_rw_block (READ, 1, &bh);
+ wait_on_buffer(bh);
+ memcpy((char *)kaddr, bh->b_data + udf_ext0_offset(inode),
+ inode->i_size);
+ brelse(bh);
+ SetPageUptodate(page);
+ kunmap(page);
+ UnlockPage(page);
+ return 0;
+}
+
+int udf_writepage_adinicb (struct dentry *dentry, struct page *page)
+{
+ struct inode *inode = dentry->d_inode;
+
+ struct buffer_head *bh;
+ int block;
+ unsigned long kaddr = 0;
+
+ if (!PageLocked(page))
+ BUG();
+
+ kaddr = kmap(page);
+ block = udf_get_lb_pblock(inode->i_sb, UDF_I_LOCATION(inode), 0);
+ bh = getblk (inode->i_dev, block, inode->i_sb->s_blocksize);
+ if (!buffer_uptodate(bh))
+ {
+ ll_rw_block (READ, 1, &bh);
+ wait_on_buffer(bh);
+ }
+ memcpy(bh->b_data + udf_ext0_offset(inode), (char *)kaddr,
+ inode->i_size);
+ ll_rw_block (WRITE, 1, &bh);
+ wait_on_buffer(bh);
+ brelse(bh);
+ SetPageUptodate(page);
+ kunmap(page);
+ return 0;
+}
diff --git a/fs/udf/lowlevel.c b/fs/udf/lowlevel.c
index dee98ad71..d8993254e 100644
--- a/fs/udf/lowlevel.c
+++ b/fs/udf/lowlevel.c
@@ -15,7 +15,7 @@
* ftp://prep.ai.mit.edu/pub/gnu/GPL
* Each contributing author retains all rights to their own work.
*
- * (C) 1999 Ben Fennema
+ * (C) 1999-2000 Ben Fennema
*
* HISTORY
*
@@ -47,16 +47,21 @@ udf_get_last_session(struct super_block *sb)
vol_desc_start=0;
ms_info.addr_format=CDROM_LBA;
- i=ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long) &ms_info);
+ i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long) &ms_info);
+
#define WE_OBEY_THE_WRITTEN_STANDARDS 1
- if (i == 0) {
+
+ if (i == 0)
+ {
udf_debug("XA disk: %s, vol_desc_start=%d\n",
(ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba);
#if WE_OBEY_THE_WRITTEN_STANDARDS
if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */
#endif
vol_desc_start = ms_info.addr.lba;
- } else {
+ }
+ else
+ {
udf_debug("CDROMMULTISESSION not supported: rc=%d\n", i);
}
return vol_desc_start;
@@ -86,17 +91,20 @@ udf_get_last_block(struct super_block *sb, int *flags)
lblock = 0;
ret = ioctl_by_bdev(bdev, BLKGETSIZE, (unsigned long) &lblock);
- if (!ret && lblock != 0x7FFFFFFF) {
- /* Hard Disk */
+ if (!ret && lblock != 0x7FFFFFFF) /* Hard Disk */
+ {
if (mult)
lblock *= mult;
else if (div)
lblock /= div;
- } else {
- /* CDROM */
+ }
+ else /* CDROM */
+ {
ret = ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long) &lblock);
}
+
if (!ret && lblock)
return lblock - 1;
- return 0;
+ else
+ return 0;
}
diff --git a/fs/udf/misc.c b/fs/udf/misc.c
index 0b2068015..834727ae8 100644
--- a/fs/udf/misc.c
+++ b/fs/udf/misc.c
@@ -16,8 +16,8 @@
* Each contributing author retains all rights to their own work.
*
* (C) 1998 Dave Boynton
- * (C) 1998-1999 Ben Fennema
- * (C) 1999 Stelias Computing Inc
+ * (C) 1998-2000 Ben Fennema
+ * (C) 1999-2000 Stelias Computing Inc
*
* HISTORY
*
@@ -64,20 +64,6 @@ udf64_high32(Uint64 indat)
return indat >> 32;
}
-uid_t udf_convert_uid(int uidin)
-{
- if ( uidin == -1 )
- return 0;
- return uidin;
-}
-
-gid_t udf_convert_gid(int gidin)
-{
- if ( gidin == -1 )
- return 0;
- return gidin;
-}
-
#if defined(__linux__) && defined(__KERNEL__)
extern struct buffer_head *
@@ -138,7 +124,6 @@ udf_add_extendedattr(struct inode * inode, Uint32 size, Uint32 type,
if (UDF_I_LENALLOC(inode))
{
memmove(&ad[size], ad, UDF_I_LENALLOC(inode));
- UDF_I_EXT0OFFS(inode) += size;
}
if (UDF_I_LENEATTR(inode))
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index ebf344832..1f54833e4 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -15,14 +15,13 @@
* ftp://prep.ai.mit.edu/pub/gnu/GPL
* Each contributing author retains all rights to their own work.
*
- * (C) 1998-1999 Ben Fennema
- * (C) 1999 Stelias Computing Inc
+ * (C) 1998-2000 Ben Fennema
+ * (C) 1999-2000 Stelias Computing Inc
*
* HISTORY
*
- * 12/12/98 blf Created. Split out the lookup code from dir.c
- * 04/19/99 blf link, mknod, symlink support
- *
+ * 12/12/98 blf Created. Split out the lookup code from dir.c
+ * 04/19/99 blf link, mknod, symlink support
*/
#include "udfdecl.h"
@@ -153,7 +152,7 @@ udf_find_entry(struct inode *dir, struct dentry *dentry,
char *nameptr;
Uint8 lfi;
Uint16 liu;
- loff_t size = (UDF_I_EXT0OFFS(dir) + dir->i_size) >> 2;
+ loff_t size = (udf_ext0_offset(dir) + dir->i_size) >> 2;
lb_addr bloc, eloc;
Uint32 extoffset, elen, offset;
struct buffer_head *bh = NULL;
@@ -161,7 +160,7 @@ udf_find_entry(struct inode *dir, struct dentry *dentry,
if (!dir)
return NULL;
- f_pos = (UDF_I_EXT0OFFS(dir) >> 2);
+ f_pos = (udf_ext0_offset(dir) >> 2);
fibh->soffset = fibh->eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2),
@@ -297,6 +296,9 @@ udf_lookup(struct inode *dir, struct dentry *dentry)
struct FileIdentDesc cfi, *fi;
struct udf_fileident_bh fibh;
+ if (dentry->d_name.len > UDF_NAME_LEN)
+ return ERR_PTR(-ENAMETOOLONG);
+
#ifdef UDF_RECOVERY
/* temporary shorthand for specifying files by inode number */
if (!strncmp(dentry->d_name.name, ".B=", 3) )
@@ -336,7 +338,7 @@ udf_add_entry(struct inode *dir, struct dentry *dentry,
loff_t f_pos;
int flen;
char *nameptr;
- loff_t size = (UDF_I_EXT0OFFS(dir) + dir->i_size) >> 2;
+ loff_t size = (udf_ext0_offset(dir) + dir->i_size) >> 2;
int nfidlen;
Uint8 lfi;
Uint16 liu;
@@ -370,7 +372,7 @@ udf_add_entry(struct inode *dir, struct dentry *dentry,
nfidlen = (sizeof(struct FileIdentDesc) + 0 + namelen + 3) & ~3;
- f_pos = (UDF_I_EXT0OFFS(dir) >> 2);
+ f_pos = (udf_ext0_offset(dir) >> 2);
fibh->soffset = fibh->eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2),
@@ -473,13 +475,13 @@ udf_add_entry(struct inode *dir, struct dentry *dentry,
{
udf_release_data(bh);
bh = NULL;
- fibh->soffset -= UDF_I_EXT0OFFS(dir);
- fibh->eoffset -= UDF_I_EXT0OFFS(dir);
- f_pos -= (UDF_I_EXT0OFFS(dir) >> 2);
+ fibh->soffset -= udf_ext0_offset(dir);
+ fibh->eoffset -= udf_ext0_offset(dir);
+ f_pos -= (udf_ext0_offset(dir) >> 2);
if (fibh->sbh != fibh->ebh)
udf_release_data(fibh->ebh);
udf_release_data(fibh->sbh);
- if (!(fibh->sbh = fibh->ebh = udf_expand_adinicb(dir, &block, 1, err)))
+ if (!(fibh->sbh = fibh->ebh = udf_expand_dir_adinicb(dir, &block, err)))
return NULL;
bloc = UDF_I_LOCATION(dir);
extoffset = udf_file_entry_alloc_offset(dir);
@@ -640,7 +642,7 @@ int udf_create(struct inode *dir, struct dentry *dentry, int mode)
if (!inode)
return err;
- inode->i_op = &udf_file_inode_operations;
+ inode->i_op = &udf_file_inode_operations_adinicb;
inode->i_mode = mode;
mark_inode_dirty(inode);
@@ -682,6 +684,7 @@ int udf_mknod(struct inode * dir, struct dentry * dentry, int mode, int rdev)
goto out;
inode->i_uid = current->fsuid;
+ init_special_inode(inode, mode, rdev);
inode->i_mode = mode;
inode->i_op = NULL;
if (!(fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err)))
@@ -702,7 +705,6 @@ int udf_mknod(struct inode * dir, struct dentry * dentry, int mode, int rdev)
mark_inode_dirty(dir);
dir->i_version = ++event;
}
- init_special_inode(inode, mode, rdev);
mark_inode_dirty(inode);
if (fibh.sbh != fibh.ebh)
@@ -734,19 +736,9 @@ int udf_mkdir(struct inode * dir, struct dentry * dentry, int mode)
inode->i_op = &udf_dir_inode_operations;
inode->i_size = (sizeof(struct FileIdentDesc) + 3) & ~3;
- if (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_IN_ICB)
- {
- UDF_I_EXT0LEN(inode) = inode->i_size;
- UDF_I_EXT0LOC(inode) = UDF_I_LOCATION(inode);
- UDF_I_LENALLOC(inode) = inode->i_size;
- loc = UDF_I_LOCATION(inode).logicalBlockNum;
- fibh.sbh = udf_tread(inode->i_sb, inode->i_ino, inode->i_sb->s_blocksize);
- }
- else
- {
- fibh.sbh = udf_bread (inode, 0, 1, &err);
- loc = UDF_I_EXT0LOC(inode).logicalBlockNum;
- }
+ UDF_I_LENALLOC(inode) = inode->i_size;
+ loc = UDF_I_LOCATION(inode).logicalBlockNum;
+ fibh.sbh = udf_tread(inode->i_sb, inode->i_ino, inode->i_sb->s_blocksize);
if (!fibh.sbh)
{
@@ -809,13 +801,13 @@ static int empty_dir(struct inode *dir)
struct FileIdentDesc *fi, cfi;
struct udf_fileident_bh fibh;
loff_t f_pos;
- loff_t size = (UDF_I_EXT0OFFS(dir) + dir->i_size) >> 2;
+ loff_t size = (udf_ext0_offset(dir) + dir->i_size) >> 2;
int block;
lb_addr bloc, eloc;
Uint32 extoffset, elen, offset;
struct buffer_head *bh = NULL;
- f_pos = (UDF_I_EXT0OFFS(dir) >> 2);
+ f_pos = (udf_ext0_offset(dir) >> 2);
fibh.soffset = fibh.eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2),
@@ -1170,7 +1162,7 @@ int udf_rename (struct inode * old_dir, struct dentry * old_dentry,
}
if (S_ISDIR(old_inode->i_mode))
{
- Uint32 offset = UDF_I_EXT0OFFS(old_inode);
+ Uint32 offset = udf_ext0_offset(old_inode);
if (new_inode)
{
@@ -1203,6 +1195,14 @@ int udf_rename (struct inode * old_dir, struct dentry * old_dentry,
new_dir->i_version = ++event;
/*
+ * Like most other Unix systems, set the ctime for inodes on a
+ * rename.
+ */
+ old_inode->i_ctime = CURRENT_TIME;
+ UDF_I_UCTIME(old_inode) = CURRENT_UTIME;
+ mark_inode_dirty(old_inode);
+
+ /*
* ok, that's it
*/
ncfi.fileVersionNum = ocfi.fileVersionNum;
diff --git a/fs/udf/partition.c b/fs/udf/partition.c
index ecfabb849..658d2220e 100644
--- a/fs/udf/partition.c
+++ b/fs/udf/partition.c
@@ -30,161 +30,204 @@
#include <linux/fs.h>
#include <linux/string.h>
#include <linux/udf_fs.h>
+#include <linux/malloc.h>
-extern Uint32 udf_get_pblock(struct super_block *sb, Uint32 block, Uint16 partition, Uint32 offset)
+inline Uint32 udf_get_pblock(struct super_block *sb, Uint32 block, Uint16 partition, Uint32 offset)
{
- Uint16 ident;
-
if (partition >= UDF_SB_NUMPARTS(sb))
{
udf_debug("block=%d, partition=%d, offset=%d: invalid partition\n",
block, partition, offset);
return 0xFFFFFFFF;
}
- switch (UDF_SB_PARTTYPE(sb, partition))
+ if (UDF_SB_PARTFUNC(sb, partition))
+ return UDF_SB_PARTFUNC(sb, partition)(sb, block, partition, offset);
+ else
+ return UDF_SB_PARTROOT(sb, partition) + block + offset;
+}
+
+Uint32 udf_get_pblock_virt15(struct super_block *sb, Uint32 block, Uint16 partition, Uint32 offset)
+{
+ struct buffer_head *bh = NULL;
+ Uint32 newblock;
+ Uint32 index;
+ Uint32 loc;
+
+ index = (sb->s_blocksize - UDF_SB_TYPEVIRT(sb,partition).s_start_offset) / sizeof(Uint32);
+
+ if (block > UDF_SB_TYPEVIRT(sb,partition).s_num_entries)
{
- case UDF_TYPE1_MAP15:
- {
- return UDF_SB_PARTROOT(sb, partition) + block + offset;
- }
- case UDF_VIRTUAL_MAP15:
- case UDF_VIRTUAL_MAP20:
- {
- struct buffer_head *bh = NULL;
- Uint32 newblock;
- Uint32 index;
- Uint32 loc;
+ udf_debug("Trying to access block beyond end of VAT (%d max %d)\n",
+ block, UDF_SB_TYPEVIRT(sb,partition).s_num_entries);
+ return 0xFFFFFFFF;
+ }
- index = (sb->s_blocksize - UDF_SB_TYPEVIRT(sb,partition).s_start_offset) / sizeof(Uint32);
+ if (block >= index)
+ {
+ block -= index;
+ newblock = 1 + (block / (sb->s_blocksize / sizeof(Uint32)));
+ index = block % (sb->s_blocksize / sizeof(Uint32));
+ }
+ else
+ {
+ newblock = 0;
+ index = UDF_SB_TYPEVIRT(sb,partition).s_start_offset / sizeof(Uint32) + block;
+ }
+ loc = udf_locked_block_map(UDF_SB_VAT(sb), newblock);
- if (block > UDF_SB_TYPEVIRT(sb,partition).s_num_entries)
- {
- udf_debug("Trying to access block beyond end of VAT (%d max %d)\n",
- block, UDF_SB_TYPEVIRT(sb,partition).s_num_entries);
- return 0xFFFFFFFF;
- }
+ if (!(bh = bread(sb->s_dev, loc, sb->s_blocksize)))
+ {
+ udf_debug("get_pblock(UDF_VIRTUAL_MAP:%p,%d,%d) VAT: %d[%d]\n",
+ sb, block, partition, loc, index);
+ return 0xFFFFFFFF;
+ }
- if (block >= index)
- {
- block -= index;
- newblock = 1 + (block / (sb->s_blocksize / sizeof(Uint32)));
- index = block % (sb->s_blocksize / sizeof(Uint32));
- }
- else
- {
- newblock = 0;
- index = UDF_SB_TYPEVIRT(sb,partition).s_start_offset / sizeof(Uint32) + block;
- }
+ loc = le32_to_cpu(((Uint32 *)bh->b_data)[index]);
- loc = udf_locked_block_map(UDF_SB_VAT(sb), newblock);
+ udf_release_data(bh);
- if (!(bh = bread(sb->s_dev, loc, sb->s_blocksize)))
- {
- udf_debug("get_pblock(UDF_VIRTUAL_MAP:%p,%d,%d) VAT: %d[%d]\n",
- sb, block, partition, loc, index);
- return 0xFFFFFFFF;
- }
+ if (UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum == partition)
+ {
+ udf_debug("recursive call to udf_get_pblock!\n");
+ return 0xFFFFFFFF;
+ }
- loc = le32_to_cpu(((Uint32 *)bh->b_data)[index]);
+ return udf_get_pblock(sb, loc, UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum, offset);
+}
- udf_release_data(bh);
+inline Uint32 udf_get_pblock_virt20(struct super_block *sb, Uint32 block, Uint16 partition, Uint32 offset)
+{
+ return udf_get_pblock_virt15(sb, block, partition, offset);
+}
- if (UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum == partition)
- {
- udf_debug("recursive call to udf_get_pblock!\n");
- return 0xFFFFFFFF;
- }
+Uint32 udf_get_pblock_spar15(struct super_block *sb, Uint32 block, Uint16 partition, Uint32 offset)
+{
+ Uint32 packet = (block + offset) >> UDF_SB_TYPESPAR(sb,partition).s_spar_pshift;
+ Uint32 index = 0;
- return udf_get_pblock(sb, loc, UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum, offset);
- }
- case UDF_SPARABLE_MAP15:
- {
- Uint32 newblock = UDF_SB_PARTROOT(sb, partition) + block + offset;
- Uint32 spartable = UDF_SB_TYPESPAR(sb, partition).s_spar_loc;
- Uint32 plength = UDF_SB_TYPESPAR(sb,partition).s_spar_plen;
- Uint32 packet = (block + offset) & (~(plength-1));
- struct buffer_head *bh = NULL;
- struct SparingTable *st;
- SparingEntry *se;
+ if (UDF_SB_TYPESPAR(sb,partition).s_spar_indexsize == 8)
+ index = UDF_SB_TYPESPAR(sb,partition).s_spar_remap.s_spar_remap8[packet];
+ else if (UDF_SB_TYPESPAR(sb,partition).s_spar_indexsize == 16)
+ index = UDF_SB_TYPESPAR(sb,partition).s_spar_remap.s_spar_remap16[packet];
+ else if (UDF_SB_TYPESPAR(sb,partition).s_spar_indexsize == 32)
+ index = UDF_SB_TYPESPAR(sb,partition).s_spar_remap.s_spar_remap32[packet];
- bh = udf_read_tagged(sb, spartable, spartable, &ident);
+ if (index == ((1 << UDF_SB_TYPESPAR(sb,partition).s_spar_indexsize)-1))
+ return UDF_SB_PARTROOT(sb,partition) + block + offset;
- if (!bh)
- {
- printk(KERN_ERR "udf: udf_read_tagged(%p,%d,%d)\n",
- sb, spartable, spartable);
- return 0xFFFFFFFF;
- }
+ packet = UDF_SB_TYPESPAR(sb,partition).s_spar_map[index];
+ return packet + ((block + offset) & ((1 << UDF_SB_TYPESPAR(sb,partition).s_spar_pshift)-1));
+}
+
+void udf_fill_spartable(struct super_block *sb, struct udf_sparing_data *sdata, int partlen)
+{
+ Uint16 ident;
+ Uint32 spartable;
+ int i;
+ struct buffer_head *bh;
+ struct SparingTable *st;
+
+ for (i=0; i<4; i++)
+ {
+ if (!(spartable = sdata->s_spar_loc[i]))
+ continue;
+
+ bh = udf_read_tagged(sb, spartable, spartable, &ident);
+
+ if (!bh)
+ {
+ sdata->s_spar_loc[i] = 0;
+ continue;
+ }
+ if (ident == 0)
+ {
st = (struct SparingTable *)bh->b_data;
- if (ident == 0)
+ if (!strncmp(st->sparingIdent.ident, UDF_ID_SPARING, strlen(UDF_ID_SPARING)))
{
- if (!strncmp(st->sparingIdent.ident, UDF_ID_SPARING, strlen(UDF_ID_SPARING)))
- {
- Uint16 rtl = le16_to_cpu(st->reallocationTableLen);
- Uint16 index;
+ SparingEntry *se;
+ Uint16 rtl = le16_to_cpu(st->reallocationTableLen);
+ int index;
- /* If the sparing table span multiple blocks, find out which block we are on */
-
- se = &(st->mapEntry[0]);
+ if (!sdata->s_spar_map)
+ {
+ int num = 1, mapsize;
+ sdata->s_spar_indexsize = 8;
+ while (rtl*sizeof(Uint32) >= (1 << sdata->s_spar_indexsize))
+ {
+ num ++;
+ sdata->s_spar_indexsize <<= 1;
+ }
+ mapsize = (rtl * sizeof(Uint32)) +
+ ((partlen/(1 << sdata->s_spar_pshift)) * sizeof(Uint8) * num);
+ sdata->s_spar_map = kmalloc(mapsize, GFP_KERNEL);
+ sdata->s_spar_remap.s_spar_remap32 = &sdata->s_spar_map[rtl];
+ memset(sdata->s_spar_map, 0xFF, mapsize);
+ }
- if (rtl * sizeof(SparingEntry) + sizeof(struct SparingTable) > sb->s_blocksize)
+ index = sizeof(struct SparingTable);
+ for (i=0; i<rtl; i++)
+ {
+ if (index > sb->s_blocksize)
{
- index = (sb->s_blocksize - sizeof(struct SparingTable)) / sizeof(SparingEntry);
- if (le32_to_cpu(se[index-1].origLocation) == packet)
+ udf_release_data(bh);
+ bh = udf_tread(sb, ++spartable, sb->s_blocksize);
+ if (!bh)
{
- udf_release_data(bh);
- return le32_to_cpu(se[index].mappedLocation) | (newblock & (plength-1));
+ sdata->s_spar_loc[i] = 0;
+ continue;
}
- else if (le32_to_cpu(se[index-1].origLocation) < packet)
+ index = 0;
+ }
+ se = (SparingEntry *)&(bh->b_data[index]);
+ index += sizeof(SparingEntry);
+
+ if (sdata->s_spar_map[i] == 0xFFFFFFFF)
+ sdata->s_spar_map[i] = le32_to_cpu(se->mappedLocation);
+ else if (sdata->s_spar_map[i] != le32_to_cpu(se->mappedLocation))
+ {
+ udf_debug("Found conflicting Sparing Data (%d vs %d for entry %d)\n",
+ sdata->s_spar_map[i], le32_to_cpu(se->mappedLocation), i);
+ }
+
+ if (le32_to_cpu(se->origLocation) < 0xFFFFFFF0)
+ {
+ int packet = le32_to_cpu(se->origLocation) >> sdata->s_spar_pshift;
+ if (sdata->s_spar_indexsize == 8)
{
- do
+ if (sdata->s_spar_remap.s_spar_remap8[packet] == 0xFF)
+ sdata->s_spar_remap.s_spar_remap8[packet] = i;
+ else if (sdata->s_spar_remap.s_spar_remap8[packet] != i)
{
- udf_release_data(bh);
- bh = udf_tread(sb, spartable, sb->s_blocksize);
- if (!bh)
- return 0xFFFFFFFF;
- se = (SparingEntry *)bh->b_data;
- spartable ++;
- rtl -= index;
- index = sb->s_blocksize / sizeof(SparingEntry);
-
- if (le32_to_cpu(se[index].origLocation) == packet)
- {
- udf_release_data(bh);
- return le32_to_cpu(se[index].mappedLocation) | (newblock & (plength-1));
- }
- } while (rtl * sizeof(SparingEntry) > sb->s_blocksize &&
- le32_to_cpu(se[index-1].origLocation) < packet);
+ udf_debug("Found conflicting Sparing Data (%d vs %d)\n",
+ sdata->s_spar_remap.s_spar_remap8[packet], i);
+ }
}
- }
-
- for (index=0; index<rtl; index++)
- {
- if (le32_to_cpu(se[index].origLocation) == packet)
+ else if (sdata->s_spar_indexsize == 16)
{
- udf_release_data(bh);
- return le32_to_cpu(se[index].mappedLocation) | (newblock & (plength-1));
+ if (sdata->s_spar_remap.s_spar_remap16[packet] == 0xFFFF)
+ sdata->s_spar_remap.s_spar_remap16[packet] = i;
+ else if (sdata->s_spar_remap.s_spar_remap16[packet] != i)
+ {
+ udf_debug("Found conflicting Sparing Data (%d vs %d)\n",
+ sdata->s_spar_remap.s_spar_remap16[packet], i);
+ }
}
- else if (le32_to_cpu(se[index].origLocation) > packet)
+ else if (sdata->s_spar_indexsize == 32)
{
- udf_release_data(bh);
- return newblock;
+ if (sdata->s_spar_remap.s_spar_remap32[packet] == 0xFFFFFFFF)
+ sdata->s_spar_remap.s_spar_remap32[packet] = i;
+ else if (sdata->s_spar_remap.s_spar_remap32[packet] != i)
+ {
+ udf_debug("Found conflicting Sparing Data (%d vs %d)\n",
+ sdata->s_spar_remap.s_spar_remap32[packet], i);
+ }
}
}
-
- udf_release_data(bh);
- return newblock;
}
}
- udf_release_data(bh);
}
+ udf_release_data(bh);
}
- return 0xFFFFFFFF;
-}
-
-extern Uint32 udf_get_lb_pblock(struct super_block *sb, lb_addr loc, Uint32 offset)
-{
- return udf_get_pblock(sb, loc.logicalBlockNum, loc.partitionReferenceNum, offset);
}
diff --git a/fs/udf/super.c b/fs/udf/super.c
index aba702b57..272b9eacb 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -26,7 +26,8 @@
* Each contributing author retains all rights to their own work.
*
* (C) 1998 Dave Boynton
- * (C) 1998-1999 Ben Fennema
+ * (C) 1998-2000 Ben Fennema
+ * (C) 2000 Stelias Computing Inc
*
* HISTORY
*
@@ -91,29 +92,27 @@ static void udf_load_partdesc(struct super_block *, struct buffer_head *);
static void udf_open_lvid(struct super_block *);
static void udf_close_lvid(struct super_block *);
static unsigned int udf_count_free(struct super_block *);
-
-/* version specific functions */
static int udf_statfs(struct super_block *, struct statfs *, int);
/* UDF filesystem type */
static struct file_system_type udf_fstype = {
- "udf", /* name */
+ "udf", /* name */
FS_REQUIRES_DEV, /* fs_flags */
udf_read_super, /* read_super */
- NULL /* next */
+ NULL /* next */
};
/* Superblock operations */
static struct super_operations udf_sb_ops =
{
udf_read_inode, /* read_inode */
-#ifdef CONFIG_UDF_RW
+#if CONFIG_UDF_RW == 1
udf_write_inode, /* write_inode */
#else
NULL, /* write_inode */
#endif
udf_put_inode, /* put_inode */
-#ifdef CONFIG_UDF_RW
+#if CONFIG_UDF_RW == 1
udf_delete_inode, /* delete_inode */
#else
NULL, /* delete_inode */
@@ -130,7 +129,6 @@ static struct super_operations udf_sb_ops =
struct udf_options
{
unsigned char novrs;
- unsigned char utf8;
unsigned int blocksize;
unsigned int session;
unsigned int lastblock;
@@ -143,7 +141,6 @@ struct udf_options
mode_t umask;
gid_t gid;
uid_t uid;
- char *iocharset;
};
#if defined(MODULE)
@@ -194,8 +191,8 @@ int __init init_udf_fs(void)
if ( size < sizeof(struct udf_sb_info) )
{
printk(KERN_ERR "udf: Danger! Kernel was compiled without enough room for udf_sb_info\n");
- printk(KERN_ERR "udf: Kernel has room for %u bytes, udf needs %u\n",
- size, sizeof(struct udf_sb_info));
+ printk(KERN_ERR "udf: Kernel has room for %u bytes, udf needs %lu\n",
+ size, (unsigned long)sizeof(struct udf_sb_info));
return 0;
}
}
@@ -217,8 +214,6 @@ int __init init_udf_fs(void)
* unhide Show otherwise hidden files.
* undelete Show deleted files in lists.
* strict Set strict conformance (unused)
- * utf8 (unused)
- * iocharset (unused)
*
* The remaining are for debugging and disaster recovery:
*
@@ -267,7 +262,6 @@ udf_parse_options(char *options, struct udf_options *uopt)
uopt->volume = 0xFFFFFFFF;
uopt->rootdir = 0xFFFFFFFF;
uopt->fileset = 0xFFFFFFFF;
- uopt->iocharset = NULL;
if (!options)
return 1;
@@ -280,8 +274,6 @@ udf_parse_options(char *options, struct udf_options *uopt)
*(val++) = 0;
if (!strcmp(opt, "novrs") && !val)
uopt->novrs = 1;
- else if (!strcmp(opt, "utf8") && !val)
- uopt->utf8 = 1;
else if (!strcmp(opt, "bs") && val)
uopt->blocksize = simple_strtoul(val, NULL, 0);
else if (!strcmp(opt, "unhide") && !val)
@@ -310,15 +302,6 @@ udf_parse_options(char *options, struct udf_options *uopt)
uopt->fileset = simple_strtoul(val, NULL, 0);
else if (!strcmp(opt, "rootdir") && val)
uopt->rootdir = simple_strtoul(val, NULL, 0);
- else if (!strcmp(opt, "iocharset") && val)
- {
- uopt->iocharset = val;
- while (*val && *val != ',')
- val ++;
- if (val == uopt->iocharset)
- return 0;
- *val = 0;
- }
else if (val)
{
printk(KERN_ERR "udf: bad mount option \"%s=%s\"\n",
@@ -344,7 +327,6 @@ udf_remount_fs(struct super_block *sb, int *flags, char *options)
uopt.uid = UDF_SB(sb)->s_uid ;
uopt.gid = UDF_SB(sb)->s_gid ;
uopt.umask = UDF_SB(sb)->s_umask ;
- uopt.utf8 = UDF_SB(sb)->s_utf8 ;
if ( !udf_parse_options(options, &uopt) )
return -EINVAL;
@@ -353,7 +335,6 @@ udf_remount_fs(struct super_block *sb, int *flags, char *options)
UDF_SB(sb)->s_uid = uopt.uid;
UDF_SB(sb)->s_gid = uopt.gid;
UDF_SB(sb)->s_umask = uopt.umask;
- UDF_SB(sb)->s_utf8 = uopt.utf8;
if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
return 0;
@@ -841,6 +822,9 @@ udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
UDF_SB_PARTROOT(sb,i) = le32_to_cpu(p->partitionStartingLocation) + UDF_SB_SESSION(sb);
UDF_SB_PARTMAPS(sb)[i].s_uspace_bitmap = 0xFFFFFFFF;
+ if (UDF_SB_PARTTYPE(sb,i) == UDF_SPARABLE_MAP15)
+ udf_fill_spartable(sb, &UDF_SB_TYPESPAR(sb,i), UDF_SB_PARTLEN(sb,i));
+
if (!strcmp(p->partitionContents.ident, PARTITION_CONTENTS_NSR02) ||
!strcmp(p->partitionContents.ident, PARTITION_CONTENTS_NSR03))
{
@@ -882,7 +866,7 @@ static int
udf_load_logicalvol(struct super_block *sb, struct buffer_head * bh, lb_addr *fileset)
{
struct LogicalVolDesc *lvd;
- int i, offset;
+ int i, j, offset;
Uint8 type;
lvd = (struct LogicalVolDesc *)bh->b_data;
@@ -902,6 +886,7 @@ udf_load_logicalvol(struct super_block *sb, struct buffer_head * bh, lb_addr *fi
UDF_SB_PARTTYPE(sb,i) = UDF_TYPE1_MAP15;
UDF_SB_PARTVSN(sb,i) = le16_to_cpu(gpm1->volSeqNum);
UDF_SB_PARTNUM(sb,i) = le16_to_cpu(gpm1->partitionNum);
+ UDF_SB_PARTFUNC(sb,i) = NULL;
}
else if (type == 2)
{
@@ -909,16 +894,29 @@ udf_load_logicalvol(struct super_block *sb, struct buffer_head * bh, lb_addr *fi
if (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL, strlen(UDF_ID_VIRTUAL)))
{
if (le16_to_cpu(((Uint16 *)upm2->partIdent.identSuffix)[0]) == 0x0150)
+ {
UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP15;
+ UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt15;
+ }
else if (le16_to_cpu(((Uint16 *)upm2->partIdent.identSuffix)[0]) == 0x0200)
+ {
UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP20;
+ UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt20;
+ }
}
else if (!strncmp(upm2->partIdent.ident, UDF_ID_SPARABLE, strlen(UDF_ID_SPARABLE)))
{
+ int plen;
+
struct SparablePartitionMap *spm = (struct SparablePartitionMap *)&(lvd->partitionMaps[offset]);
UDF_SB_PARTTYPE(sb,i) = UDF_SPARABLE_MAP15;
- UDF_SB_TYPESPAR(sb,i).s_spar_plen = le16_to_cpu(spm->packetLength);
- UDF_SB_TYPESPAR(sb,i).s_spar_loc = le32_to_cpu(spm->locSparingTable[0]);
+ plen = le16_to_cpu(spm->packetLength);
+ UDF_SB_TYPESPAR(sb,i).s_spar_pshift = 0;
+ while (plen >>= 1)
+ UDF_SB_TYPESPAR(sb,i).s_spar_pshift ++;
+ for (j=0; j<spm->numSparingTables; j++)
+ UDF_SB_TYPESPAR(sb,i).s_spar_loc[j] = le32_to_cpu(spm->locSparingTable[j]);
+ UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_spar15;
}
else
{
@@ -1190,7 +1188,7 @@ udf_load_partition(struct super_block *sb, lb_addr *fileset)
if (UDF_SB_PARTTYPE(sb,i) == UDF_VIRTUAL_MAP15)
{
- UDF_SB_TYPEVIRT(sb,i).s_start_offset = UDF_I_EXT0OFFS(UDF_SB_VAT(sb));
+ UDF_SB_TYPEVIRT(sb,i).s_start_offset = udf_ext0_offset(UDF_SB_VAT(sb));
UDF_SB_TYPEVIRT(sb,i).s_num_entries = (UDF_SB_VAT(sb)->i_size - 36) >> 2;
}
else if (UDF_SB_PARTTYPE(sb,i) == UDF_VIRTUAL_MAP20)
@@ -1201,8 +1199,8 @@ udf_load_partition(struct super_block *sb, lb_addr *fileset)
pos = udf_block_map(UDF_SB_VAT(sb), 0);
bh = bread(sb->s_dev, pos, sb->s_blocksize);
UDF_SB_TYPEVIRT(sb,i).s_start_offset =
- le16_to_cpu(((struct VirtualAllocationTable20 *)bh->b_data + UDF_I_EXT0OFFS(UDF_SB_VAT(sb)))->lengthHeader) +
- UDF_I_EXT0OFFS(UDF_SB_VAT(sb));
+ le16_to_cpu(((struct VirtualAllocationTable20 *)bh->b_data + udf_ext0_offset(UDF_SB_VAT(sb)))->lengthHeader) +
+ udf_ext0_offset(UDF_SB_VAT(sb));
UDF_SB_TYPEVIRT(sb,i).s_num_entries = (UDF_SB_VAT(sb)->i_size -
UDF_SB_TYPEVIRT(sb,i).s_start_offset) >> 2;
udf_release_data(bh);
@@ -1218,7 +1216,7 @@ udf_load_partition(struct super_block *sb, lb_addr *fileset)
static void udf_open_lvid(struct super_block *sb)
{
-#ifdef CONFIG_UDF_RW
+#if CONFIG_UDF_RW == 1
if (UDF_SB_LVIDBH(sb))
{
int i;
@@ -1247,7 +1245,7 @@ static void udf_open_lvid(struct super_block *sb)
static void udf_close_lvid(struct super_block *sb)
{
-#ifdef CONFIG_UDF_RW
+#if CONFIG_UDF_RW == 1
if (UDF_SB_LVIDBH(sb) &&
UDF_SB_LVID(sb)->integrityType == INTEGRITY_TYPE_OPEN)
{
@@ -1301,10 +1299,9 @@ udf_read_super(struct super_block *sb, void *options, int silent)
int i;
uopt.flags = 0;
- uopt.uid = 0;
- uopt.gid = 0;
+ uopt.uid = -1;
+ uopt.gid = -1;
uopt.umask = 0;
- uopt.utf8 = 0;
/* Lock the module in memory (if applicable) */
MOD_INC_USE_COUNT;
@@ -1328,7 +1325,6 @@ udf_read_super(struct super_block *sb, void *options, int silent)
UDF_SB(sb)->s_uid = uopt.uid;
UDF_SB(sb)->s_gid = uopt.gid;
UDF_SB(sb)->s_umask = uopt.umask;
- UDF_SB(sb)->s_utf8 = uopt.utf8;
/* Set the block size for all transfers */
if (!udf_set_blocksize(sb, uopt.blocksize))
@@ -1356,20 +1352,6 @@ udf_read_super(struct super_block *sb, void *options, int silent)
goto error_out;
}
- UDF_SB_CHARSET(sb) = NULL;
-
-#ifdef CONFIG_NLS
- if (uopt.utf8 == 0)
- {
- char *p = uopt.iocharset ? uopt.iocharset : "iso8859-1";
- UDF_SB_CHARSET(sb) = load_nls(p);
- if (!UDF_SB_CHARSET(sb))
- if (uopt.iocharset)
- goto error_out;
- UDF_SB_CHARSET(sb) = load_nls_default();
- }
-#endif
-
/* Fill in the rest of the superblock */
sb->s_op = &udf_sb_ops;
sb->dq_op = NULL;
@@ -1405,7 +1387,8 @@ udf_read_super(struct super_block *sb, void *options, int silent)
{
timestamp ts;
udf_time_to_stamp(&ts, UDF_SB_RECORDTIME(sb), 0);
- udf_info("Mounting volume '%s', timestamp %04u/%02u/%02u %02u:%02u (%x)\n",
+ udf_info("UDF %s (%s) Mounting volume '%s', timestamp %04u/%02u/%02u %02u:%02u (%x)\n",
+ UDFFS_VERSION, UDFFS_DATE,
UDF_SB_VOLIDENT(sb), ts.year, ts.month, ts.day, ts.hour, ts.minute,
ts.typeAndTimezone);
}
diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c
index 63ebb5713..6e5dd233a 100644
--- a/fs/udf/symlink.c
+++ b/fs/udf/symlink.c
@@ -15,7 +15,7 @@
* ftp://prep.ai.mit.edu/pub/gnu/GPL
* Each contributing author retains all rights to their own work.
*
- * (C) 1998-1999 Ben Fennema
+ * (C) 1998-2000 Ben Fennema
* (C) 1999 Stelias Computing Inc
*
* HISTORY
@@ -39,14 +39,17 @@
static void udf_pc_to_char(char *from, int fromlen, char *to)
{
struct PathComponent *pc;
- int elen = 0, len = 0;
+ int elen = 0;
char *p = to;
- while (elen < fromlen) {
+ while (elen < fromlen)
+ {
pc = (struct PathComponent *)(from + elen);
- switch (pc->componentType) {
+ switch (pc->componentType)
+ {
case 1:
- if (pc->lengthComponentIdent == 0) {
+ if (pc->lengthComponentIdent == 0)
+ {
p = to;
*p++ = '/';
}
@@ -61,17 +64,16 @@ static void udf_pc_to_char(char *from, int fromlen, char *to)
/* that would be . - just ignore */
break;
case 5:
- memcpy(p+len, pc->componentIdent,
- pc->lengthComponentIdent);
+ memcpy(p, pc->componentIdent, pc->lengthComponentIdent);
p += pc->lengthComponentIdent;
*p++ = '/';
}
elen += sizeof(struct PathComponent) + pc->lengthComponentIdent;
}
-
- if (p>to+1) {
+ if (p > to+1)
p[-1] = '\0';
- }
+ else
+ p[0] = '\0';
}
static int udf_symlink_filler(struct dentry * dentry, struct page *page)
@@ -79,20 +81,20 @@ static int udf_symlink_filler(struct dentry * dentry, struct page *page)
struct inode *inode = dentry->d_inode;
struct buffer_head *bh = NULL;
char *symlink;
- int err;
-
- char *p = (char*)kmap(page);
+ int err = -EIO;
+ char *p = (char *)kmap(page);
- err = -EIO;
- if (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_IN_ICB) {
- bh = udf_tread(inode->i_sb, inode->i_ino,
- inode->i_sb->s_blocksize);
+ if (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_IN_ICB)
+ {
+ bh = udf_tread(inode->i_sb, inode->i_ino, inode->i_sb->s_blocksize);
if (!bh)
goto out;
symlink = bh->b_data + udf_file_entry_alloc_offset(inode);
- } else {
+ }
+ else
+ {
bh = bread(inode->i_dev, udf_block_map(inode, 0),
inode->i_sb->s_blocksize);
@@ -104,6 +106,7 @@ static int udf_symlink_filler(struct dentry * dentry, struct page *page)
udf_pc_to_char(symlink, inode->i_size, p);
udf_release_data(bh);
+
SetPageUptodate(page);
kunmap(page);
UnlockPage(page);
@@ -112,14 +115,29 @@ out:
SetPageError(page);
kunmap(page);
UnlockPage(page);
- return -EIO;
+ return err;
}
/*
* symlinks can't do much...
*/
struct inode_operations udf_symlink_inode_operations = {
- readlink: page_readlink,
- follow_link: page_follow_link,
- readpage: udf_symlink_filler,
+ NULL, /* no file-operations */
+ NULL, /* create */
+ NULL, /* lookup */
+ NULL, /* link */
+ NULL, /* unlink */
+ NULL, /* symlink */
+ NULL, /* mkdir */
+ NULL, /* rmdir */
+ NULL, /* mknod */
+ NULL, /* rename */
+ page_readlink, /* readlink */
+ page_follow_link, /* follow_link */
+ NULL, /* get_block */
+ udf_symlink_filler, /* readpage */
+ NULL, /* writepage */
+ NULL, /* truncate */
+ NULL, /* permission */
+ NULL /* revalidate */
};
diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
index 1bf6e4cee..4054da721 100644
--- a/fs/udf/truncate.c
+++ b/fs/udf/truncate.c
@@ -15,7 +15,7 @@
* ftp://prep.ai.mit.edu/pub/gnu/GPL
* Each contributing author retains all rights to their own work.
*
- * (C) 1999 Ben Fennema
+ * (C) 1999-2000 Ben Fennema
* (C) 1999 Stelias Computing Inc
*
* HISTORY
@@ -33,32 +33,29 @@
#include "udf_sb.h"
static void extent_trunc(struct inode * inode, lb_addr bloc, int *extoffset,
- lb_addr eloc, Uint32 elen, struct buffer_head **bh, Uint32 offset)
+ lb_addr eloc, Uint8 etype, Uint32 elen, struct buffer_head **bh, Uint32 offset)
{
lb_addr neloc = { 0, 0 };
- int nelen = 0;
+ int nelen = 0;
int blocks = inode->i_sb->s_blocksize / 512;
int last_block = (elen + inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits;
if (offset)
{
- nelen = ((offset - 1) << inode->i_sb->s_blocksize_bits) +
- (inode->i_size & (inode->i_sb->s_blocksize - 1));
+ nelen = (etype << 30) |
+ (((offset - 1) << inode->i_sb->s_blocksize_bits) +
+ (inode->i_size & (inode->i_sb->s_blocksize - 1)));
neloc = eloc;
}
-
- inode->i_blocks -= (blocks * (last_block - offset));
+ if (etype == EXTENT_RECORDED_ALLOCATED)
+ inode->i_blocks -= (blocks * (last_block - offset));
udf_write_aext(inode, bloc, extoffset, neloc, nelen, bh, 1);
- if (!memcmp(&UDF_I_EXT0LOC(inode), &eloc, sizeof(lb_addr)))
- {
- UDF_I_EXT0LOC(inode) = neloc;
- UDF_I_EXT0LEN(inode) = nelen;
- }
mark_inode_dirty(inode);
- udf_free_blocks(inode, eloc, offset, last_block - offset);
+ if (etype != EXTENT_NOT_RECORDED_NOT_ALLOCATED)
+ udf_free_blocks(inode, eloc, offset, last_block - offset);
}
-static void trunc(struct inode * inode)
+void udf_trunc(struct inode * inode)
{
lb_addr bloc, eloc, neloc = { 0, 0 };
Uint32 extoffset, elen, offset, nelen = 0, lelen = 0, lenalloc;
@@ -77,7 +74,7 @@ static void trunc(struct inode * inode)
if ((etype = inode_bmap(inode, first_block, &bloc, &extoffset, &eloc, &elen, &offset, &bh)) != -1)
{
extoffset -= adsize;
- extent_trunc(inode, bloc, &extoffset, eloc, elen, &bh, offset);
+ extent_trunc(inode, bloc, &extoffset, eloc, etype, elen, &bh, offset);
if (offset)
lenalloc = extoffset;
@@ -124,10 +121,8 @@ static void trunc(struct inode * inode)
else
lelen = 1;
}
- else if (etype != EXTENT_NOT_RECORDED_NOT_ALLOCATED)
- extent_trunc(inode, bloc, &extoffset, eloc, elen, &bh, 0);
else
- udf_write_aext(inode, bloc, &extoffset, neloc, nelen, &bh, 1);
+ extent_trunc(inode, bloc, &extoffset, eloc, etype, elen, &bh, 0);
}
if (lelen)
@@ -151,8 +146,6 @@ static void trunc(struct inode * inode)
}
else if (inode->i_size)
{
- lb_addr e0loc = UDF_I_LOCATION(inode);
- Uint32 ext0offset = udf_file_entry_alloc_offset(inode);
char tetype;
if (offset)
@@ -164,8 +157,6 @@ static void trunc(struct inode * inode)
extoffset -= adsize;
elen = (EXTENT_NOT_RECORDED_NOT_ALLOCATED << 30) |
(elen + (offset << inode->i_sb->s_blocksize_bits));
- if (ext0offset == extoffset && !memcmp(&e0loc, &bloc, sizeof(lb_addr)))
- UDF_I_EXT0LEN(inode) = elen;
udf_write_aext(inode, bloc, &extoffset, eloc, elen, &bh, 0);
}
else
@@ -176,18 +167,11 @@ static void trunc(struct inode * inode)
elen = (EXTENT_RECORDED_ALLOCATED << 30) |
((elen + inode->i_sb->s_blocksize - 1) &
~(inode->i_sb->s_blocksize - 1));
- if (ext0offset == extoffset && !memcmp(&e0loc, &bloc, sizeof(lb_addr)))
- UDF_I_EXT0LEN(inode) = elen;
udf_write_aext(inode, bloc, &extoffset, eloc, elen, &bh, 1);
}
memset(&eloc, 0x00, sizeof(lb_addr));
elen = (EXTENT_NOT_RECORDED_NOT_ALLOCATED << 30) |
(offset << inode->i_sb->s_blocksize_bits);
- if (ext0offset == extoffset && !memcmp(&e0loc, &bloc, sizeof(lb_addr)))
- {
- UDF_I_EXT0LOC(inode) = eloc;
- UDF_I_EXT0LEN(inode) = elen;
- }
udf_add_aext(inode, &bloc, &extoffset, eloc, elen, &bh, 1);
}
}
@@ -204,12 +188,7 @@ void udf_truncate(struct inode * inode)
if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
return;
- if (!UDF_I_EXT0OFFS(inode))
- {
- udf_discard_prealloc(inode);
-
- trunc(inode);
- }
+ udf_trunc(inode);
inode->i_mtime = inode->i_ctime = CURRENT_TIME;
mark_inode_dirty(inode);
@@ -223,6 +202,8 @@ void udf_truncate_adinicb(struct inode * inode)
if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
return;
+ UDF_I_LENALLOC(inode) = inode->i_size;
+
inode->i_mtime = inode->i_ctime = CURRENT_TIME;
mark_inode_dirty(inode);
}
diff --git a/fs/udf/udf_i.h b/fs/udf/udf_i.h
index 8b9038296..4d1f64c85 100644
--- a/fs/udf/udf_i.h
+++ b/fs/udf/udf_i.h
@@ -1,11 +1,8 @@
#ifndef __LINUX_UDF_I_H
#define __LINUX_UDF_I_H
-#define UDF_I(X) (&((X)->u.udf_i))
+#define UDF_I(X) (&((X)->u.udf_i))
-#define UDF_I_EXT0LOC(X) ( UDF_I(X)->i_ext0Location )
-#define UDF_I_EXT0LEN(X) ( UDF_I(X)->i_ext0Length )
-#define UDF_I_EXT0OFFS(X) ( UDF_I(X)->i_ext0Offset )
#define UDF_I_LOCATION(X) ( UDF_I(X)->i_location )
#define UDF_I_LENEATTR(X) ( UDF_I(X)->i_lenEAttr )
#define UDF_I_LENALLOC(X) ( UDF_I(X)->i_lenAlloc )
@@ -13,8 +10,6 @@
#define UDF_I_ALLOCTYPE(X) ( UDF_I(X)->i_alloc_type )
#define UDF_I_EXTENDED_FE(X)( UDF_I(X)->i_extended_fe )
#define UDF_I_STRAT4096(X) ( UDF_I(X)->i_strat_4096 )
-#define UDF_I_PREALLOC_COUNT(X) ( UDF_I(X)->i_prealloc_count )
-#define UDF_I_PREALLOC_BLOCK(X) ( UDF_I(X)->i_prealloc_block )
#define UDF_I_NEXT_ALLOC_BLOCK(X) ( UDF_I(X)->i_next_alloc_block )
#define UDF_I_NEXT_ALLOC_GOAL(X) ( UDF_I(X)->i_next_alloc_goal )
#define UDF_I_UATIME(X) ( UDF_I(X)->i_uatime )
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index 310ba4aef..5fab514bc 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -24,6 +24,7 @@
{\
UDF_SB_NUMPARTS(X) = Y;\
UDF_SB_PARTMAPS(X) = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
+ memset(UDF_SB_PARTMAPS(X), 0x00, sizeof(struct udf_part_map) * Y);\
}
#define IS_STRICT(X) ( UDF_SB(X)->s_flags & UDF_FLAG_STRICT )
@@ -43,9 +44,7 @@
#define UDF_SB_RECORDTIME(X) ( UDF_SB(X)->s_recordtime )
#define UDF_SB_VOLIDENT(X) ( UDF_SB(X)->s_volident )
#define UDF_SB_PARTMAPS(X) ( UDF_SB(X)->s_partmaps )
-#define UDF_SB_LOCATION(X) ( UDF_SB(X)->s_location )
#define UDF_SB_SERIALNUM(X) ( UDF_SB(X)->s_serialnum )
-#define UDF_SB_CHARSET(X) ( UDF_SB(X)->s_nls_iocharset )
#define UDF_SB_VAT(X) ( UDF_SB(X)->s_vat )
#define UDF_SB_BLOCK_BITMAP_NUMBER(X,Y) ( UDF_SB(X)->s_block_bitmap_number[Y] )
@@ -59,5 +58,6 @@
#define UDF_SB_PARTNUM(X,Y) ( UDF_SB_PARTMAPS(X)[Y].s_partition_num )
#define UDF_SB_TYPESPAR(X,Y) ( UDF_SB_PARTMAPS(X)[Y].s_type_specific.s_sparing )
#define UDF_SB_TYPEVIRT(X,Y) ( UDF_SB_PARTMAPS(X)[Y].s_type_specific.s_virtual )
+#define UDF_SB_PARTFUNC(X,Y) ( UDF_SB_PARTMAPS(X)[Y].s_partition_func )
#endif /* __LINUX_UDF_SB_H */
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index f50ca705c..171cd0d75 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -1,7 +1,7 @@
#ifndef __UDF_DECL_H
#define __UDF_DECL_H
-#define UDF_VERSION_NOTICE "v0.8.9.4"
+#define UDF_VERSION_NOTICE "v0.9.0"
#include <linux/udf_167.h>
#include <linux/udf_udf.h>
@@ -39,6 +39,12 @@
sizeof(struct ExtendedFileEntry) :\
sizeof(struct FileEntry)) + UDF_I_LENEATTR(inode))
+#define udf_ext0_offset(inode)\
+ (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_IN_ICB ?\
+ udf_file_entry_alloc_offset(inode) : 0)
+
+#define udf_get_lb_pblock(sb,loc,offset) udf_get_pblock((sb), (loc).logicalBlockNum, (loc).partitionReferenceNum, (offset))
+
#else
#include <sys/types.h>
@@ -128,9 +134,12 @@ extern int udf_ioctl(struct inode *, struct file *, unsigned int, unsigned long)
/* inode.c */
extern struct inode *udf_iget(struct super_block *, lb_addr);
extern int udf_sync_inode(struct inode *);
-extern struct buffer_head * udf_expand_adinicb(struct inode *, int *, int, int *);
+extern void udf_expand_file_adinicb(struct file *, int, int *);
+extern struct buffer_head * udf_expand_dir_adinicb(struct inode *, int *, int *);
extern struct buffer_head * udf_getblk(struct inode *, long, int, int *);
extern int udf_get_block(struct inode *, long, struct buffer_head *, int);
+extern int udf_readpage_adinicb (struct dentry *, struct page *);
+extern int udf_writepage_adinicb (struct dentry *, struct page *);
extern struct buffer_head * udf_bread(struct inode *, int, int, int *);
extern void udf_read_inode(struct inode *);
extern void udf_put_inode(struct inode *);
@@ -163,7 +172,10 @@ extern unsigned int udf_get_last_block(struct super_block *, int *);
/* partition.c */
extern Uint32 udf_get_pblock(struct super_block *, Uint32, Uint16, Uint32);
-extern Uint32 udf_get_lb_pblock(struct super_block *, lb_addr, Uint32);
+extern Uint32 udf_get_pblock_virt15(struct super_block *, Uint32, Uint16, Uint32);
+extern Uint32 udf_get_pblock_virt20(struct super_block *, Uint32, Uint16, Uint32);
+extern Uint32 udf_get_pblock_spar15(struct super_block *, Uint32, Uint16, Uint32);
+extern void udf_fill_spartable(struct super_block *, struct udf_sparing_data *, int);
/* unicode.c */
extern int udf_get_filename(Uint8 *, Uint8 *, int);
@@ -173,6 +185,7 @@ extern void udf_free_inode(struct inode *);
extern struct inode * udf_new_inode (const struct inode *, int, int *);
/* truncate.c */
+extern void udf_trunc(struct inode *);
extern void udf_truncate(struct inode *);
extern void udf_truncate_adinicb(struct inode *);
@@ -181,6 +194,7 @@ extern void udf_free_blocks(const struct inode *, lb_addr, Uint32, Uint32);
extern int udf_alloc_blocks(const struct inode *, Uint16, Uint32, Uint32);
extern int udf_new_block(const struct inode *, Uint16, Uint32, int *);
extern int udf_sync_file(struct file *, struct dentry *);
+extern int udf_sync_file_adinicb(struct file *, struct dentry *);
/* directory.c */
extern Uint8 * udf_filead_read(struct inode *, Uint8 *, Uint8, lb_addr, int *, int *, struct buffer_head **, int *);
@@ -207,8 +221,6 @@ extern int udf_UTF8toCS0(dstring *, struct ustr *, int);
extern Uint16 udf_crc(Uint8 *, Uint32, Uint16);
/* misc.c */
-extern uid_t udf_convert_uid(int);
-extern gid_t udf_convert_gid(int);
extern Uint32 udf64_low32(Uint64);
extern Uint32 udf64_high32(Uint64);
extern void udf_update_tag(char *, int);
diff --git a/fs/udf/udftime.c b/fs/udf/udftime.c
index 3fa925f6b..b2a9e3462 100644
--- a/fs/udf/udftime.c
+++ b/fs/udf/udftime.c
@@ -139,7 +139,7 @@ udf_time_to_stamp(timestamp *dest, time_t tv_sec, long tv_usec)
gettimeofday(&tv, &sys_tz);
#endif
- offset = (-sys_tz.tz_minuteswest + (sys_tz.tz_dsttime ? 60 : 0));
+ offset = (-sys_tz.tz_minuteswest);
if (!dest)
return NULL;
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index 6cf63164d..29801728d 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -38,24 +38,24 @@ int udf_ustr_to_dchars(Uint8 *dest, const struct ustr *src, int strlen)
{
if ( (!dest) || (!src) || (!strlen) || (src->u_len > strlen) )
return 0;
- memcpy(dest+1, src->u_name, src->u_len-1);
+ memcpy(dest+1, src->u_name, src->u_len);
dest[0] = src->u_cmpID;
- return src->u_len;
+ return src->u_len + 1;
}
int udf_ustr_to_char(Uint8 *dest, const struct ustr *src, int strlen)
{
if ( (!dest) || (!src) || (!strlen) || (src->u_len >= strlen) )
return 0;
- memcpy(dest, src->u_name, src->u_len-1);
- return src->u_len - 1;
+ memcpy(dest, src->u_name, src->u_len);
+ return src->u_len;
}
int udf_ustr_to_dstring(dstring *dest, const struct ustr *src, int dlength)
{
if ( udf_ustr_to_dchars(dest, src, dlength-1) )
{
- dest[dlength-1] = src->u_len;
+ dest[dlength-1] = src->u_len + 1;
return dlength;
}
else
@@ -69,8 +69,8 @@ int udf_dchars_to_ustr(struct ustr *dest, const Uint8 *src, int strlen)
memset(dest, 0, sizeof(struct ustr));
memcpy(dest->u_name, src+1, strlen-1);
dest->u_cmpID = src[0];
- dest->u_len = strlen;
- return strlen;
+ dest->u_len = strlen-1;
+ return strlen-1;
}
int udf_char_to_ustr(struct ustr *dest, const Uint8 *src, int strlen)
@@ -80,8 +80,8 @@ int udf_char_to_ustr(struct ustr *dest, const Uint8 *src, int strlen)
memset(dest, 0, sizeof(struct ustr));
memcpy(dest->u_name, src, strlen);
dest->u_cmpID = 0x08;
- dest->u_len = strlen + 1;
- return strlen + 1;
+ dest->u_len = strlen;
+ return strlen;
}
@@ -182,38 +182,21 @@ int udf_CS0toUTF8(struct ustr *utf_o, struct ustr *ocu_i)
/* Expand OSTA compressed Unicode to Unicode */
c = ocu[i++];
if (cmp_id == 16)
- {
c = (c << 8) | ocu[i++];
-#ifdef __KERNEL__
- if (c & 0xFF00)
- udf_debug("cmd_id == 16 (0x%2x%2x)\n",
- ((c >> 8) & 0xFF), (c & 0xFF));
-#endif
- }
/* Compress Unicode to UTF-8 */
if (c < 0x80U)
utf_o->u_name[utf_o->u_len++] = (Uint8)c;
- else if (c < 0x800U) {
+ else if (c < 0x800U)
+ {
utf_o->u_name[utf_o->u_len++] = (Uint8)(0xc0 | (c >> 6));
utf_o->u_name[utf_o->u_len++] = (Uint8)(0x80 | (c & 0x3f));
-#ifdef __KERNEL__
- udf_debug("(0x%2x%2x) -> (%2x) (%2x)\n",
- ((c >> 8) & 0xFF), (c & 0xFF),
- utf_o->u_name[utf_o->u_len-2],
- utf_o->u_name[utf_o->u_len-1]);
-#endif
- } else {
+ }
+ else
+ {
utf_o->u_name[utf_o->u_len++] = (Uint8)(0xe0 | (c >> 12));
utf_o->u_name[utf_o->u_len++] = (Uint8)(0x80 | ((c >> 6) & 0x3f));
utf_o->u_name[utf_o->u_len++] = (Uint8)(0x80 | (c & 0x3f));
-#ifdef __KERNEL__
- udf_debug("(0x%2x%2x) -> (%2x) (%2x) (%2x)\n",
- ((c >> 8) & 0xFF), (c & 0xFF),
- utf_o->u_name[utf_o->u_len-3],
- utf_o->u_name[utf_o->u_len-2],
- utf_o->u_name[utf_o->u_len-1]);
-#endif
}
}
utf_o->u_cmpID=8;
@@ -259,34 +242,49 @@ int udf_UTF8toCS0(dstring *ocu, struct ustr *utf, int length)
try_again:
utf_char = 0U;
utf_cnt = 0U;
- for (i = 0U; i < utf->u_len; i++) {
- c = (unsigned)utf->u_name[i];
+ for (i = 0U; i < utf->u_len; i++)
+ {
+ c = (Uint8)utf->u_name[i];
/* Complete a multi-byte UTF-8 character */
- if (utf_cnt) {
+ if (utf_cnt)
+ {
utf_char = (utf_char << 6) | (c & 0x3fU);
if (--utf_cnt)
continue;
- } else {
+ }
+ else
+ {
/* Check for a multi-byte UTF-8 character */
- if (c & 0x80U) {
+ if (c & 0x80U)
+ {
/* Start a multi-byte UTF-8 character */
- if ((c & 0xe0U) == 0xc0U) {
+ if ((c & 0xe0U) == 0xc0U)
+ {
utf_char = c & 0x1fU;
utf_cnt = 1;
- } else if ((c & 0xf0U) == 0xe0U) {
+ }
+ else if ((c & 0xf0U) == 0xe0U)
+ {
utf_char = c & 0x0fU;
utf_cnt = 2;
- } else if ((c & 0xf8U) == 0xf0U) {
+ }
+ else if ((c & 0xf8U) == 0xf0U)
+ {
utf_char = c & 0x07U;
utf_cnt = 3;
- } else if ((c & 0xfcU) == 0xf8U) {
+ }
+ else if ((c & 0xfcU) == 0xf8U)
+ {
utf_char = c & 0x03U;
utf_cnt = 4;
- } else if ((c & 0xfeU) == 0xfcU) {
+ }
+ else if ((c & 0xfeU) == 0xfcU)
+ {
utf_char = c & 0x01U;
utf_cnt = 5;
- } else
+ }
+ else
goto error_out;
continue;
} else
@@ -295,8 +293,10 @@ try_again:
}
/* Choose no compression if necessary */
- if (utf_char > max_val) {
- if ( 0xffU == max_val ) {
+ if (utf_char > max_val)
+ {
+ if ( 0xffU == max_val )
+ {
max_val = 0xffffU;
ocu[0] = (Uint8)0x10U;
goto try_again;
@@ -305,11 +305,15 @@ try_again:
}
if (max_val == 0xffffU)
+ {
ocu[++u_len] = (Uint8)(utf_char >> 8);
+ }
ocu[++u_len] = (Uint8)(utf_char & 0xffU);
}
- if (utf_cnt) {
+
+ if (utf_cnt)
+ {
error_out:
#ifdef __KERNEL__
printk(KERN_ERR "udf: bad UTF-8 character\n");
@@ -317,8 +321,8 @@ error_out:
return 0;
}
- ocu[length - 1] = (Uint8)u_len;
- return u_len;
+ ocu[length - 1] = (Uint8)u_len + 1;
+ return u_len + 1;
}
#ifdef __KERNEL__