summaryrefslogtreecommitdiffstats
path: root/fs/udf/udf_sb.h
Commit message (Collapse)AuthorAgeFilesLines
* udf: Use correct partition reference number for metadataAlden Tondettar2016-05-191-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | UDF/OSTA terminology is confusing. Partition Numbers (PNs) are arbitrary 16-bit values, one for each physical partition in the volume. Partition Reference Numbers (PRNs) are indices into the the Partition Map Table and do not necessarily equal the PN of the mapped partition. The current metadata code mistakenly uses the PN instead of the PRN when mapping metadata blocks to physical/sparable blocks. Windows-created UDF 2.5 discs for some reason use large, arbitrary PNs, resulting in mount failure and KASAN read warnings in udf_read_inode(). For example, a NetBSD UDF 2.5 partition might look like this: PRN PN Type --- -- ---- 0 0 Sparable 1 0 Metadata Since PRN == PN, we are fine. But Windows could gives us: PRN PN Type --- ---- ---- 0 8192 Sparable 1 8192 Metadata So udf_read_inode() will start out by checking the partition length in sbi->s_partmaps[8192], which is obviously out of bounds. Fix this by creating a new field (s_phys_partition_ref) in struct udf_meta_data, referencing whatever physical or sparable map has the same partition number as the metadata partition. [JK: Add comment about s_phys_partition_ref, change its name] Signed-off-by: Alden Tondettar <alden.tondettar@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
* udf: Export superblock magic to userspaceJan Kara2016-04-281-3/+1
| | | | | | | | Currently UDF superblock magic doesn't appear in any userspace header files and thus userspace apps have hard time checking for this fs. Let's export the magic to userspace as with any other filesystem. Signed-off-by: Jan Kara <jack@suse.cz>
* udf: Fortify LVID loadingJan Kara2013-09-241-1/+1
| | | | | | | | | | A user has reported an oops in udf_statfs() that was caused by numOfPartitions entry in LVID structure being corrupted. Fix the problem by verifying whether numOfPartitions makes sense at least to the extent that LVID fits into a single block as it should. Reported-by: Juergen Weigert <jw@suse.com> Signed-off-by: Jan Kara <jack@suse.cz>
* udf: Remove unused s_extLength from udf_bitmapJan Kara2013-02-051-1/+0
| | | | | | | s_extLength was assigned to but the value was never really used. So just remove the field. Signed-off-by: Jan Kara <jack@suse.cz>
* udf: Make s_block_bitmap standard arrayJan Kara2013-02-051-1/+1
| | | | | | | | | | struct udf_bitmap has array of buffer pointers attached to it. The code unnecessarily used s_block_bitmap as a pointer to the array instead of the standard trick of using 0 length array in the declaration. Change that to make code more readable and actually shrink the structure by one pointer. Signed-off-by: Jan Kara <jack@suse.cz>
* udf: Fix bitmap overflow on large filesystems with small block sizeJan Kara2013-02-051-1/+1
| | | | | | | | | | | | | | For large UDF filesystems with 512-byte blocks the number of necessary bitmap blocks is larger than 2^16 so s_nr_groups in udf_bitmap overflows (the number will overflow for filesystems larger than 128 GB with 512-byte blocks). That results in ENOSPC errors despite the filesystem has plenty of free space. Fix the problem by changing s_nr_groups' type to 'int'. That is enough even for filesystems 2^32 blocks (UDF maximum) and 512-byte blocksize. Reported-and-tested-by: v10lator@myway.de Signed-off-by: Jan Kara <jack@suse.cz>
* userns: Convert the udf filesystem to use kuid/kgid where appropriateEric W. Biederman2012-09-211-2/+2
| | | | | Cc: Jan Kara <jack@suse.cz> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
* udf: propagate umode_tAl Viro2012-01-031-4/+4
| | | | | | | | note re mount options: fmask and dmask are explicitly truncated to 12bit, UDF_INVALID_MODE just needs to be guaranteed to differ from any such value. And umask is used only in &= with umode_t, so we ignore other bits anyway. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* udf: Cleanup metadata flags handlingJan Kara2011-10-311-2/+4
| | | | | | Use simple ->s_flags variable instead of u8 variable for each flag. Signed-off-by: Jan Kara <jack@suse.cz>
* udf: Skip mirror metadata FE loading when metadata FE is okNamjae Jeon2011-10-311-0/+1
| | | | | | | | | | It is not necessary to load mirror metadata FE when metadata FE is OK. So try to read it only the first time udf_get_pblock_meta25() fails to map the block from metadata FE. Signed-off-by: Ashish Sangwan <ashishsangwan2@gmail.com> Signed-off-by: Namjae Jeon <linkinjeon@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
* udf: Protect default inode credentials by rwlockJan Kara2011-01-061-0/+2
| | | | | | | | | Superblock carries credentials (uid, gid, etc.) which are used as default values in __udf_read_inode() when media does not provide these. These credentials can change during remount so we protect them by a rwlock so that each inode gets a consistent set of credentials. Signed-off-by: Jan Kara <jack@suse.cz>
* udf: Convert UDF_SB(sb)->s_flags to use bitopsJan Kara2011-01-061-4/+16
| | | | | | | Use atomic bitops to manipulate with sb flags to make manipulation safe without any locking. Signed-off-by: Jan Kara <jack@suse.cz>
* udf: Don't write integrity descriptor too oftenJan Kara2009-04-021-0/+2
| | | | | | | | | | | | | | | | We update information in logical volume integrity descriptor after each allocation (as LVID contains free space, number of directories and files on disk etc.). If the filesystem is on some phase change media, this leads to its quick degradation as such media is able to handle only 10000 overwrites or so. We solve the problem by writing new information into LVID only on umount, remount-ro and sync. This solves the problem at the price of longer media inconsistency (previously media became consistent after pdflush flushed dirty LVID buffer) but that should be acceptable. Report by and patch written in cooperation with Rich Coe <Richard.Coe@med.ge.com>. Signed-off-by: Jan Kara <jack@suse.cz>
* udf: Try anchor in block 256 firstJan Kara2009-04-021-1/+1
| | | | | | | | | | | | Anchor block can be located at several places on the medium. Two of the locations are relative to media end which is problematic to detect. Also some drives report some block as last but are not able to read it or any block nearby before it. So let's first try block 256 and if it is all fine, don't look at other possible locations of anchor blocks to avoid IO errors. This change required a larger reorganization of code but the new code is hopefully more readable and definitely shorter. Signed-off-by: Jan Kara <jack@suse.cz>
* udf: use hardware sector sizeClemens Ladisch2009-04-021-0/+1
| | | | | | | | | | | | | | | | | | | This patch makes the UDF FS driver use the hardware sector size as the default logical block size, which is required by the UDF specifications. While the previous default of 2048 bytes was correct for optical disks, it was not for hard disks or USB storage devices, and made it impossible to use such a device with the default mount options. (The Linux mkudffs tool uses a default block size of 2048 bytes even on devices with smaller hardware sectors, so this bug is unlikely to be noticed unless UDF-formatted USB storage devices are exchanged with other OSs.) To avoid regressions for people who use loopback optical disk images or who used the (sometimes wrong) defaults of mkudffs, we also try with a block size of 2048 bytes if no anchor was found with the hardware sector size. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Jan Kara <jack@suse.cz>
* udf: fix default mode and dmode options handlingMarcin Slusarz2009-04-021-0/+2
| | | | | | | | | | On x86 (and several other archs) mode_t is defined as "unsigned short" and comparing unsigned shorts to negative ints is broken (because short is promoted to int and then compared). Fix it. Reported-and-tested-by: Laurent Riffard <laurent.riffard@free.fr> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
* udf: implement mode and dmode mounting optionsMarcin Slusarz2009-04-021-0/+2
| | | | | | | | | "dmode" allows overriding permissions of directories and "mode" allows overriding permissions of files. Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com> Cc: Jan Kara <jack@suse.cz> Signed-off-by: Jan Kara <jack@suse.cz>
* udf: Add read-only support for 2.50 UDF mediaJan Kara2008-04-171-1/+15
| | | | | | | | | | | | 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>
* udf: Cleanup anchor block detection.Jan Kara2008-04-171-1/+1
| | | | | | | | | | | | | | 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>
* udf: move headers out include/linux/Christoph Hellwig2008-04-171-0/+93
| | | | | | | | | | | | | | | | 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>
* mount options: fix udfMiklos Szeredi2008-02-081-0/+2
| | | | | | | | | | Add a .show_options super operation to udf. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Acked-by: Cyrill Gorcunov <gorcunov@gmail.com> Acked-by: Jan Kara <jack@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* udf: move calculating of nr_groups into helper functionMarcin Slusarz2008-02-081-0/+2
| | | | | | | | | Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com> Cc: Ben Fennema <bfennema@falcon.csc.calpoly.edu> Acked-by: Jan Kara <jack@suse.cz> Cc: Christoph Hellwig <hch@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* udf: convert macros related to bitmaps to functionsMarcin Slusarz2008-02-081-38/+0
| | | | | | | | | | | | convert UDF_SB_ALLOC_BITMAP macro to udf_sb_alloc_bitmap function convert UDF_SB_FREE_BITMAP macro to udf_sb_free_bitmap function Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com> Cc: Ben Fennema <bfennema@falcon.csc.calpoly.edu> Acked-by: Jan Kara <jack@suse.cz> Cc: Christoph Hellwig <hch@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* udf: convert UDF_SB_ALLOC_PARTMAPS macro to udf_sb_alloc_partition_maps functionMarcin Slusarz2008-02-081-13/+0
| | | | | | | | | | | | | - convert UDF_SB_ALLOC_PARTMAPS macro to udf_sb_alloc_partition_maps function - convert kmalloc + memset to kcalloc - check if kcalloc failed (partially) Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com> Cc: Ben Fennema <bfennema@falcon.csc.calpoly.edu> Cc: Jan Kara <jack@suse.cz> Acked-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* udf: remove some ugly macrosMarcin Slusarz2008-02-081-55/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | remove macros: - UDF_SB_PARTMAPS - UDF_SB_PARTTYPE - UDF_SB_PARTROOT - UDF_SB_PARTLEN - UDF_SB_PARTVSN - UDF_SB_PARTNUM - UDF_SB_TYPESPAR - UDF_SB_TYPEVIRT - UDF_SB_PARTFUNC - UDF_SB_PARTFLAGS - UDF_SB_VOLIDENT - UDF_SB_NUMPARTS - UDF_SB_PARTITION - UDF_SB_SESSION - UDF_SB_ANCHOR - UDF_SB_LASTBLOCK - UDF_SB_LVIDBH - UDF_SB_LVID - UDF_SB_UMASK - UDF_SB_GID - UDF_SB_UID - UDF_SB_RECORDTIME - UDF_SB_SERIALNUM - UDF_SB_UDFREV - UDF_SB_FLAGS - UDF_SB_VAT - UDF_UPDATE_UDFREV - UDF_SB_FREE and open code them convert UDF_SB_LVIDIU macro to udf_sb_lvidiu function rename some struct udf_sb_info fields: - s_volident to s_volume_ident - s_lastblock to s_last_block - s_lvidbh to s_lvid_bh - s_recordtime to s_record_time - s_serialnum to s_serial_number; - s_vat to s_vat_inode; Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com> Cc: Ben Fennema <bfennema@falcon.csc.calpoly.edu> Cc: Jan Kara <jack@suse.cz> Acked-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* UDF: fix UID and GID mount option ignoranceCyrill Gorcunov2007-07-311-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | This patch fix weird behaviour of UDF mounting procedure. To get UID changed (for now) we have to type mount -t udf -o uid=some_user,uid=ignore /dev/device /mnt/moun_point and specifying two uid at once is strange a bit. So with the patch we are able to mount without additional 'uid=ignore' option. The same for GID option is done. This patch will not break current mount scheme (with two option). Btw this does fix (I hope) the following [BUG 6124] mount of UDF fs ignores UID and GID options http://bugzilla.kernel.org/show_bug.cgi?id=6124 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> Cc: Jan Kara <jack@ucw.cz> Cc: Michael <auslands-kv@gmx.de> Cc: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* UDF: coding style conversion - lindent fixupsCyrill Gorcunov2007-07-211-17/+9
| | | | | | | | | This patch fixes up sources after conversion by Lindent. Signed-off-by: Cyrill Gorcunov <gorcunov@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>
* UDF: coding style conversion - lindentCyrill Gorcunov2007-07-191-3/+3
| | | | | | | | | This patch converts UDF coding style to kernel coding style using Lindent. Signed-off-by: Cyrill Gorcunov <gorcunov@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>
* udf: use get_bh()Jan Kara2007-05-081-1/+1
| | | | | | | | | | Make UDF use get_bh() instead of directly accessing b_count and use brelse() instead of udf_release_data() which does just brelse()... Signed-off-by: Jan Kara <jack@suse.cz> Acked-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* [PATCH] udf: fix uid/gid options and add uid/gid=ignore and forget optionsPhillip Susi2006-03-081-0/+4
| | | | | | | | | | | | | | | | | | | | Fix a bug in udf where it would write uid/gid = 0 to the disk for files owned by the id given with the uid=/gid= mount options. It also adds 4 new mount options: uid/gid=forget and uid/gid=ignore. Without any options the id in core and on disk always match. Giving uid/gid=nnn specifies a default ID to be used in core when the on disk ID is -1. uid/gid=ignore forces the in core ID to allways be used no matter what the on disk ID is. uid/gid=forget forces the on disk ID to always be written out as -1. The use of these options allows you to override ownerships on a disk or disable ownwership information from being written, allowing the media to be used portably between different computers and possibly different users without permissions issues that would require root to correct. Signed-off-by: Phillip Susi <psusi@cfl.rr.com> Cc: Pekka Enberg <penberg@cs.helsinki.fi> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [PATCH] kfree cleanup: fsJesper Juhl2005-11-071-2/+1
| | | | | | | | | | This is the fs/ part of the big kfree cleanup patch. Remove pointless checks for NULL prior to calling kfree() in fs/. Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* Linux-2.6.12-rc2Linus Torvalds2005-04-161-0/+139
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!