1368 |
va_end(argp); |
va_end(argp); |
1369 |
} |
} |
1370 |
|
|
1371 |
|
#define beginswith(s, c) ((s) && (s)[0] == (c)) |
1372 |
|
|
1373 |
|
static int endswith(const char *s, char c) |
1374 |
|
{ |
1375 |
|
int slen; |
1376 |
|
|
1377 |
|
if (!s && !s[0]) |
1378 |
|
return 0; |
1379 |
|
slen = strlen(s) - 1; |
1380 |
|
|
1381 |
|
return s[slen] == c; |
1382 |
|
} |
1383 |
|
|
1384 |
int suitableImage(struct singleEntry * entry, const char * bootPrefix, |
int suitableImage(struct singleEntry * entry, const char * bootPrefix, |
1385 |
int skipRemoved, int flags) { |
int skipRemoved, int flags) { |
1386 |
struct singleLine * line; |
struct singleLine * line; |
1411 |
fullName = alloca(strlen(bootPrefix) + |
fullName = alloca(strlen(bootPrefix) + |
1412 |
strlen(line->elements[1].item) + 1); |
strlen(line->elements[1].item) + 1); |
1413 |
rootspec = getRootSpecifier(line->elements[1].item); |
rootspec = getRootSpecifier(line->elements[1].item); |
1414 |
sprintf(fullName, "%s%s", bootPrefix, |
int rootspec_offset = rootspec ? strlen(rootspec) : 0; |
1415 |
line->elements[1].item + (rootspec ? strlen(rootspec) : 0)); |
int hasslash = endswith(bootPrefix, '/') || |
1416 |
|
beginswith(line->elements[1].item + rootspec_offset, '/'); |
1417 |
|
sprintf(fullName, "%s%s%s", bootPrefix, hasslash ? "" : "/", |
1418 |
|
line->elements[1].item + rootspec_offset); |
1419 |
if (access(fullName, R_OK)) { |
if (access(fullName, R_OK)) { |
1420 |
notSuitablePrintf(entry, "access to %s failed\n", fullName); |
notSuitablePrintf(entry, "access to %s failed\n", fullName); |
1421 |
return 0; |
return 0; |