Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/makefs/ffs.c
Show First 20 Lines • Show All 914 Lines • ▼ Show 20 Lines | ffs_write_file(union dinode *din, uint32_t ino, void *buf, fsinfo_t *fsopts) | ||||
in.i_fd = fsopts->fd; | in.i_fd = fsopts->fd; | ||||
if (DIP(din, size) == 0) | if (DIP(din, size) == 0) | ||||
goto write_inode_and_leave; /* mmm, cheating */ | goto write_inode_and_leave; /* mmm, cheating */ | ||||
if (isfile) { | if (isfile) { | ||||
fbuf = emalloc(ffs_opts->bsize); | fbuf = emalloc(ffs_opts->bsize); | ||||
if ((ffd = open((char *)buf, O_RDONLY, 0444)) == -1) { | if ((ffd = open((char *)buf, O_RDONLY, 0444)) == -1) { | ||||
warn("Can't open `%s' for reading", (char *)buf); | err(EXIT_FAILURE, "Can't open `%s' for reading", (char *)buf); | ||||
goto leave_ffs_write_file; | |||||
} | } | ||||
} else { | } else { | ||||
p = buf; | p = buf; | ||||
} | } | ||||
chunk = 0; | chunk = 0; | ||||
for (bufleft = DIP(din, size); bufleft > 0; bufleft -= chunk) { | for (bufleft = DIP(din, size); bufleft > 0; bufleft -= chunk) { | ||||
chunk = MIN(bufleft, ffs_opts->bsize); | chunk = MIN(bufleft, ffs_opts->bsize); | ||||
Show All 37 Lines | if (errno != 0) | ||||
goto bad_ffs_write_file; | goto bad_ffs_write_file; | ||||
brelse(bp, 0); | brelse(bp, 0); | ||||
if (!isfile) | if (!isfile) | ||||
p += chunk; | p += chunk; | ||||
} | } | ||||
write_inode_and_leave: | write_inode_and_leave: | ||||
ffs_write_inode(&in.i_din, in.i_number, fsopts); | ffs_write_inode(&in.i_din, in.i_number, fsopts); | ||||
leave_ffs_write_file: | |||||
if (fbuf) | if (fbuf) | ||||
free(fbuf); | free(fbuf); | ||||
if (ffd != -1) | if (ffd != -1) | ||||
close(ffd); | close(ffd); | ||||
} | } | ||||
static void | static void | ||||
▲ Show 20 Lines • Show All 185 Lines • Show Last 20 Lines |