Commit graph

148 commits

Author SHA1 Message Date
Tomas Janousek
e8183c2452 udf: Fix regression in UDF anchor block detection
In some cases it could happen that some block passed test in
udf_check_anchor_block() even though udf_read_tagged() refused to read it later
(e.g. because checksum was not correct).  This patch makes
udf_check_anchor_block() use udf_read_tagged() so that the checking is
stricter.

This fixes the regression (certain disks unmountable) caused by commit
423cf6dc04.

Signed-off-by: Tomas Janousek <tomi@nomi.cz>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-06-24 11:38:03 +02:00
Paul Collins
e4f3ec0634 udf: restore UDFFS_DEBUG to being undefined by default
Commit 706047a797, "udf: Fix compilation
warnings when UDF debug is on" inadvertently (I assume) enabled
debugging messages by default for UDF.  This patch disables them again.

Signed-off-by: Paul Collins <paul@ondioline.org>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-06-16 14:24:36 +02:00
Linus Torvalds
0f1bce41fe 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: Fix memory corruption when fs mounted with noadinicb option
  udf: Make udf exportable
  udf: fs/udf/partition.c:udf_get_pblock() mustn't be inline
2008-05-08 10:48:03 -07:00
Jan Kara
9afadc4b1f udf: Fix memory corruption when fs mounted with noadinicb option
When UDF filesystem is mounted with noadinicb mount option, it
happens that we extend an empty directory with a block. A code in
udf_add_entry() didn't count with this possibility and used
uninitialized data leading to memory and filesystem corruption.
Add a check whether file already has some extents before operating
on them.

Signed-off-by: Jan Kara <jack@suse.cz>
2008-05-07 09:49:52 +02:00
Rasmus Rohde
221e583a73 udf: Make udf exportable
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Rasmus Rohde <rohde@duff.dk>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-05-07 09:48:23 +02:00
Harvey Harrison
8e24eea728 fs: replace remaining __FUNCTION__ occurrences
__FUNCTION__ is gcc-specific, use __func__

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-04-30 08:29:54 -07:00
Adrian Bunk
22ba0317c8 udf: fs/udf/partition.c:udf_get_pblock() mustn't be inline
This patch fixes the following build error with UML and gcc 4.3:

<--  snip  -->

...
  CC      fs/udf/partition.o
/home/bunk/linux/kernel-2.6/git/linux-2.6/fs/udf/partition.c: In function ‘udf_get_pblock_virt15’:
/home/bunk/linux/kernel-2.6/git/linux-2.6/fs/udf/partition.c:32: sorry, unimplemented: inlining failed in call to ‘udf_get_pblock’: function body not available
/home/bunk/linux/kernel-2.6/git/linux-2.6/fs/udf/partition.c:102: sorry, unimplemented: called from here
make[3]: *** [fs/udf/partition.o] Error 1

<--  snip  -->

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-28 18:44:26 +02:00
Harvey Harrison
78e917d59c udf: fix sparse warning in namei.c
Let's use bsize instead.
fs/udf/namei.c:960:12: warning: symbol 'elen' shadows an earlier one
fs/udf/namei.c:937:15: originally declared here

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Cc: Jan Kara <jack@ucw.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-04-28 08:58:46 -07:00
Bob Copeland
f845fced91 udf: use crc_itu_t from lib instead of udf_crc
As pointed out by Sergey Vlasov, UDF implements its own version of
the CRC ITU-T V.41.  Convert it to use the one in the library.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
Cc: Sergey Vlasov <vsu@altlinux.ru>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:29:56 +02:00
Sebastian Manciulea
706047a797 udf: Fix compilation warnings when UDF debug is on
Fix two compilation warnings (and actual bugs in message formatting)
when UDF debugging is turned on.

Signed-off-by: Sebastian Manciulea <manciuleas@yahoo.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:29:48 +02:00
Sebastian Manciulea
47c9358a01 udf: Fix bug in VAT mapping code
Fix mapping of blocks using VAT when it is stored in an inode.
UDF_I(inode)->i_data already points to the beginning of VAT header so there's
no need to add udf_ext0_offset(inode).

