summaryrefslogtreecommitdiffstats
path: root/libblkid/src/partitions/dos.c
Commit message (Collapse)AuthorAgeFilesLines
* libblkid: do not interpret NTFS as MBRKarel Zak2019-07-171-0/+7
| | | | | | | | | | | | | | | # mkntfs -Q -F /dev/sdc old version: # ./blkid -p /dev/sdc /dev/sdc: UUID="0E9E8C5F2F718479" TYPE="ntfs" USAGE="filesystem" PTTYPE="dos" new version:  # ./blkid -p /dev/sdc /dev/sdc: UUID="0E9E8C5F2F718479" TYPE="ntfs" USAGE="filesystem" Reported-by: Mike Fleetwood <mike.fleetwood@googlemail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* various: fix 'uninitialized when used' warnings [clang]Sami Kerola2019-02-181-1/+1
| | | | | | | This change fixes "warning: variable 'var' may be uninitialized when used here [-Wconditional-uninitialized]" warnings reported in various files. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libblkid:(dos) make subtypes probing more robustKarel Zak2018-02-271-7/+18
| | | | | | | | | The current code mix partitions as defined on disk with partitions from partlist (as recognized by libblkid). It seems better to follow partlist only. Reported-by: Vaclav Dolezal <vdolezal@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: replace magic number 37 with UUID_STR_LENPhilip Prindeville2017-09-051-1/+1
| | | | Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
* libblkid: ignore empty MBR on LVM deviceKarel Zak2016-08-301-0/+31
| | | | | | | | | | | | | | | It's possible to use boot sector and empty MBR on LVM physical volume to make LVM disk bootable. In this case MBR should be ignored and disk reported as LVM. Just for the record, this is ugly non-default LVM setup maintained for backward compatibility (yes, LVM guys don't like it too). Unfortunately people still use it. The proper way is to use regular partitioned disk. Reported-by: Xen <list@xenhideout.nl> Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: avoid non-empty recursion in EBRKarel Zak2016-07-121-0/+7
| | | | | | | | | | | | | | | | | | | | | | This is extension to the patch 7164a1c34d18831ac61c6744ad14ce916d389b3f. We also need to detect non-empty recursion in the EBR chain. It's possible to create standard valid logical partitions and in the last one points back to the EBR chain. In this case all offsets will be non-empty. Unfortunately, it's valid to create logical partitions that are not in the "disk order" (sorted by start offset). So link somewhere back is valid, but this link cannot points to already existing partition (otherwise we will see recursion). This patch forces libblkid to ignore duplicate logical partitions, the duplicate chain segment is interpreted as non-data segment, after 100 iterations with non-data segments it will break the loop -- no memory is allocated in this case by the loop. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1349536 References: http://seclists.org/oss-sec/2016/q3/40 Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: ignore extended partition at zero offsetKarel Zak2016-07-071-2/+12
| | | | | | | | | | | | | If the extended partition starts at zero LBA then MBR is interpreted as EBR and all is recursively parsed... result is out-of-memory. MBR --extended-partition--> EBR --> MBR --> ENB --> MBR ... Note that such PT is not possible to create by standard partitioning tools. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1349536 Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: Fix various typosSebastian Rasmussen2016-05-311-2/+2
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* libblkid: improve MBR vs. FAT + boot sector detectionKarel Zak2015-01-271-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It seems that some systems are able to produce boot sector + MBR with almost valid FAT superblock. The libblkid already checks for FAT magic string, media, correct sector and dir size, etc. -- but all this is not enough. The patch add to FAT prober also MBR detection to make sure that there is no MBR with usable first partition. All this is enabled for whole-disk devices only. first sector (and this is no FAT baby ;-) $ hexdump -C -n 512 /dev/nbd0 00000000 eb 58 90 4d 53 44 4f 53 35 2e 30 00 02 10 16 10 |.X.MSDOS5.0.....| 00000010 02 00 00 00 00 f8 00 00 3f 00 ff 00 00 00 00 00 |........?.......| 00000020 00 00 40 01 f5 27 00 00 00 00 00 00 02 00 00 00 |..@..'..........| 00000030 01 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000040 80 01 29 c5 a3 06 1a 4e 4f 20 4e 41 4d 45 20 20 |..)....NO NAME | 00000050 20 20 46 41 54 33 32 20 20 20 33 c9 8e d1 bc f4 | FAT32 3.....| 00000060 7b 8e c1 8e d9 bd 00 7c 88 56 40 88 4e 02 8a 56 |{......|.V@.N..V| 00000070 40 b4 41 bb aa 55 cd 13 72 10 81 fb 55 aa 75 0a |@.A..U..r...U.u.| 00000080 f6 c1 01 74 05 fe 46 02 eb 2d 8a 56 40 b4 08 cd |...t..F..-.V@...| 00000090 13 73 05 b9 ff ff 8a f1 66 0f b6 c6 40 66 0f b6 |.s......f...@f..| 000000a0 d1 80 e2 3f f7 e2 86 cd c0 ed 06 41 66 0f b7 c9 |...?.......Af...| 000000b0 66 f7 e1 66 89 46 f8 83 7e 16 00 75 39 83 7e 2a |f..f.F..~..u9.~*| 000000c0 00 77 33 66 8b 46 1c 66 83 c0 0c bb 00 80 b9 01 |.w3f.F.f........| 000000d0 00 e8 2c 00 e9 a8 03 a1 f8 7d 80 c4 7c 8b f0 ac |..,......}..|...| 000000e0 84 c0 74 17 3c ff 74 09 b4 0e bb 07 00 cd 10 eb |..t.<.t.........| 000000f0 ee a1 fa 7d eb e4 a1 7d 80 eb df 98 cd 16 cd 19 |...}...}........| 00000100 66 60 80 7e 02 00 0f 84 20 00 66 6a 00 66 50 06 |f`.~.... .fj.fP.| 00000110 53 66 68 10 00 01 00 b4 42 8a 56 40 8b f4 cd 13 |Sfh.....B.V@....| 00000120 66 58 66 58 66 58 66 58 eb 33 66 3b 46 f8 72 03 |fXfXfXfX.3f;F.r.| 00000130 f9 eb 2a 66 33 d2 66 0f b7 4e 18 66 f7 f1 fe c2 |..*f3.f..N.f....| 00000140 8a ca 66 8b d0 66 c1 ea 10 f7 76 1a 86 d6 8a 56 |..f..f....v....V| 00000150 40 8a e8 c0 e4 06 0a cc b8 01 02 cd 13 66 61 0f |@............fa.| 00000160 82 74 ff 81 c3 00 02 66 40 49 75 94 c3 42 4f 4f |.t.....f@Iu..BOO| 00000170 54 4d 47 52 20 20 20 20 00 00 00 00 00 00 00 00 |TMGR ........| 00000180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 000001a0 00 00 00 00 00 00 00 00 00 00 00 00 0d 0a 44 69 |..............Di| 000001b0 73 6b 20 65 72 72 6f 72 ff 0d 0a 50 72 65 00 00 |sk error...Pre..| 000001c0 01 01 0c 3f e0 ff 00 08 00 00 00 f8 3f 01 00 00 |...?........?...| 000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.| MBR: $ hexdump -C -s 446 -n $((512 - 446)) /dev/nbd0 000001be 00 00 01 01 0c 3f e0 ff 00 08 00 00 00 f8 3f 01 |.....?........?.| 000001ce 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 000001fe 55 aa |U.| Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1182831 Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: fix partitions probingKarel Zak2014-03-281-1/+1
| | | | | | | | | | | * PART_ENTRY_* stuff is optional and should not overwrite previous probing result in partitions_probe() * missing minix parental partition is not error * blkid_probe_is_vfat() usage has to be more robust Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: use new debug functionsKarel Zak2014-03-211-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* blkid: convert superblocks to new calling conventionHannes Reinecke2014-03-201-17/+23
| | | | | | | | | | | | | With the previous patch the scanning functions were modified to return a differentiated return code. To correctly abort scanning when an I/O error occurs we need to differentiate between 'error' (= -1) and 'not found' (= 1) in the probe functions. This patch updates all superblock scanning functions to the new calling convention. Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: add mbr_get_partition()Karel Zak2013-09-161-4/+3Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: use functions from pt-mbr.hKarel Zak2013-09-161-11/+11
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: rename sys_type to sys_indKarel Zak2013-09-161-7/+7
| | | | | | | This makes struct dos_partition more compatible with the current fdisk code. Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: move MBR definitions to include/pt-mbr.hKarel Zak2013-09-161-6/+5Star
|
* libblkid: move MBR partition types to include/Karel Zak2013-09-161-10/+10
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: support pseudo PARTUUID= for MBRKarel Zak2013-06-131-1/+3
| | | | | | | | | | | | # blkid /dev/sdb1 dev/sdb1: TYPE="ext2" PARTUUID="54e743a7-01" the PARTUUID is generated from MBR Id and partition number. The same method uses Linux kernel for root=PARTUUID= on systems with MBR. Note that the patch also removes 0x prefix from PTUUID. Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: set PTUUID for GPT and DOSKarel Zak2013-06-131-10/+14
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: clean up DBG()Karel Zak2013-04-081-3/+3
| | | | | | | | | - use stderr only - use BLKID_ prefix for debug masks - don't use \n in in messages and don't use printf(), but use generic blkid_debug(). Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: return disk ID/UUID by PT binary interfaceKarel Zak2013-02-191-1/+10
| | | | | | Add blkid_parttable_get_id() function. Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: [partitions] fix compiler warnings [-Wunused-parameter -Wsign-compare]Karel Zak2011-08-021-2/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: use top-level directory for libblkid rather than shlibs/blkidKarel Zak2011-06-091-0/+287
Signed-off-by: Karel Zak <kzak@redhat.com>