[BACK]Return to ufs.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / lib / libsa

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/lib/libsa/ufs.c between version 1.50 and 1.50.4.2

version 1.50, 2007/09/29 21:36:56 version 1.50.4.2, 2008/02/18 21:06:59
Line 68 
Line 68 
 #include <ufs/ufs/dir.h>  #include <ufs/ufs/dir.h>
 #ifdef LIBSA_LFS  #ifdef LIBSA_LFS
 #include <sys/queue.h>  #include <sys/queue.h>
   #include <sys/condvar.h>
 #include <sys/mount.h>                  /* XXX for MNAMELEN */  #include <sys/mount.h>                  /* XXX for MNAMELEN */
 #include <ufs/lfs/lfs.h>  #include <ufs/lfs/lfs.h>
 #else  #else
Line 194  find_inode_sector(ino32_t inumber, struc
Line 195  find_inode_sector(ino32_t inumber, struc
   
         rc = read_inode(fs->lfs_ifile, f);          rc = read_inode(fs->lfs_ifile, f);
         if (rc)          if (rc)
                 return (rc);                  return rc;
   
         ifileent_blkno =          ifileent_blkno =
             (inumber / fs->lfs_ifpb) + fs->lfs_cleansz + fs->lfs_segtabsz;              (inumber / fs->lfs_ifpb) + fs->lfs_cleansz + fs->lfs_segtabsz;
Line 202  find_inode_sector(ino32_t inumber, struc
Line 203  find_inode_sector(ino32_t inumber, struc
             (inumber % fs->lfs_ifpb) * sizeof (IFILE_Vx);              (inumber % fs->lfs_ifpb) * sizeof (IFILE_Vx);
         rc = buf_read_file(f, &ent_in_buf, &buf_after_ent);          rc = buf_read_file(f, &ent_in_buf, &buf_after_ent);
         if (rc)          if (rc)
                 return (rc);                  return rc;
         /* make sure something's not badly wrong, but don't panic. */          /* make sure something's not badly wrong, but don't panic. */
         if (buf_after_ent < sizeof (IFILE_Vx))          if (buf_after_ent < sizeof (IFILE_Vx))
                 return (EINVAL);                  return EINVAL;
   
         *isp = FSBTODB(fs, ((IFILE_Vx *)ent_in_buf)->if_daddr);          *isp = FSBTODB(fs, ((IFILE_Vx *)ent_in_buf)->if_daddr);
         if (*isp == LFS_UNUSED_DADDR)   /* again, something badly wrong */          if (*isp == LFS_UNUSED_DADDR)   /* again, something badly wrong */
                 return (EINVAL);                  return EINVAL;
         return (0);          return 0;
 }  }
 #endif  #endif
   
Line 235  read_inode(ino32_t inumber, struct open_
Line 236  read_inode(ino32_t inumber, struct open_
         if (inumber == fs->lfs_ifile)          if (inumber == fs->lfs_ifile)
                 inode_sector = FSBTODB(fs, fs->lfs_idaddr);                  inode_sector = FSBTODB(fs, fs->lfs_idaddr);
         else if ((rc = find_inode_sector(inumber, f, &inode_sector)) != 0)          else if ((rc = find_inode_sector(inumber, f, &inode_sector)) != 0)
                 return (rc);                  return rc;
 #else  #else
         inode_sector = FSBTODB(fs, ino_to_fsba(fs, inumber));          inode_sector = FSBTODB(fs, ino_to_fsba(fs, inumber));
 #endif  #endif
Line 270  read_inode(ino32_t inumber, struct open_
Line 271  read_inode(ino32_t inumber, struct open_
          */           */
         fp->f_ind_cache_block = ~0;          fp->f_ind_cache_block = ~0;
         fp->f_buf_blkno = -1;          fp->f_buf_blkno = -1;
         return (rc);          return rc;
 }  }
   
 /*  /*
Line 282  block_map(struct open_file *f, indp_t fi
Line 283  block_map(struct open_file *f, indp_t fi
 {  {
         struct file *fp = (struct file *)f->f_fsdata;          struct file *fp = (struct file *)f->f_fsdata;
         struct fs *fs = fp->f_fs;          struct fs *fs = fp->f_fs;
         unsigned level;          uint level;
         indp_t ind_cache;          indp_t ind_cache;
         indp_t ind_block_num;          indp_t ind_block_num;
         size_t rsize;          size_t rsize;
Line 315  block_map(struct open_file *f, indp_t fi
Line 316  block_map(struct open_file *f, indp_t fi
         if (file_block < NDADDR) {          if (file_block < NDADDR) {
                 /* Direct block. */                  /* Direct block. */
                 *disk_block_p = fp->f_di.di_db[file_block];                  *disk_block_p = fp->f_di.di_db[file_block];
                 return (0);                  return 0;
         }          }
   
         file_block -= NDADDR;          file_block -= NDADDR;
Line 332  block_map(struct open_file *f, indp_t fi
Line 333  block_map(struct open_file *f, indp_t fi
                         break;                          break;
                 if (level > NIADDR * fp->f_nishift)                  if (level > NIADDR * fp->f_nishift)
                         /* Block number too high */                          /* Block number too high */
                         return (EFBIG);                          return EFBIG;
                 file_block -= (indp_t)1 << level;                  file_block -= (indp_t)1 << level;
         }          }
   
Line 342  block_map(struct open_file *f, indp_t fi
Line 343  block_map(struct open_file *f, indp_t fi
                 level -= fp->f_nishift;                  level -= fp->f_nishift;
                 if (ind_block_num == 0) {                  if (ind_block_num == 0) {
                         *disk_block_p = 0;      /* missing */                          *disk_block_p = 0;      /* missing */
                         return (0);                          return 0;
                 }                  }
   
                 twiddle();                  twiddle();
Line 356  block_map(struct open_file *f, indp_t fi
Line 357  block_map(struct open_file *f, indp_t fi
                         FSBTODB(fp->f_fs, ind_block_num), fs->fs_bsize,                          FSBTODB(fp->f_fs, ind_block_num), fs->fs_bsize,
                         buf, &rsize);                          buf, &rsize);
                 if (rc)                  if (rc)
                         return (rc);                          return rc;
                 if (rsize != fs->fs_bsize)                  if (rsize != fs->fs_bsize)
                         return EIO;                          return EIO;
                 ind_block_num = buf[file_block >> level];                  ind_block_num = buf[file_block >> level];
Line 372  block_map(struct open_file *f, indp_t fi
Line 373  block_map(struct open_file *f, indp_t fi
   
         *disk_block_p = ind_block_num;          *disk_block_p = ind_block_num;
   
         return (0);          return 0;
 }  }
   
 /*  /*
Line 401  buf_read_file(struct open_file *f, char 
Line 402  buf_read_file(struct open_file *f, char 
         if (file_block != fp->f_buf_blkno) {          if (file_block != fp->f_buf_blkno) {
                 rc = block_map(f, file_block, &disk_block);                  rc = block_map(f, file_block, &disk_block);
                 if (rc)                  if (rc)
                         return (rc);                          return rc;
   
                 if (disk_block == 0) {                  if (disk_block == 0) {
                         memset(fp->f_buf, 0, block_size);                          memset(fp->f_buf, 0, block_size);
Line 412  buf_read_file(struct open_file *f, char 
Line 413  buf_read_file(struct open_file *f, char 
                                 FSBTODB(fs, disk_block),                                  FSBTODB(fs, disk_block),
                                 block_size, fp->f_buf, &fp->f_buf_size);                                  block_size, fp->f_buf, &fp->f_buf_size);
                         if (rc)                          if (rc)
                                 return (rc);                                  return rc;
                 }                  }
   
                 fp->f_buf_blkno = file_block;                  fp->f_buf_blkno = file_block;
Line 432  buf_read_file(struct open_file *f, char 
Line 433  buf_read_file(struct open_file *f, char 
         if (*size_p > fp->f_di.di_size - fp->f_seekp)          if (*size_p > fp->f_di.di_size - fp->f_seekp)
                 *size_p = fp->f_di.di_size - fp->f_seekp;                  *size_p = fp->f_di.di_size - fp->f_seekp;
   
         return (0);          return 0;
 }  }
   
 /*  /*
Line 441  buf_read_file(struct open_file *f, char 
Line 442  buf_read_file(struct open_file *f, char 
  */   */
 static int  static int
 search_directory(const char *name, int length, struct open_file *f,  search_directory(const char *name, int length, struct open_file *f,
     ino32_t *inumber_p)          ino32_t *inumber_p)
 {  {
         struct file *fp = (struct file *)f->f_fsdata;          struct file *fp = (struct file *)f->f_fsdata;
         struct direct *dp;          struct direct *dp;
Line 455  search_directory(const char *name, int l
Line 456  search_directory(const char *name, int l
         while (fp->f_seekp < (off_t)fp->f_di.di_size) {          while (fp->f_seekp < (off_t)fp->f_di.di_size) {
                 rc = buf_read_file(f, &buf, &buf_size);                  rc = buf_read_file(f, &buf, &buf_size);
                 if (rc)                  if (rc)
                         return (rc);                          return rc;
   
                 dp = (struct direct *)buf;                  dp = (struct direct *)buf;
                 edp = (struct direct *)(buf + buf_size);                  edp = (struct direct *)(buf + buf_size);
Line 474  search_directory(const char *name, int l
Line 475  search_directory(const char *name, int l
                             !memcmp(name, dp->d_name, length)) {                              !memcmp(name, dp->d_name, length)) {
                                 /* found entry */                                  /* found entry */
                                 *inumber_p = dp->d_ino;                                  *inumber_p = dp->d_ino;
                                 return (0);                                  return 0;
                         }                          }
                 }                  }
                 fp->f_seekp += buf_size;                  fp->f_seekp += buf_size;
         }          }
         return (ENOENT);          return ENOENT;
 }  }
   
 #ifdef LIBSA_FFSv2  #ifdef LIBSA_FFSv2
Line 733  ufs_open(const char *path, struct open_f
Line 734  ufs_open(const char *path, struct open_f
   
 #endif /* !LIBSA_FS_SINGLECOMPONENT */  #endif /* !LIBSA_FS_SINGLECOMPONENT */
   
         fp->f_seekp = 0;                /* reset seek pointer */          fp->f_seekp = 0;                /* reset seek pointer */
   
 out:  out:
         if (rc)          if (rc)
                 ufs_close(f);                  ufs_close(f);
         return (rc);          return rc;
 }  }
   
 int  int
Line 748  ufs_close(struct open_file *f)
Line 749  ufs_close(struct open_file *f)
   
         f->f_fsdata = NULL;          f->f_fsdata = NULL;
         if (fp == NULL)          if (fp == NULL)
                 return (0);                  return 0;
   
         if (fp->f_buf)          if (fp->f_buf)
                 dealloc(fp->f_buf, fp->f_fs->fs_bsize);                  dealloc(fp->f_buf, fp->f_fs->fs_bsize);
         dealloc(fp->f_fs, SBLOCKSIZE);          dealloc(fp->f_fs, SBLOCKSIZE);
         dealloc(fp, sizeof(struct file));          dealloc(fp, sizeof(struct file));
         return (0);          return 0;
 }  }
   
 /*  /*
Line 791  ufs_read(struct open_file *f, void *star
Line 792  ufs_read(struct open_file *f, void *star
         }          }
         if (resid)          if (resid)
                 *resid = size;                  *resid = size;
         return (rc);          return rc;
 }  }
   
 /*  /*
Line 802  int
Line 803  int
 ufs_write(struct open_file *f, void *start, size_t size, size_t *resid)  ufs_write(struct open_file *f, void *start, size_t size, size_t *resid)
 {  {
   
         return (EROFS);          return EROFS;
 }  }
 #endif /* !LIBSA_NO_FS_WRITE */  #endif /* !LIBSA_NO_FS_WRITE */
   
Line 823  ufs_seek(struct open_file *f, off_t offs
Line 824  ufs_seek(struct open_file *f, off_t offs
                 fp->f_seekp = fp->f_di.di_size - offset;                  fp->f_seekp = fp->f_di.di_size - offset;
                 break;                  break;
         default:          default:
                 return (-1);                  return -1;
         }          }
         return (fp->f_seekp);          return fp->f_seekp;
 }  }
 #endif /* !LIBSA_NO_FS_SEEK */  #endif /* !LIBSA_NO_FS_SEEK */
   
Line 840  ufs_stat(struct open_file *f, struct sta
Line 841  ufs_stat(struct open_file *f, struct sta
         sb->st_uid = fp->f_di.di_uid;          sb->st_uid = fp->f_di.di_uid;
         sb->st_gid = fp->f_di.di_gid;          sb->st_gid = fp->f_di.di_gid;
         sb->st_size = fp->f_di.di_size;          sb->st_size = fp->f_di.di_size;
         return (0);          return 0;
 }  }
   
 #ifdef LIBSA_FFSv1  #ifdef LIBSA_FFSv1

Legend:
Removed from v.1.50  
changed lines
  Added in v.1.50.4.2

CVSweb <webmaster@jp.NetBSD.org>