diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-18 21:08:49 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-18 21:08:49 +0000 |
commit | de7684a309ad20c1b889d048d741cb1dd52245f7 (patch) | |
tree | efae3387e1978cdd128ff2a922b734d0e9d0180f /util-linux/volume_id/reiserfs.c | |
parent | 27dd495b98a6135554b1d839fefe436ba3c6ca71 (diff) | |
download | busybox-w32-de7684a309ad20c1b889d048d741cb1dd52245f7.tar.gz busybox-w32-de7684a309ad20c1b889d048d741cb1dd52245f7.tar.bz2 busybox-w32-de7684a309ad20c1b889d048d741cb1dd52245f7.zip |
support for mount by label (not yet tested)
Also adds findfs applet. Closes bug 1143.
Diffstat (limited to 'util-linux/volume_id/reiserfs.c')
-rw-r--r-- | util-linux/volume_id/reiserfs.c | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/util-linux/volume_id/reiserfs.c b/util-linux/volume_id/reiserfs.c new file mode 100644 index 000000000..98ecec23a --- /dev/null +++ b/util-linux/volume_id/reiserfs.c | |||
@@ -0,0 +1,105 @@ | |||
1 | /* | ||
2 | * volume_id - reads filesystem label and uuid | ||
3 | * | ||
4 | * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org> | ||
5 | * Copyright (C) 2005 Tobias Klauser <tklauser@access.unizh.ch> | ||
6 | * | ||
7 | * This library is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU Lesser General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2.1 of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * This library is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with this library; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | |||
22 | #include "volume_id_internal.h" | ||
23 | |||
24 | struct reiserfs_super_block { | ||
25 | uint32_t blocks_count; | ||
26 | uint32_t free_blocks; | ||
27 | uint32_t root_block; | ||
28 | uint32_t journal_block; | ||
29 | uint32_t journal_dev; | ||
30 | uint32_t orig_journal_size; | ||
31 | uint32_t dummy2[5]; | ||
32 | uint16_t blocksize; | ||
33 | uint16_t dummy3[3]; | ||
34 | uint8_t magic[12]; | ||
35 | uint32_t dummy4[5]; | ||
36 | uint8_t uuid[16]; | ||
37 | uint8_t label[16]; | ||
38 | } __attribute__((__packed__)); | ||
39 | |||
40 | struct reiser4_super_block { | ||
41 | uint8_t magic[16]; | ||
42 | uint16_t dummy[2]; | ||
43 | uint8_t uuid[16]; | ||
44 | uint8_t label[16]; | ||
45 | uint64_t dummy2; | ||
46 | } __attribute__((__packed__)); | ||
47 | |||
48 | #define REISERFS1_SUPERBLOCK_OFFSET 0x2000 | ||
49 | #define REISERFS_SUPERBLOCK_OFFSET 0x10000 | ||
50 | |||
51 | int volume_id_probe_reiserfs(struct volume_id *id, uint64_t off) | ||
52 | { | ||
53 | struct reiserfs_super_block *rs; | ||
54 | struct reiser4_super_block *rs4; | ||
55 | |||
56 | dbg("probing at offset 0x%llx", (unsigned long long) off); | ||
57 | |||
58 | rs = volume_id_get_buffer(id, off + REISERFS_SUPERBLOCK_OFFSET, 0x200); | ||
59 | if (rs == NULL) | ||
60 | return -1; | ||
61 | |||
62 | if (memcmp(rs->magic, "ReIsErFs", 8) == 0) { | ||
63 | strcpy(id->type_version, "3.5"); | ||
64 | goto found; | ||
65 | } | ||
66 | if (memcmp(rs->magic, "ReIsEr2Fs", 9) == 0) { | ||
67 | strcpy(id->type_version, "3.6"); | ||
68 | goto found_label; | ||
69 | } | ||
70 | if (memcmp(rs->magic, "ReIsEr3Fs", 9) == 0) { | ||
71 | strcpy(id->type_version, "JR"); | ||
72 | goto found_label; | ||
73 | } | ||
74 | |||
75 | rs4 = (struct reiser4_super_block *) rs; | ||
76 | if (memcmp(rs4->magic, "ReIsEr4", 7) == 0) { | ||
77 | strcpy(id->type_version, "4"); | ||
78 | volume_id_set_label_raw(id, rs4->label, 16); | ||
79 | volume_id_set_label_string(id, rs4->label, 16); | ||
80 | volume_id_set_uuid(id, rs4->uuid, UUID_DCE); | ||
81 | goto found; | ||
82 | } | ||
83 | |||
84 | rs = volume_id_get_buffer(id, off + REISERFS1_SUPERBLOCK_OFFSET, 0x200); | ||
85 | if (rs == NULL) | ||
86 | return -1; | ||
87 | |||
88 | if (memcmp(rs->magic, "ReIsErFs", 8) == 0) { | ||
89 | strcpy(id->type_version, "3.5"); | ||
90 | goto found; | ||
91 | } | ||
92 | |||
93 | return -1; | ||
94 | |||
95 | found_label: | ||
96 | volume_id_set_label_raw(id, rs->label, 16); | ||
97 | volume_id_set_label_string(id, rs->label, 16); | ||
98 | volume_id_set_uuid(id, rs->uuid, UUID_DCE); | ||
99 | |||
100 | found: | ||
101 | volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); | ||
102 | id->type = "reiserfs"; | ||
103 | |||
104 | return 0; | ||
105 | } | ||