Signed-off-by: Sebastian Manciulea <manciuleas@yahoo.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:29:43 +02:00
Jan Kara
bfb257a598 udf: Add read-only support for 2.50 UDF media
This patch implements parsing of metadata partitions and reading of Metadata
File thus allowing to read UDF 2.50 media. Error resilience is implemented
through accessing the Metadata Mirror File in case the data the Metadata File
cannot be read. The patch is based on the original patch by Sebastian Manciulea
<manciuleas@yahoo.com> and Mircea Fedoreanu <mirceaf_spl@yahoo.com>.

Signed-off-by: Sebastian Manciulea <manciuleas@yahoo.com>
Signed-off-by: Mircea Fedoreanu <mirceaf_spl@yahoo.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:29:36 +02:00
Sebastian Manciulea
f4bcbbd92e udf: Fix handling of multisession media
According to OSTA UDF specification, only anchor blocks and primary volume
descriptors are placed on media relative to the last session. All other block
numbers are absolute (in the partition or the whole media). This seems to be
confirmed by multisession media created by other systems.

Signed-off-by: Sebastian Manciulea <manciuleas@yahoo.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:28:33 +02:00
Jan Kara
96200be307 udf: Mount filesystem read-only if it has pseudooverwrite partition
As we don't properly support writing to pseudooverwrite partition (we should
add entries to VAT and relocate blocks instead of just writing them), mount
filesystems with such partition as read-only.

Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:28:14 +02:00
Jan Kara
fa5e081563 udf: Handle VAT packed inside inode properly
We didn't handle VAT packed inside the inode - we tried to call udf_block_map()
on such file which lead to strange results at best. Add proper handling of
packed VAT as we do it with other packed files.

Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:25:35 +02:00
Jan Kara
742e1795e2 udf: Allow loading of VAT inode
UDF media with VAT could have never worked because udf_fill_inode() didn't
know about case FILE_TYPE_VAT20. Fix this.

Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:23:41 +02:00
Jan Kara
c82a127505 udf: Fix detection of VAT version
We incorrectly (way to strictly) checked version of VAT on loading and thus
refuse to mount correct media.  There are just two format versions - below 2.0
and above 2.0 and we understand both. So update the version check accordingly.

Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:23:39 +02:00
Jan Kara
4f7874c868 udf: Silence warning about accesses beyond end of device
Some of the computed positions of anchor block could be beyond the end of
device. Skip reading such blocks.

Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:23:17 +02:00
Jan Kara
5fb28aa25a udf: Improve anchor block detection
Add <last block>+1 and <last block>-1 to a list of blocks which can be the
real last recorded block on a UDF media. Sebastian Manciulea
<manciuleas@yahoo.com> claims this helps some drive + media combinations
he is able to test.

Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:23:13 +02:00
Jan Kara
423cf6dc04 udf: Cleanup anchor block detection.
UDF anchor block detection is complicated by several things - there are several
places where the anchor point can be, some of them relative to the last
recorded block which some devices report wrongly. Moreover some devices on some
media seem to have 7 spare blocks sectors for every 32 blocks (at least as far
as I understand the old code) so we have to count also with that possibility.

This patch splits anchor block detection into several functions so that it is
clearer what we actually try to do. We fix several bugs of the type "for such
and such media, we fail to check block blah" as a result of the cleanup.

Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:23:10 +02:00
Jan Kara
38b74a53e5 udf: Move processing of virtual partitions
This patch move processing of UDF virtual partitions close to the place
where other partition types are processed. As a result we now also
properly fill in partition access type.

Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:23:04 +02:00
Jan Kara
3fb38dfa0e udf: Move filling of partition descriptor info into a separate function
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:23:04 +02:00
Jan Kara
2e0838fd0c udf: Improve error recovery on mount
Report error when we fail to allocate memory for a bitmap and properly
release allocated memory and inodes for all the partitions in case of
mount failure and umount.

Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:23:04 +02:00
Jan Kara
c0eb31ed13 udf: Cleanup volume descriptor sequence processing
Cleanup processing of volume descriptor sequence so that it is more readable,
make code handle errors (e.g. media problems) better.

Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:23:04 +02:00
Pavel Emelyanov
d0db181c07 udf: fix anchor point detection
According to ECMA 167 rev.  3 (see 3/8.4.2.1), Anchor Volume Descriptor
Pointer should be recorded at two or more anchor points located at sectors
256, N, N - 256, where N - is a largest logical sector number at volume
space.

So we should always try to detect N on UDF volume before trying to find
Anchor Volume Descriptor (i.e.  calling to udf_find_anchor()).

