Lines Matching refs:fd
32 int fd;
35 fd = open(fn, O_RDONLY);
36 if(fd < 0) return 0;
38 sz = lseek(fd, 0, SEEK_END);
41 if(lseek(fd, 0, SEEK_SET) != 0) goto oops;
46 if(read(fd, data, sz) != sz) goto oops;
47 close(fd);
53 close(fd);
77 int write_padding(int fd, unsigned pagesize, unsigned itemsize)
88 if(write(fd, padding, count) != count) {
109 int fd;
239 fd = open(bootimg, O_CREAT | O_TRUNC | O_WRONLY, 0644);
240 if(fd < 0) {
245 if(write(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) goto fail;
246 if(write_padding(fd, pagesize, sizeof(hdr))) goto fail;
248 if(write(fd, kernel_data, hdr.kernel_size) != hdr.kernel_size) goto fail;
249 if(write_padding(fd, pagesize, hdr.kernel_size)) goto fail;
251 if(write(fd, ramdisk_data, hdr.ramdisk_size) != hdr.ramdisk_size) goto fail;
252 if(write_padding(fd, pagesize, hdr.ramdisk_size)) goto fail;
255 if(write(fd, second_data, hdr.second_size) != hdr.second_size) goto fail;
256 if(write_padding(fd, pagesize, hdr.ramdisk_size)) goto fail;
263 close(fd);