Magellan Linux

Diff of /tags/grubby-8_20/grubby.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1736 by niro, Sat Feb 18 01:02:17 2012 UTC revision 1745 by niro, Sat Feb 18 01:05:52 2012 UTC
# Line 1368  void notSuitablePrintf(struct singleEntr Line 1368  void notSuitablePrintf(struct singleEntr
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;
# Line 1398  int suitableImage(struct singleEntry * e Line 1411  int suitableImage(struct singleEntry * e
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;

Legend:
Removed from v.1736  
changed lines
  Added in v.1745