/[pupa]/pupa/util/i386/pc/biosdisk.c
ViewVC logotype

Diff of /pupa/util/i386/pc/biosdisk.c

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

revision 1.2 by okuji, Thu Jan 2 23:46:21 2003 UTC revision 1.3 by okuji, Tue Jan 7 07:54:07 2003 UTC
# Line 177  pupa_util_biosdisk_open (const char *nam Line 177  pupa_util_biosdisk_open (const char *nam
177      if (! fd)      if (! fd)
178        return pupa_error (PUPA_ERR_BAD_DEVICE, "cannot open `%s'", map[drive]);        return pupa_error (PUPA_ERR_BAD_DEVICE, "cannot open `%s'", map[drive]);
179    
180        if (fstat (fd, &st) < 0 || ! S_ISBLK (st.st_mode))
181          {
182            close (fd);
183            goto fail;
184          }
185        
186      if (ioctl (fd, BLKGETSIZE, &nr))      if (ioctl (fd, BLKGETSIZE, &nr))
187        {        {
188          close (fd);          close (fd);
# Line 198  pupa_util_biosdisk_open (const char *nam Line 204  pupa_util_biosdisk_open (const char *nam
204    if (stat (map[drive], &st) < 0)    if (stat (map[drive], &st) < 0)
205      return pupa_error (PUPA_ERR_BAD_DEVICE, "cannot stat `%s'", map[drive]);      return pupa_error (PUPA_ERR_BAD_DEVICE, "cannot stat `%s'", map[drive]);
206    
207    if (st.st_blocks)    disk->total_sectors = st.st_size >> PUPA_DISK_SECTOR_BITS;
     disk->total_sectors = st.st_blocks;  
   else  
     /* Hmm... Use st_size instead.  */  
     disk->total_sectors = st.st_size >> PUPA_DISK_SECTOR_BITS;  
208        
209    pupa_util_info ("the size of %s is %lu", name, disk->total_sectors);    pupa_util_info ("the size of %s is %lu", name, disk->total_sectors);
210        

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26