Lines Matching refs:fp

126 #define DIP(fp, field) \
127 ((fp)->f_fs->fs_magic == FS_UFS1_MAGIC ? \
128 (fp)->f_di.di1.field : (fp)->f_di.di2.field)
144 struct file *fp = (struct file *)f->f_fsdata;
145 struct fs *fs = fp->f_fs;
168 if (fp->f_fs->fs_magic == FS_UFS1_MAGIC)
169 fp->f_di.di1 = ((struct ufs1_dinode *)buf)
172 fp->f_di.di2 = ((struct ufs2_dinode *)buf)
182 fp->f_blkno[level] = -1;
183 fp->f_buf_blkno = -1;
185 fp->f_seekp = 0;
201 struct file *fp = (struct file *)f->f_fsdata;
202 struct fs *fs = fp->f_fs;
233 *disk_block_p = DIP(fp, di_db[file_block]);
246 if (file_block < fp->f_nindir[level])
248 file_block -= fp->f_nindir[level];
255 ind_block_num = DIP(fp, di_ib[level]);
263 if (fp->f_blkno[level] != ind_block_num) {
264 if (fp->f_blk[level] == (char *)0)
265 fp->f_blk[level] =
269 fsbtodb(fp->f_fs, ind_block_num),
271 fp->f_blk[level],
272 &fp->f_blksize[level]);
275 if (fp->f_blksize[level] != fs->fs_bsize)
277 fp->f_blkno[level] = ind_block_num;
281 idx = file_block / fp->f_nindir[level - 1];
282 file_block %= fp->f_nindir[level - 1];
286 if (fp->f_fs->fs_magic == FS_UFS1_MAGIC)
287 ind_block_num = ((ufs1_daddr_t *)fp->f_blk[level])[idx];
289 ind_block_num = ((ufs2_daddr_t *)fp->f_blk[level])[idx];
306 struct file *fp = (struct file *)f->f_fsdata;
307 struct fs *fs = fp->f_fs;
317 off = blkoff(fs, fp->f_seekp);
318 file_block = lblkno(fs, fp->f_seekp);
319 block_size = sblksize(fs, DIP(fp, di_size), file_block);
333 if (*size_p > DIP(fp, di_size) - fp->f_seekp)
334 *size_p = DIP(fp, di_size) - fp->f_seekp;
343 (file_block != fp->f_buf_blkno)) {
345 if (fp->f_buf == (char *)0)
346 fp->f_buf = malloc(fs->fs_bsize);
351 block_size, fp->f_buf, &fp->f_buf_size);
355 fp->f_buf_blkno = file_block;
361 bcopy(buf_p, fp->f_buf + off, *size_p);
370 block_size, fp->f_buf, &fp->f_buf_size);
384 struct file *fp = (struct file *)f->f_fsdata;
385 struct fs *fs = fp->f_fs;
392 off = blkoff(fs, fp->f_seekp);
393 file_block = lblkno(fs, fp->f_seekp);
394 block_size = sblksize(fs, DIP(fp, di_size), file_block);
396 if (file_block != fp->f_buf_blkno) {
397 if (fp->f_buf == (char *)0)
398 fp->f_buf = malloc(fs->fs_bsize);
405 bzero(fp->f_buf, block_size);
406 fp->f_buf_size = block_size;
411 block_size, fp->f_buf, &fp->f_buf_size);
416 fp->f_buf_blkno = file_block;
424 *buf_p = fp->f_buf + off;
430 if (*size_p > DIP(fp, di_size) - fp->f_seekp)
431 *size_p = DIP(fp, di_size) - fp->f_seekp;
446 struct file *fp = (struct file *)f->f_fsdata;
456 fp->f_seekp = 0;
457 while (fp->f_seekp < DIP(fp, di_size)) {
477 fp->f_seekp += buf_size;
495 struct file *fp;
505 fp = malloc(sizeof(struct file));
506 bzero(fp, sizeof(struct file));
507 f->f_fsdata = (void *)fp;
511 fp->f_fs = fs;
544 fp->f_nindir[level] = mult;
570 if ((DIP(fp, di_mode) & IFMT) != IFDIR) {
612 if ((DIP(fp, di_mode) & IFMT) == IFLNK) {
613 int link_len = DIP(fp, di_size);
627 if (fp->f_fs->fs_magic == FS_UFS1_MAGIC)
628 cp = (caddr_t)(fp->f_di.di1.di_db);
630 cp = (caddr_t)(fp->f_di.di2.di_db);
638 struct fs *fs = fp->f_fs;
675 fp->f_seekp = 0;
682 if (fp->f_buf)
683 free(fp->f_buf);
684 free(fp->f_fs);
685 free(fp);
694 struct file *fp = (struct file *)f->f_fsdata;
698 if (fp == (struct file *)0)
702 if (fp->f_blk[level])
703 free(fp->f_blk[level]);
705 if (fp->f_buf)
706 free(fp->f_buf);
707 free(fp->f_fs);
708 free(fp);
723 struct file *fp = (struct file *)f->f_fsdata;
731 if (fp->f_seekp >= DIP(fp, di_size))
744 fp->f_seekp += csize;
765 struct file *fp = (struct file *)f->f_fsdata;
772 if (fp->f_seekp >= DIP(fp, di_size))
781 fp->f_seekp += csize;
796 struct file *fp = (struct file *)f->f_fsdata;
800 fp->f_seekp = offset;
803 fp->f_seekp += offset;
806 fp->f_seekp = DIP(fp, di_size) - offset;
812 return (fp->f_seekp);
820 struct file *fp = (struct file *)f->f_fsdata;
823 sb->st_mode = DIP(fp, di_mode);
824 sb->st_uid = DIP(fp, di_uid);
825 sb->st_gid = DIP(fp, di_gid);
826 sb->st_size = DIP(fp, di_size);
833 struct file *fp = (struct file *)f->f_fsdata;
843 if (fp->f_seekp >= DIP(fp, di_size))
849 fp->f_seekp += dp->d_reclen;