Lines Matching defs:fp

127 #define DIP(fp, field) \
128 ((fp)->f_fs->fs_magic == FS_UFS1_MAGIC ? \
129 (fp)->f_di.di1.field : (fp)->f_di.di2.field)
145 struct file *fp = (struct file *)f->f_fsdata;
146 struct fs *fs = fp->f_fs;
169 if (fp->f_fs->fs_magic == FS_UFS1_MAGIC)
170 fp->f_di.di1 = ((struct ufs1_dinode *)buf)
173 fp->f_di.di2 = ((struct ufs2_dinode *)buf)
183 fp->f_blkno[level] = -1;
184 fp->f_buf_blkno = -1;
186 fp->f_seekp = 0;
202 struct file *fp = (struct file *)f->f_fsdata;
203 struct fs *fs = fp->f_fs;
234 *disk_block_p = DIP(fp, di_db[file_block]);
247 if (file_block < fp->f_nindir[level])
249 file_block -= fp->f_nindir[level];
256 ind_block_num = DIP(fp, di_ib[level]);
264 if (fp->f_blkno[level] != ind_block_num) {
265 if (fp->f_blk[level] == (char *)0)
266 fp->f_blk[level] =
270 fsbtodb(fp->f_fs, ind_block_num), 0,
272 fp->f_blk[level],
273 &fp->f_blksize[level]);
276 if (fp->f_blksize[level] != fs->fs_bsize)
278 fp->f_blkno[level] = ind_block_num;
282 idx = file_block / fp->f_nindir[level - 1];
283 file_block %= fp->f_nindir[level - 1];
287 if (fp->f_fs->fs_magic == FS_UFS1_MAGIC)
288 ind_block_num = ((ufs1_daddr_t *)fp->f_blk[level])[idx];
290 ind_block_num = ((ufs2_daddr_t *)fp->f_blk[level])[idx];
307 struct file *fp = (struct file *)f->f_fsdata;
308 struct fs *fs = fp->f_fs;
318 off = blkoff(fs, fp->f_seekp);
319 file_block = lblkno(fs, fp->f_seekp);
320 block_size = sblksize(fs, DIP(fp, di_size), file_block);
334 if (*size_p > DIP(fp, di_size) - fp->f_seekp)
335 *size_p = DIP(fp, di_size) - fp->f_seekp;
344 (file_block != fp->f_buf_blkno)) {
346 if (fp->f_buf == (char *)0)
347 fp->f_buf = malloc(fs->fs_bsize);
352 block_size, fp->f_buf, &fp->f_buf_size);
356 fp->f_buf_blkno = file_block;
362 bcopy(buf_p, fp->f_buf + off, *size_p);
371 block_size, fp->f_buf, &fp->f_buf_size);
385 struct file *fp = (struct file *)f->f_fsdata;
386 struct fs *fs = fp->f_fs;
393 off = blkoff(fs, fp->f_seekp);
394 file_block = lblkno(fs, fp->f_seekp);
395 block_size = sblksize(fs, DIP(fp, di_size), file_block);
397 if (file_block != fp->f_buf_blkno) {
398 if (fp->f_buf == (char *)0)
399 fp->f_buf = malloc(fs->fs_bsize);
406 bzero(fp->f_buf, block_size);
407 fp->f_buf_size = block_size;
412 block_size, fp->f_buf, &fp->f_buf_size);
417 fp->f_buf_blkno = file_block;
425 *buf_p = fp->f_buf + off;
431 if (*size_p > DIP(fp, di_size) - fp->f_seekp)
432 *size_p = DIP(fp, di_size) - fp->f_seekp;
447 struct file *fp = (struct file *)f->f_fsdata;
457 fp->f_seekp = 0;
458 while (fp->f_seekp < DIP(fp, di_size)) {
478 fp->f_seekp += buf_size;
496 struct file *fp;
506 fp = malloc(sizeof(struct file));
507 bzero(fp, sizeof(struct file));
508 f->f_fsdata = (void *)fp;
512 fp->f_fs = fs;
545 fp->f_nindir[level] = mult;
571 if ((DIP(fp, di_mode) & IFMT) != IFDIR) {
613 if ((DIP(fp, di_mode) & IFMT) == IFLNK) {
614 int link_len = DIP(fp, di_size);
628 if (fp->f_fs->fs_magic == FS_UFS1_MAGIC)
629 cp = (caddr_t)(fp->f_di.di1.di_db);
631 cp = (caddr_t)(fp->f_di.di2.di_db);
639 struct fs *fs = fp->f_fs;
676 fp->f_seekp = 0;
683 if (fp->f_buf)
684 free(fp->f_buf);
685 free(fp->f_fs);
686 free(fp);
695 struct file *fp = (struct file *)f->f_fsdata;
699 if (fp == (struct file *)0)
703 if (fp->f_blk[level])
704 free(fp->f_blk[level]);
706 if (fp->f_buf)
707 free(fp->f_buf);
708 free(fp->f_fs);
709 free(fp);
724 struct file *fp = (struct file *)f->f_fsdata;
732 if (fp->f_seekp >= DIP(fp, di_size))
745 fp->f_seekp += csize;
766 struct file *fp = (struct file *)f->f_fsdata;
773 if (fp->f_seekp >= DIP(fp, di_size))
782 fp->f_seekp += csize;
797 struct file *fp = (struct file *)f->f_fsdata;
801 fp->f_seekp = offset;
804 fp->f_seekp += offset;
807 fp->f_seekp = DIP(fp, di_size) - offset;
813 return (fp->f_seekp);
821 struct file *fp = (struct file *)f->f_fsdata;
824 sb->st_mode = DIP(fp, di_mode);
825 sb->st_uid = DIP(fp, di_uid);
826 sb->st_gid = DIP(fp, di_gid);
827 sb->st_size = DIP(fp, di_size);
834 struct file *fp = (struct file *)f->f_fsdata;
844 if (fp->f_seekp >= DIP(fp, di_size))
850 fp->f_seekp += dp->d_reclen;