701 |
struct configFileInfo *cfi); |
struct configFileInfo *cfi); |
702 |
static int getNextLine(char **bufPtr, struct singleLine *line, |
static int getNextLine(char **bufPtr, struct singleLine *line, |
703 |
struct configFileInfo *cfi); |
struct configFileInfo *cfi); |
704 |
static char *getRootSpecifier(char *str); |
static size_t getRootSpecifier(const char *str); |
705 |
static void requote(struct singleLine *line, struct configFileInfo *cfi); |
static void requote(struct singleLine *line, struct configFileInfo *cfi); |
706 |
static void insertElement(struct singleLine *line, |
static void insertElement(struct singleLine *line, |
707 |
const char *item, int insertHere, |
const char *item, int insertHere, |
2125 |
char *fullName; |
char *fullName; |
2126 |
int i; |
int i; |
2127 |
char *dev; |
char *dev; |
2128 |
char *rootspec; |
size_t rs; |
2129 |
char *rootdev; |
char *rootdev; |
2130 |
|
|
2131 |
if (skipRemoved && entry->skip) { |
if (skipRemoved && entry->skip) { |
2153 |
|
|
2154 |
fullName = alloca(strlen(bootPrefix) + |
fullName = alloca(strlen(bootPrefix) + |
2155 |
strlen(line->elements[1].item) + 1); |
strlen(line->elements[1].item) + 1); |
2156 |
rootspec = getRootSpecifier(line->elements[1].item); |
rs = getRootSpecifier(line->elements[1].item); |
|
int rootspec_offset = rootspec ? strlen(rootspec) : 0; |
|
2157 |
int hasslash = endswith(bootPrefix, '/') || |
int hasslash = endswith(bootPrefix, '/') || |
2158 |
beginswith(line->elements[1].item + rootspec_offset, '/'); |
beginswith(line->elements[1].item + rs, '/'); |
2159 |
sprintf(fullName, "%s%s%s", bootPrefix, hasslash ? "" : "/", |
sprintf(fullName, "%s%s%s", bootPrefix, hasslash ? "" : "/", |
2160 |
line->elements[1].item + rootspec_offset); |
line->elements[1].item + rs); |
2161 |
if (access(fullName, R_OK)) { |
if (access(fullName, R_OK)) { |
2162 |
notSuitablePrintf(entry, 0, "access to %s failed\n", fullName); |
notSuitablePrintf(entry, 0, "access to %s failed\n", fullName); |
2163 |
return 0; |
return 0; |
2249 |
struct singleLine *line; |
struct singleLine *line; |
2250 |
int i; |
int i; |
2251 |
char *chptr; |
char *chptr; |
|
char *rootspec = NULL; |
|
2252 |
enum lineType_e checkType = LT_KERNEL; |
enum lineType_e checkType = LT_KERNEL; |
2253 |
|
|
2254 |
if (isdigit(*kernel)) { |
if (isdigit(*kernel)) { |
2353 |
|
|
2354 |
if (line && line->type != LT_MENUENTRY && |
if (line && line->type != LT_MENUENTRY && |
2355 |
line->numElements >= 2) { |
line->numElements >= 2) { |
2356 |
rootspec = |
if (!strcmp(line->elements[1].item + |
2357 |
getRootSpecifier(line->elements[1]. |
getRootSpecifier( |
2358 |
item); |
line->elements[1].item), |
2359 |
if (!strcmp |
kernel + strlen(prefix))) |
|
(line->elements[1].item + |
|
|
((rootspec != |
|
|
NULL) ? strlen(rootspec) : 0), |
|
|
kernel + strlen(prefix))) |
|
2360 |
break; |
break; |
2361 |
} |
} |
2362 |
if (line->type == LT_MENUENTRY && |
if (line->type == LT_MENUENTRY && |
3265 |
type & (LT_HYPER | LT_KERNEL | LT_MBMODULE | LT_INITRD | |
type & (LT_HYPER | LT_KERNEL | LT_MBMODULE | LT_INITRD | |
3266 |
LT_KERNEL_EFI | LT_INITRD_EFI | LT_KERNEL_16 | |
LT_KERNEL_EFI | LT_INITRD_EFI | LT_KERNEL_16 | |
3267 |
LT_INITRD_16)) { |
LT_INITRD_16)) { |
3268 |
char *rootspec = |
size_t rs = getRootSpecifier(tmplLine->elements[1].item); |
3269 |
getRootSpecifier(tmplLine->elements[1].item); |
if (rs > 0) { |
|
if (rootspec != NULL) { |
|
3270 |
free(newLine->elements[1].item); |
free(newLine->elements[1].item); |
3271 |
newLine->elements[1].item = |
newLine->elements[1].item = sdupprintf( |
3272 |
sdupprintf("%s%s", rootspec, val); |
"%.*s%s", (int) rs, |
3273 |
|
tmplLine->elements[1].item, val); |
3274 |
} |
} |
3275 |
} |
} |
3276 |
} |
} |
4322 |
return 1; |
return 1; |
4323 |
} |
} |
4324 |
|
|
4325 |
static char *getRootSpecifier(char *str) |
static size_t getRootSpecifier(const char *str) |
4326 |
{ |
{ |
4327 |
char *idx, *rootspec = NULL; |
size_t rs = 0; |
4328 |
|
|
4329 |
if (*str == '(') { |
if (*str == '(') { |
4330 |
idx = rootspec = strdup(str); |
for (; str[rs] != ')' && !isspace(str[rs]); rs++) { |
4331 |
while (*idx && (*idx != ')') && (!isspace(*idx))) |
if (!str[rs]) |
4332 |
idx++; |
return rs; |
4333 |
*(++idx) = '\0'; |
} |
4334 |
|
rs++; |
4335 |
} |
} |
4336 |
return rootspec; |
|
4337 |
|
return rs; |
4338 |
} |
} |
4339 |
|
|
4340 |
static char *getInitrdVal(struct grubConfig *config, |
static char *getInitrdVal(struct grubConfig *config, |
5364 |
if (displayDefault) { |
if (displayDefault) { |
5365 |
struct singleLine *line; |
struct singleLine *line; |
5366 |
struct singleEntry *entry; |
struct singleEntry *entry; |
5367 |
char *rootspec; |
size_t rs; |
5368 |
|
|
5369 |
if (config->defaultImage == NO_DEFAULT_ENTRY) |
if (config->defaultImage == NO_DEFAULT_ENTRY) |
5370 |
return 0; |
return 0; |
5383 |
if (!line) |
if (!line) |
5384 |
return 0; |
return 0; |
5385 |
|
|
5386 |
rootspec = getRootSpecifier(line->elements[1].item); |
rs = getRootSpecifier(line->elements[1].item); |
5387 |
printf("%s%s\n", bootPrefix, line->elements[1].item + |
printf("%s%s\n", bootPrefix, line->elements[1].item + rs); |
|
((rootspec != NULL) ? strlen(rootspec) : 0)); |
|
5388 |
|
|
5389 |
return 0; |
return 0; |
5390 |
|
|