예제 #1
0
/**
 * Loads a volume descriptor
 *  @param fs Filesystem
 *  @param type Type of volume descriptor
 *  @param buf Buffer for volume descriptor
 *  @return 0=success; -1=failure
 */
int iso9660_voldesc_load(struct cdi_fs_filesystem *fs,iso9660_voldesc_type_t type,void *buf) {
  debug("iso9660_voldesc_load(0x%x,%d,0x%x)\n",fs,type,buf);
  struct iso9660_voldesc header;
  size_t i;

  for (i=ISO9660_FIRST_SECTOR;header.type!=type && header.type!=ISO9660_VOLDESC_TERM;i++) {
    iso9660_sector_read(fs,i*ISO9660_DEFAULT_SECTOR_SIZE,sizeof(header),&header);
    if (!iso9660_voldesc_checksig(header.signature)) return -1;
  }
  i--;

  if (header.type==type) {
    iso9660_sector_read(fs,i*ISO9660_DEFAULT_SECTOR_SIZE,sizeof(struct iso9660_voldesc_prim),buf);
    return 0;
  }
  else {
    debug("Volume Descriptor: Wrong type: %d\n",header.type);
    return -1;
  }
}
예제 #2
0
파일: sector.c 프로젝트: jgraef/meinOS
/**
 * Reads data from device for cache
 *  @param cache CDI cache
 *  @param block Block to read
 *  @param count How many blocks to read
 *  @param dest Buffer to store data in
 *  @param prv Private data (CDI filesystem)
 */
int iso9660_sector_read_cache(struct cdi_cache *cache,uint64_t block,size_t count,void *dest,void *prv) {
  debug("iso9660_sector_read_cache(0x%x,0x%x,0x%x,0x%x,0x%x,0x%x)\n",cache,block,count,dest,prv);
  uint64_t start = ((uint64_t)block)*ISO9660_DEFAULT_SECTOR_SIZE;
  size_t size = count*ISO9660_DEFAULT_SECTOR_SIZE;
  return iso9660_sector_read(prv,start,size,dest)/ISO9660_DEFAULT_SECTOR_SIZE;
}