Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 181685 | Differences between
and this patch

Collapse All | Expand All

(-)mkinitrd-4.2.1.10.orig/grubby/grubby.c (-2 / +2 lines)
Lines 235-241 Link Here
235
struct singleEntry * findEntryByPath(struct grubConfig * cfg, 
235
struct singleEntry * findEntryByPath(struct grubConfig * cfg, 
236
				     const char * path, const char * prefix,
236
				     const char * path, const char * prefix,
237
				     int * index);
237
				     int * index);
238
static char * strndup(char * from, int len);
238
static char * strndup(char * from, size_t len);
239
static int readFile(int fd, char ** bufPtr);
239
static int readFile(int fd, char ** bufPtr);
240
static void lineInit(struct singleLine * line);
240
static void lineInit(struct singleLine * line);
241
static void lineFree(struct singleLine * line);
241
static void lineFree(struct singleLine * line);
Lines 245-251 Link Here
245
		       struct configFileInfo * cfi);
245
		       struct configFileInfo * cfi);
246
static char * getRootSpecifier(char * str);
246
static char * getRootSpecifier(char * str);
247
247
248
static char * strndup(char * from, int len) {
248
static char * strndup(char * from, size_t len) {
249
    char * to;
249
    char * to;
250
250
251
    to = malloc(len + 1);
251
    to = malloc(len + 1);
(-)mkinitrd-4.2.1.10.orig/nash/linux_fs.h (-1 / +10 lines)
Lines 80-89 Link Here
80
	unsigned char		s_oid_maxsize[2];
80
	unsigned char		s_oid_maxsize[2];
81
	unsigned char		s_oid_cursize[2];
81
	unsigned char		s_oid_cursize[2];
82
	unsigned char		s_state[2];
82
	unsigned char		s_state[2];
83
	unsigned char		s_magic[12];
83
	unsigned char		s_magic[10];
84
	unsigned char		s_dummy1[10];
85
	unsigned char		s_version[2]; /* only valid with relocated journal */
86
87
        /* only valid in 3.6.x format --mason@suse.com */
88
	unsigned char		s_dummy2[10];
89
	unsigned char		s_uuid[16];
90
	unsigned char		s_label[16];
84
};
91
};
85
#define REISERFS_SUPER_MAGIC_STRING "ReIsErFs"
92
#define REISERFS_SUPER_MAGIC_STRING "ReIsErFs"
86
#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs"
93
#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs"
94
/* also known as REISER2FS_JR_SUPER_MAGIC_STRING */
95
#define REISER3FS_SUPER_MAGIC_STRING "ReIsEr3Fs" 
87
#define REISERFS_DISK_OFFSET_IN_BYTES (64 * 1024)
96
#define REISERFS_DISK_OFFSET_IN_BYTES (64 * 1024)
88
/* the spot for the super in versions 3.5 - 3.5.10 (inclusive) */
97
/* the spot for the super in versions 3.5 - 3.5.10 (inclusive) */
89
#define REISERFS_OLD_DISK_OFFSET_IN_BYTES (8 * 1024)
98
#define REISERFS_OLD_DISK_OFFSET_IN_BYTES (8 * 1024)
(-)mkinitrd-4.2.1.10.orig/nash/mount_by_label.c (-23 / +87 lines)
Lines 37-75 Link Here
37
	int major, minor;
37
	int major, minor;