That said, all this patch does is updates the s_last_block even if the
udf_vrs() returns positive value.

Originally written and tested by Yuri Per, ported on latest mainline by me.

Signed-off-by: Yuri Per <Yuri.Per@acronis.com>
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Cc: Max Lyadvinsky <Max.Lyadvinsky@acronis.com>
Cc: Vladimir Simonov <Vladimir.Simonov@acronis.com>
Cc: Andrew Neporada <Andrew.Neporada@acronis.com>
Cc: Kirill Korotaev <dev@openvz.org>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:23:04 +02:00
Jan Kara
b80697c14d udf: Remove declarations of arrays of size UDF_NAME_LEN (256 bytes)
There are several places in UDF where we declared temporary arrays of
UDF_NAME_LEN bytes on stack. This is not nice to stack usage so this patch
changes those places to use kmalloc() instead. Also clean up bail-out paths
in those functions when we are changing them.

Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:23:04 +02:00
Jan Kara
9bf2c6b834 udf: Remove checking of existence of filename in udf_add_entry()
We don't have to check whether a directory entry already exists in a directory
when creating a new one since we've already checked that earlier by lookup and
we are holding directory i_mutex all the time.

Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:23:03 +02:00
Jan Kara
200a3592cd udf: Mark udf_process_sequence() as noinline
Mark udf_process_sequence() as noinline since stack usage is terrible
otherwise.

Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:49 +02:00
Marcin Slusarz
165923fa45 udf: super.c reorganization
reorganize few code blocks in super.c which
were needlessly indented (and hard to read):

so change from:
rettype fun()
{
	init;
	if (sth) {
		long block of code;
	}
}

to:
rettype fun()
{
	init;
	if (!sth)
		return;
	long block of code;
}

or

from:
rettype fun2()
{
	init;
	while (sth) {
		init2();
		if (sth2) {
			long block of code;
		}
	}
}

to:
rettype fun2()
{
	init;
	while (sth) {
		init2();
		if (!sth2)
			continue;
		long block of code;
	}
}

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:45 +02:00
Marcin Slusarz
af15a298a4 udf: remove unneeded kernel_timestamp type
remove now unneeded kernel_timestamp type with conversion functions

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:42 +02:00
Marcin Slusarz
56774805d5 udf: convert udf_stamp_to_time and udf_time_to_stamp to use timestamps
* kernel_timestamp type was almost unused - only callers of udf_stamp_to_time
and udf_time_to_stamp used it, so let these functions handle endianness
internally and don't clutter code with conversions

* rename udf_stamp_to_time to udf_disk_stamp_to_time
  and udf_time_to_stamp to udf_time_to_disk_stamp

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:29 +02:00
marcin.slusarz@gmail.com
cbf5676a0e udf: convert udf_stamp_to_time to return struct timespec
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:29 +02:00
marcin.slusarz@gmail.com
c87e8e90d0 udf: create function for conversion from timestamp to timespec
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:29 +02:00
marcin.slusarz@gmail.com
f18f17b033 udf: udf_get_block, inode_bmap - remove unneeded checks
block cannot be less than 0, because it's sector_t,
so remove unneeded checks

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:29 +02:00
Marcin Slusarz
01b954a36a udf: convert udf_count_free_bitmap to use bitmap_weight
replace handwritten bits counting with bitmap_weight

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:29 +02:00
marcin.slusarz@gmail.com
d652eefb70 udf: replace udf_*_offset macros with functions
- translate udf_file_entry_alloc_offset macro into function
- translate udf_ext0_offset macro into function
- add comment about crypticly named fields in struct udf_inode_info

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:29 +02:00
marcin.slusarz@gmail.com
1ab9278570 udf: simplify __udf_read_inode
- move all brelse(ibh) after main if, because it's called
  on every path except one where ibh is null
- move variables to the most inner blocks

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:28 +02:00
marcin.slusarz@gmail.com
c2104fda5e udf: replace all adds to little endians variables with le*_add_cpu
replace all:
	little_endian_variable = cpu_to_leX(leX_to_cpu(little_endian_variable) +
	                                    expression_in_cpu_byteorder);
with:
	leX_add_cpu(&little_endian_variable, expression_in_cpu_byteorder);
