Пример #1
0
Файл: fs.c Проект: aosm/BootX
long LoadThinFatFile(char *fileSpec, void **binary)
{
  char       devSpec[256];
  char       *filePath;
  FSLoadFile loadFile;
  FSReadFile readFile;
  long       ret, length, length2, partIndex;
  
  ret = ConvertFileSpec(fileSpec, devSpec, &filePath);
  if ((ret == -1) || (filePath == NULL)) return -1;
  
  // Get the partition index for devSpec.
  partIndex = LookupPartition(devSpec);
  if (partIndex == -1) return -1;
  
  *binary = (void *)kLoadAddr;
  
  readFile = gParts[partIndex].readFile;
  
  if (readFile != NULL) {
    // Read the first 4096 bytes (fat header)
    length = readFile(gParts[partIndex].partIH, filePath, *binary, 0, 0x1000);
    if (length > 0) {
      if (ThinFatBinary(binary, &length) == 0) {
        // We found a fat binary; read only the thin part
        length = readFile(gParts[partIndex].partIH, filePath,
                          (void *)kLoadAddr, (unsigned long)(*binary) - kLoadAddr, length);
        *binary = (void *)kLoadAddr;
      } else {
        // Not a fat binary; read the rest of the file
        length2 = readFile(gParts[partIndex].partIH, filePath, (void *)(kLoadAddr + length), length, 0);
        if (length2 == -1) return -1;
        length += length2;
      }
    }
  } else {
    loadFile = gParts[partIndex].loadFile;
    length = loadFile(gParts[partIndex].partIH, filePath);
    if (length > 0) {
      ThinFatBinary(binary, &length);
    }
  }
  
  return length;
}
Пример #2
0
Файл: fs.c Проект: aosm/BootX
long GetFSUUID(char *spec, char *uuidStr)
{
  long       rval = -1, partIndex;
  FSGetUUID  getUUID;
  char       devSpec[256];
  
  do {
    if(ConvertFileSpec(spec, devSpec, NULL))  break;
    
    // Get the partition index
    partIndex = LookupPartition(devSpec);
    if (partIndex == -1)  break;
    
    getUUID = gParts[partIndex].getUUID;
    if(getUUID)
      rval = getUUID(gParts[partIndex].partIH, uuidStr);
  } while(0);

  return rval;
}
Пример #3
0
long GetDirEntry(char *dirSpec, long *dirIndex, char **name,
                 long *flags, long *time)
{
    char          devSpec[256];
    char          *dirPath;
    FSGetDirEntry getDirEntry;
    long          ret, partIndex;

    ret = ConvertFileSpec(dirSpec, devSpec, &dirPath);
    if ((ret == -1) || (dirPath == NULL)) return -1;

    // Get the partition index for devSpec.
    partIndex = LookupPartition(devSpec);
    if (partIndex == -1) return -1;

    getDirEntry = gParts[partIndex].getDirEntry;
    ret = getDirEntry(gParts[partIndex].partIH, dirPath,
                      dirIndex, name, flags, time);
    return ret;
}
Пример #4
0
Файл: fs.c Проект: aosm/BootX
long LoadFile(char *fileSpec)
{
  char       devSpec[256];
  char       *filePath;
  FSLoadFile loadFile;
  long       ret, length, partIndex;
  
  ret = ConvertFileSpec(fileSpec, devSpec, &filePath);
  if ((ret == -1) || (filePath == NULL)) return -1;
  
  // Get the partition index for devSpec.
  partIndex = LookupPartition(devSpec);
  if (partIndex == -1) return -1;
  
  loadFile = gParts[partIndex].loadFile;
  length = loadFile(gParts[partIndex].partIH, filePath);
  
//  if (length == 0) return -1;
  
  return length;
}