38
} *uuidCache = NULL;
38
} *uuidCache = NULL;
39
39
40
/* for now, only ext2, ext3 and xfs are supported */
40
typedef int (*GetLabelUuidProc)(int fd, char **label, char *uuid);
41
static int
42
get_label_uuid(const char *device, char **label, char *uuid) {
43
41
44
	/* start with ext2/3 and xfs tests, taken from mount_guess_fstype */
42
static int get_label_uuid_ext2(int fd, char **label, char *uuid);
45
	/* should merge these later */
43
static int get_label_uuid_xfs(int fd, char **label, char *uuid);
46
	int fd;
44
static int get_label_uuid_reiserfs(int fd, char **label, char *uuid);
47
	int rv = 1;
45
48
	size_t namesize;
46
/* for now, only ext2, ext3, reiserfs and xfs are supported */
47
static const 
48
GetLabelUuidProc get_label_uuid_proc_table[] =
49
{
50
	get_label_uuid_ext2,
51
	get_label_uuid_reiserfs,
52
	get_label_uuid_xfs,
53
	NULL
54
};
55
56
static int 
57
get_label_uuid_ext2(int fd, char **label, char *uuid)
58
{
49
	struct ext2_super_block e2sb;
59
	struct ext2_super_block e2sb;
50
	struct xfs_super_block xfsb;
60
	if ( ( lseek(fd, 1024, SEEK_SET) == 1024 )
51
61
			&& read(fd, (char *) &e2sb, sizeof(e2sb)) == sizeof(e2sb)
52
	fd = open(device, O_RDONLY);
62
			&& (ext2magic(e2sb) == EXT2_SUPER_MAGIC)) {
53
	if (fd < 0)
63
		size_t namesize;
54
		return rv;
55
56
	if (lseek(fd, 1024, SEEK_SET) == 1024
57
	    && read(fd, (char *) &e2sb, sizeof(e2sb)) == sizeof(e2sb)
58
	    && (ext2magic(e2sb) == EXT2_SUPER_MAGIC)) {
59
		memcpy(uuid, e2sb.s_uuid, sizeof(e2sb.s_uuid));
64
		memcpy(uuid, e2sb.s_uuid, sizeof(e2sb.s_uuid));
60
		namesize = sizeof(e2sb.s_volume_name);
65
		namesize = sizeof(e2sb.s_volume_name);
61
		if ((*label = calloc(namesize + 1, 1)) != NULL)
66
		if ((*label = calloc(namesize + 1, 1)) != NULL)
62
			memcpy(*label, e2sb.s_volume_name, namesize);
67
			memcpy(*label, e2sb.s_volume_name, namesize);
63
		rv = 0;
68
		return 0;
64
	}
69
	}
65
	else if (lseek(fd, 0, SEEK_SET) == 0
70
	return 1;
66
	    && read(fd, (char *) &xfsb, sizeof(xfsb)) == sizeof(xfsb)
71
}
67
	    && (strncmp(xfsb.s_magic, XFS_SUPER_MAGIC, 4) == 0)) {
72
73
static int 
74
get_label_uuid_xfs(int fd, char **label, char *uuid)
75
{
76
	struct xfs_super_block xfsb;
77
	if ( (lseek(fd, 0, SEEK_SET) == 0)
78
			&& (read(fd, (char *) &xfsb, sizeof(xfsb)) == sizeof(xfsb) )
79
			&& (strncmp((const char*)xfsb.s_magic, XFS_SUPER_MAGIC, 4) == 0) ) {
80
		size_t namesize;
68
		memcpy(uuid, xfsb.s_uuid, sizeof(xfsb.s_uuid));
81
		memcpy(uuid, xfsb.s_uuid, sizeof(xfsb.s_uuid));
69
		namesize = sizeof(xfsb.s_fname);
82
		namesize = sizeof(xfsb.s_fname);
70
		if ((*label = calloc(namesize + 1, 1)) != NULL)
83
		if ((*label = calloc(namesize + 1, 1)) != NULL)
71
			memcpy(*label, xfsb.s_fname, namesize);
84
			memcpy(*label, xfsb.s_fname, namesize);
72
		rv = 0;
85
		return 0;
86
	}
87
	return 1;
88
}
89
90
static inline int reiserfs_magic_version(const char *magic)
91
{
92
	int rc = 0;
93
	if ( !strncmp(magic, REISERFS_SUPER_MAGIC_STRING, strlen(REISERFS_SUPER_MAGIC_STRING)) )
94
		rc = 1;
95
	if ( !strncmp(magic, REISER2FS_SUPER_MAGIC_STRING, strlen(REISER2FS_SUPER_MAGIC_STRING)) )
96
		rc = 2;
97
	if ( !strncmp(magic, REISER3FS_SUPER_MAGIC_STRING, strlen(REISER3FS_SUPER_MAGIC_STRING)) )
98
		rc = 3;
99
	return rc;
100
}																															   
101
102
static int 
103
get_label_uuid_reiserfs(int fd, char **label, char *uuid)
104
{
105
	struct reiserfs_super_block reiserfssb;
106
	if ( (lseek(fd, REISERFS_DISK_OFFSET_IN_BYTES, SEEK_SET) == REISERFS_DISK_OFFSET_IN_BYTES)
107
			&& ( read(fd, (char *) &reiserfssb, sizeof(reiserfssb)) == sizeof(reiserfssb) )
108
			/* Only 3.6.x format supers have labels or uuids. 
109
			Label and UUID can be set by reiserfstune -l/-u. */
110
			&& (reiserfs_magic_version((const char*)reiserfssb.s_magic) > 1) ) {
111
		size_t namesize;
112
		memcpy(uuid, reiserfssb.s_uuid, sizeof(reiserfssb.s_uuid));
113
		namesize = sizeof(reiserfssb.s_label);
114
		if ((*label = calloc(namesize + 1, 1)) != NULL)
115
			memcpy(*label, reiserfssb.s_label, namesize);
116
		return 0;
117
    }
118
	return 1;
119
}
120
121
static int
122
get_label_uuid(const char *device, char **label, char *uuid)
123
{
124
	int fd;
125
	int rv = 1;
126
	const GetLabelUuidProc *proc = get_label_uuid_proc_table;
127
128
	fd = open(device, O_RDONLY);
129
	if (fd < 0)
130
		return rv;
131
132
	while(*proc) {
133
		rv = (*proc)(fd, label, uuid);
134
		if ( !rv )
135
			break;
136
		++proc;
73
	}
137
	}
74
138
75
	close(fd);
139
	close(fd);
Lines 265-271 Link Here
265
	    uuid[i] = ((fromhex(s[0])<<4) | fromhex(s[1]));
329
	    uuid[i] = ((fromhex(s[0])<<4) | fromhex(s[1]));
266
	    s += 2;
330
	    s += 2;
267
	}
331
	}
268
	return get_spec_by_x(UUID, uuid, major, minor);
332
	return get_spec_by_x(UUID, (const char*)uuid, major, minor);
269
333
270
 bad_uuid:
334
 bad_uuid:
271
	fprintf(stderr, _("mount: bad UUID"));
335
	fprintf(stderr, _("mount: bad UUID"));
(-)mkinitrd-4.2.1.10.orig/nash/nash.c (-1 / +1 lines)
Lines 1561-1567 Link Here
1561
    int i;
1561
    int i;
1562
    char * start, * end;
1562
    char * start, * end;
1563
    char * chptr;
1563
    char * chptr;
1564
    int rc;
1564
    int rc = -1;
1565
1565
1566
    i = read(fd, contents, sizeof(contents) - 1);
1566
    i = read(fd, contents, sizeof(contents) - 1);
1567
    if (i == (sizeof(contents) - 1)) {
1567
    if (i == (sizeof(contents) - 1)) {

Return to bug 181685