sparse didn't generate any new warning with this patch

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:28 +02:00
marcin.slusarz@gmail.com
456390de46 udf: truncate: create function for updating of Allocation Ext Descriptor
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:28 +02:00
marcin.slusarz@gmail.com
9de90b76eb udf: simple cleanup of truncate.c
- remove one indentation level by little code reorganization
- convert "if (smth) BUG();" to "BUG_ON(smth);"

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:28 +02:00
marcin.slusarz@gmail.com
c8ed837d37 udf: constify crc
- constify internal crc table
- mark udf_crc "in" parameter as const

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:24 +02:00
marcin.slusarz@gmail.com
34f953ddfd udf: udf_CS0toNLS cleanup
- fix error handling - always zero output variable
- don't zero explicitely fields zeroed by memset
- mark "in" paramater as const

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:24 +02:00
Marcin Slusarz
6305a0a9d5 udf: fix udf_build_ustr
udf_build_ustr was broken:

- size == 1:
    dest->u_len = ptr[1 - 1], but at ptr[0] there's cmpID,
    so we created string with wrong length
    it should not happen, so we BUG() it
- size > 1 and size < UDF_NAME_LEN:
    we set u_len correctly, but memcpy copied one needless byte
- size == UDF_NAME_LEN - 1:
    memcpy overwrited u_len - with correct value, but...
- size >= UDF_NAME_LEN:
    we copied UDF_NAME_LEN - 1 bytes, but dest->u_name is array
    of UDF_NAME_LEN - 2 bytes, so we were overwriting u_len with
    character from input string

nobody noticed because all callers set size
to acceptable values (constants within range)

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:24 +02:00
marcin.slusarz@gmail.com
79cfe0ff5f udf: udf_CS0toUTF8 cleanup
- fix error handling - always zero output variable
- don't zero explicitely fields zeroed by memset
- mark "in" paramater as const
- remove outdated comment

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:23 +02:00
Adrian Bunk
b8145a7697 make udf_error() static
This patch makes the needlessly global udf_error() static.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:23 +02:00
Julia Lawall
8dee00bb75 fs/udf: Use DIV_ROUND_UP
The kernel.h macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /
(d)) but is perhaps more readable.

An extract of the semantic patch that makes this change is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@haskernel@
@@

#include <linux/kernel.h>

@depends on haskernel@
expression n,d;
@@

(
- (n + d - 1) / d
+ DIV_ROUND_UP(n,d)
|
- (n + (d - 1)) / d
+ DIV_ROUND_UP(n,d)
)

@depends on haskernel@
expression n,d;
@@

- DIV_ROUND_UP((n),d)
+ DIV_ROUND_UP(n,d)

@depends on haskernel@
expression n,d;
@@

- DIV_ROUND_UP(n,(d))
+ DIV_ROUND_UP(n,d)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:23 +02:00
Christoph Hellwig
15aebd2866 udf: move headers out include/linux/
There's really no reason to keep udf headers in include/linux as they're
not used by anything but fs/udf/.

This patch merges most of include/linux/udf_fs_i.h into fs/udf/udf_i.h,
include/linux/udf_fs_sb.h into fs/udf/udf_sb.h and
include/linux/udf_fs.h into fs/udf/udfdecl.h.

The only thing remaining in include/linux/ is a stub of udf_fs_i.h
defining the four user-visible udf ioctls.  It's also moved from
unifdef-y to headers-y because it can be included unconditionally now.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:23 +02:00
Christoph Hellwig
b1e321266d udf: kill useless file header comments for vfs method implementations
There's not need to document vfs method invocation rules, we have
Documentation/filesystems/vfs.txt and Documentation/filesystems/Locking
for that.  Also a lot of these comments where either plain wrong or
horrible out of date.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:23 +02:00
Christoph Hellwig
f1f73ba8e9 udf: kill udf_set_blocksize
This helper has been quite useless since sb_min_blocksize was introduced
and is misnamed while we're at it.  Just opencode the few lines in the
caller instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
2008-04-17 14:22:23 +02:00
Marcin Slusarz
cba44359d1 udf: fix udf_add_free_space
In commit 742ba02a51 (udf: create common
function for changing free space counter) by accident I reversed safety
condition which lead to null pointer dereference in case of media error and
wrong counting of free space in normal situation

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Jan Kara <jack@suse.cz>
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-13 16:21:20 -08:00