void send_exclude_list(int f) { int i; extern int remote_version; if (!exclude_list) { write_int(f,0); return; } for (i=0;exclude_list[i];i++) { char *pattern = exclude_list[i]->pattern; int l; l = strlen(pattern); if (l == 0) continue; if (exclude_list[i]->include) { if (remote_version < 19) { rprintf(FERROR,"remote rsync does not support include syntax - aborting\n"); exit_cleanup(RERR_UNSUPPORTED); } write_int(f,l+2); write_buf(f,"+ ",2); } else { write_int(f,l); } write_buf(f,pattern,l); } write_int(f,0); }
int varint_encode(uint64_t source, char *buf, int size, int *written) { int needed = varint_encode_size(source); if (size < needed) { return 1; } *written = 0; int pos = 0; if (source < 0) { source = ~source; if (source < 0x4) { write_buf(buf, &pos, written, 0xFC | source); return 0; } else { write_buf(buf, &pos, written, 0xF8); } } if (source < 0x80) { // Need top bit clear write_buf(buf, &pos, written, source); } else if (source < 0x4000) { // Need top two bits clear write_buf(buf, &pos, written, (source >> 8) | 0x80); write_buf(buf, &pos, written, source & 0xFF); } else if (source < 0x200000) {
/* send a complete uid/gid mapping to the peer */ void send_uid_list(int f) { struct idlist *list; if (numeric_ids) return; if (preserve_uid) { /* we send sequences of uid/byte-length/name */ list = uidlist; while (list) { int len = strlen(list->name); write_int(f, list->id); write_byte(f, len); write_buf(f, list->name, len); list = list->next; } /* terminate the uid list with a 0 uid. We explicitly exclude 0 from the list */ write_int(f, 0); } if (preserve_gid) { list = gidlist; while (list) { int len = strlen(list->name); write_int(f, list->id); write_byte(f, len); write_buf(f, list->name, len); list = list->next; } write_int(f, 0); } }
static int write_cmd(char *buf, int len) { byte hd[2]; enc_int16(len, hd); if (write_buf(1, (char *)hd, 2) != 2) return 0; if (write_buf(1, buf, len) != len) return 0; return 1; }
int unix_pass_trigger(const char *service, const char *buf, ssize_t len, int timeout) { const char *myname = "unix_pass_trigger"; int pair[2]; struct unix_pass_trigger *up; int fd; if (msg_verbose > 1) msg_info("%s: service %s", myname, service); /* * Connect... */ if ((fd = unix_pass_connect(service, BLOCKING, timeout)) < 0) { if (msg_verbose) msg_warn("%s: connect to %s: %m", myname, service); return (-1); } close_on_exec(fd, CLOSE_ON_EXEC); /* * Create a pipe, and send one pipe end to the server. */ if (pipe(pair) < 0) msg_fatal("%s: pipe: %m", myname); close_on_exec(pair[0], CLOSE_ON_EXEC); close_on_exec(pair[1], CLOSE_ON_EXEC); if (unix_send_fd(fd, pair[0]) < 0) msg_fatal("%s: send file descriptor: %m", myname); /* * Stash away context. */ up = (struct unix_pass_trigger *) mymalloc(sizeof(*up)); up->fd = fd; up->service = mystrdup(service); up->pair[0] = pair[0]; up->pair[1] = pair[1]; /* * Write the request... */ if (write_buf(pair[1], buf, len, timeout) < 0 || write_buf(pair[1], "", 1, timeout) < 0) if (msg_verbose) msg_warn("%s: write to %s: %m", myname, service); /* * Wakeup when the peer disconnects, or when we lose patience. */ if (timeout > 0) event_request_timer(unix_pass_trigger_event, (char *) up, timeout + 100); event_enable_read(fd, unix_pass_trigger_event, (char *) up); return (0); }
/** * locking_reset - reset the channel * @rchan: the channel * @init: 1 if this is a first-time channel initialization */ void locking_reset(struct rchan *rchan, int init) { if (init) channel_lock(rchan) = RAW_SPIN_LOCK_UNLOCKED; write_buf(rchan) = rchan->buf; write_buf_end(rchan) = write_buf(rchan) + rchan->buf_size; cur_write_pos(rchan) = write_buf(rchan); write_limit(rchan) = write_buf_end(rchan) - rchan->end_reserve; in_progress_event_pos(rchan) = NULL; in_progress_event_size(rchan) = 0; interrupted_pos(rchan) = NULL; interrupting_size(rchan) = 0; }
void NRF24L01::set_local_addr(uint8_t ch,uint8_t *addr) { uint8_t tmp_addr[5]; if(0 < ch && ch < 2) write_buf(NRF_WRITE_REG + RX_ADDR_P0 + ch, addr, this->rx_aw);//写RX节点地址 else if(2 <= ch && ch < 6){ tmp_addr[0] = rx_addr_1[0]; tmp_addr[1] = rx_addr_1[1]; tmp_addr[2] = rx_addr_1[2]; tmp_addr[3] = rx_addr_1[3]; tmp_addr[4] = addr[4]; write_buf(NRF_WRITE_REG + RX_ADDR_P0 + ch, tmp_addr, this->rx_aw);//写RX节点地址 } }
void NRF24L01::set_tx_mode() { // uint8_t cfg; ce->reset(); // write_buf(NRF_WRITE_REG+TX_ADDR,tx_addr,TX_ADR_WIDTH); //写TX节点地址 // set_addr_width(5); // set_destination_addr(tx_addr); // set_local_addr(0,rx_addr_0);//写RX节点地址 // //write_reg(NRF_WRITE_REG+SETUP_RETR,0x1a);//设置自动重发间隔时间:500us + 86us;最大自动重发次数:10次 // set_retry(10); // set_retry_gap(1); // set_chanal_ack(0,ENABLE); //使能通道0的自动应答 // set_chanal(0,ENABLE);//使能通道0的接收地址 // // set_rf_frq(40); //设置RF通信频率 // // set_pload_width(0,4);//选择通道0的有效数据宽度 // set_gain(RF_N_0DB);//设置TX发射参数,0db增益,低噪声增益开启 // set_baudrate(_2MBPS);//2Mbps // // set_power(1);//PWR_UP // set_tx_rx_mode(0);//接收模式 // set_crc(1,1);//EN_CRC,16BIT_CRC write_buf(NRF_WRITE_REG+TX_ADDR,tx_addr,TX_ADR_WIDTH); //写TX节点地址 write_buf(NRF_WRITE_REG+RX_ADDR_P0,tx_addr,RX_ADR_WIDTH); //设置TX节点地址,主要为了使能ACK write_reg(NRF_WRITE_REG+EN_AA,0x01); //使能通道0的自动应答 write_reg(NRF_WRITE_REG+EN_RXADDR,0x01); //使能通道0的接收地址 write_reg(NRF_WRITE_REG+SETUP_RETR,0x1a);//设置自动重发间隔时间:500us + 86us;最大自动重发次数:10次 write_reg(NRF_WRITE_REG+RF_CH,40); //设置RF通道为CHANAL write_reg(NRF_WRITE_REG+RF_SETUP,0x0f); //设置TX发射参数,0db增益,2Mbps,低噪声增益开启 write_reg(NRF_WRITE_REG+CONFIG,0x0e); //配置基本工作模式的参数;PWR_UP,EN_CRC,16BIT_CRC,发射模式,开启所有中断 ce->set();//CE为高,10us后启动发送 delay_us(10); }
/* start simulation, program loaded, processor precise state initialized */ void sim_main(void) { fprintf(stderr, "sim: ** starting *pipe* functional simulation **\n"); /* must have natural byte/word ordering */ if (sim_swap_bytes || sim_swap_words) fatal("sim: *pipe* functional simulation cannot swap bytes or words"); /* set up initial default next PC */ /* maintain $r0 semantics */ regs.regs_R[MD_REG_ZERO] = 0; regs.regs_PC -= sizeof(md_inst_t); while (TRUE) { do_if(); do_wb(); do_id(); do_ex(); do_mem(); print_env(); write_buf(); #ifndef NO_INSN_COUNT sim_num_insn++; #endif /* !NO_INSN_COUNT */ } }
/*===========================================================================* * dump_program_headers * *===========================================================================*/ PRIVATE void dump_program_headers(Elf_Phdr phdrs[], int phnum) { int i; for (i = 0; i < phnum; i++) write_buf((char *)&phdrs[i], sizeof(Elf_Phdr)); }
/* write data to destination(s) */ ssize_t write_data( const struct dstream_ctx* spc, const char* data, const ssize_t len, int fd ) { ssize_t n = 0, error = IO_ERR; int32_t n_count = -1; assert( spc && data && len ); if( fd <= 0 ) return 0; if( spc->flags & F_SCATTERED ) { n_count = spc->pkt_count; n = writev( fd, spc->pkt, n_count ); if( n <= 0 ) { if( EAGAIN == errno ) { (void)tmfprintf( g_flog, "Write on fd=[%d] timed out\n", fd); error = IO_BLK; } mperror( g_flog, errno, "%s: writev", __func__ ); return error; } } else { n = write_buf( fd, data, len, g_flog ); if( n < 0 ) error = n; } return (n > 0) ? n : error; }
/* write a i64 */ static int write_i64(int f, i64 v) { if (write_buf(f, (uchar *)&v, 8)) return -1; return 0; }
void gpfs_send_attr(stat_x *sxp, int f) { struct rsync_gpfs_attr *a = sxp->gpfs_attr; if (a && a->buf) { int ndx = (use_gpfs_attr_cache) ? gpfs_find_attr(a) : -1; /* write 1 if it was 0; means not in cache (yet), +1 */ /* +1 is to compress the GPFS_NDX_NOATTR better */ write_varint(f, ndx + 1 + 1); if (ndx < 0) { write_varint(f, a->size); write_buf(f, a->buf, a->size); } } else { /* we have no attribute for this file */ /* +1 is just because of the trivial compression * of the mostly awaited GPFS_NDX_NOATTR */ write_varint(f, GPFS_NDX_NOATTR + 1); } }
/*===========================================================================* * dump_program_headers * *===========================================================================*/ static void dump_program_headers(struct filp *f, Elf_Phdr phdrs[], int phnum) { int i; for (i = 0; i < phnum; i++) write_buf(f, (char *) &phdrs[i], sizeof(Elf_Phdr)); }
/*===========================================================================* * dump_segments * *===========================================================================*/ static void dump_segments(struct filp *f, Elf_Phdr phdrs[], int phnum) { int i; vir_bytes len; off_t off, seg_off; int r; static u8_t buf[CLICK_SIZE]; for (i = 1; i < phnum; i++) { len = phdrs[i].p_memsz; seg_off = phdrs[i].p_vaddr; if (len > LONG_MAX) { printf("VFS: segment too large to dump, truncating\n"); len = LONG_MAX; } for (off = 0; off < (off_t) len; off += CLICK_SIZE) { vir_bytes p = (vir_bytes) (seg_off + off); r = sys_datacopy_try(fp->fp_endpoint, p, SELF, (vir_bytes) buf, (phys_bytes) CLICK_SIZE); if(r != OK) { /* memory didn't exist; write as zeroes */ memset(buf, 0, sizeof(buf)); continue; } write_buf(f, (char *) buf, (off + CLICK_SIZE <= (off_t) len) ? CLICK_SIZE : (len - off)); } } }
/** Let the intermediate write request fail. The write should be retried and * finally succeed. */ TEST_F(AsyncWriteHandlerTest, IntermediateWriteFail) { size_t blocks = 5; size_t buffer_size = kBlockSize * blocks; size_t middle = blocks / 2; boost::scoped_array<char> write_buf(new char[buffer_size]()); vector<WriteEntry> expected_front(middle); vector<WriteEntry> expected_tail(blocks - middle); for (size_t i = 0; i < middle; ++i) { expected_front[i] = WriteEntry(i, 0, kBlockSize); } for (size_t i = middle; i < blocks; ++i) { expected_tail[i - middle] = WriteEntry(i, 0, kBlockSize); } test_env.osds[0]->AddDropRule( new ProcIDFilterRule(xtreemfs::pbrpc::PROC_ID_WRITE, new SkipMDropNRule(middle, 1))); ASSERT_NO_THROW(file->Write(write_buf.get(), buffer_size, 0)); ASSERT_NO_THROW(file->Flush()); EXPECT_TRUE(equal(expected_front.begin(), expected_front.end(), test_env.osds[0]->GetReceivedWrites().begin())); EXPECT_TRUE(equal(expected_tail.begin(), expected_tail.end(), test_env.osds[0]->GetReceivedWrites().end() - expected_tail.size())); ASSERT_NO_THROW(file->Close()); }
uint8_t draw_char(uint8_t start_row, uint8_t start_col, unsigned char ch, uint8_t fg_col, uint8_t bg_col, uint8_t width) { unsigned int w; unsigned int i, cpos, cnt; uint8 res = 0; // NOTE maybe print a ? or something if (ch > max_char) return 1; /* We print nothing, character not encoded */ cpos = char_pos[ch]; // Start of glyph bits in font_bits[] w = char_width(ch); // Width of the character without inter character space if (w > width) w = width; // w is now min(char_width(ch), width) // draw w columns into drawbuf // each column is copied (with correct color) to drawbuf directly from font_bits for (cnt = 0; cnt < w; cnt++, cpos+=bytes_per_col) store_buf(cnt, font_bits[cpos] | (font_bits[cpos+1] << 8), fg_col, bg_col); if ( (width - cnt) >= ic_space ){ for (i=0; i<ic_space; i++) store_buf(cnt++, 0, fg_col, bg_col); // inter character space res = cnt; }; write_buf(start_row, start_col, cnt, font_height); return res; }
static void stream_chargen( const struct server *serp ) { char line_buf[ LINE_LENGTH+2 ] ; int descriptor = SERVER_FD( serp ) ; struct service *svc = SERVER_SERVICE( serp ); if( SVC_WAITS( svc ) ) { descriptor = accept(descriptor, NULL, NULL); if ( descriptor == -1 ) { if ((errno == EMFILE) || (errno == ENFILE)) cps_service_stop(svc, "no available descriptors"); return; } } (void) shutdown( descriptor, 0 ) ; close_all_svc_descriptors(); for ( ;; ) { if ( generate_line( line_buf, sizeof( line_buf ) ) == NULL ) break ; if ( write_buf( descriptor, line_buf, sizeof( line_buf ) ) == FAILED ) break ; } if( SVC_WAITS( svc ) ) /* Service forks, so close it */ Sclose(descriptor); }
static void* read_sent_data_copy(void *arg) { int ret; struct btrfs_send *sctx = (struct btrfs_send*)arg; char buf[SEND_BUFFER_SIZE]; while (1) { ssize_t rbytes; rbytes = read(sctx->send_fd, buf, sizeof(buf)); if (rbytes < 0) { ret = -errno; error("failed to read stream from kernel: %s", strerror(-ret)); goto out; } if (!rbytes) { ret = 0; goto out; } ret = write_buf(sctx->dump_fd, buf, rbytes); if (ret < 0) goto out; } out: if (ret < 0) exit(-ret); return ERR_PTR(ret); }
static void *dump_thread(void *arg_) { int ret; struct btrfs_send *s = (struct btrfs_send*)arg_; char buf[4096]; int readed; while (1) { readed = read(s->send_fd, buf, sizeof(buf)); if (readed < 0) { ret = -errno; error("failed to read stream from kernel: %s\n", strerror(-ret)); goto out; } if (!readed) { ret = 0; goto out; } ret = write_buf(s->dump_fd, buf, readed); if (ret < 0) goto out; } out: if (ret < 0) { exit(-ret); } return ERR_PTR(ret); }
int lb_writestr_all(char **buf, int size, struct LineBuffer* lb) { if(lb->eol == 0) return 0; int eol = last_eol(lb); int n = write_buf(*buf, size, lb->line, eol); *buf += n; lb->eol = n; // pretend this was the first one. so update clears it and looks for next. return update_w(lb, n); }
void keyboard_handler() { disable_interrupts(); write_buf(inb(KEYBOARD_PORT)); outb(INT_CTL_REG, INT_CTL_DONE); enable_interrupts(); }
/*===========================================================================* * dump_notes * *===========================================================================*/ PRIVATE void dump_notes(Elf_Nhdr nhdrs[], int csig, char *exe_name) { char *note_name = ELF_NOTE_MINIX_ELFCORE_NAME "\0"; char pad[4]; minix_elfcore_info_t mei; int mei_len = sizeof(minix_elfcore_info_t); int gregs_len = sizeof(gregset_t); struct stackframe_s regs; char proc_name[PROC_NAME_LEN]; /* Get process's name */ if (sys_datacopy(PM_PROC_NR, (vir_bytes) exe_name, VFS_PROC_NR, (vir_bytes) proc_name, PROC_NAME_LEN) != OK) printf("VFS: Cannot get process's name\n"); /* Dump first note entry */ mei.mei_version = MINIX_ELFCORE_VERSION; mei.mei_meisize = mei_len; mei.mei_signo = csig; mei.mei_pid = fp->fp_pid; memcpy(mei.mei_command, proc_name, sizeof(mei.mei_command)); write_buf((char *)&nhdrs[0], sizeof(Elf_Nhdr)); write_buf(note_name, nhdrs[0].n_namesz); write_buf(pad, PAD_LEN(nhdrs[0].n_namesz) - nhdrs[0].n_namesz); write_buf((char *)&mei, mei_len); write_buf(pad, PAD_LEN(mei_len) - mei_len); /* Get registers */ if (sys_getregs(®s, fp->fp_endpoint) != OK) printf("VFS: Could not read registers\n"); if (sizeof(regs) != gregs_len) printf("VFS: Wrong core register structure size\n"); /* Dump second note entry - the general registers */ write_buf((char *)&nhdrs[1], sizeof(Elf_Nhdr)); write_buf(note_name, nhdrs[1].n_namesz); write_buf(pad, PAD_LEN(nhdrs[1].n_namesz) - nhdrs[1].n_namesz); write_buf((char *)®s, gregs_len); write_buf(pad, PAD_LEN(gregs_len) - gregs_len); }
static int lzo_wwrite_block(const char *buffer, off_t len, struct buffer_t *outbuf) { char b2[MAX_BUFFER_SIZE]; int err; lzo_uint dst_len; char scratch[LZO1X_1_MEM_COMPRESS]; outbuf->offset=0; memset(scratch,0,sizeof(scratch)); err=lzo1x_1_compress((void*)buffer, len, (void*)b2, &dst_len, scratch); switch(err) { case LZO_E_OK: break; case LZO_E_ERROR: return -EINVAL; /* WTF? */ case LZO_E_OUT_OF_MEMORY: return -ENOMEM; /* Uh oh */ case LZO_E_NOT_COMPRESSIBLE: return -EINVAL; /* Claimed not to be used, dunno what we'll do */ case LZO_E_INPUT_OVERRUN: return -EINVAL; /* Can't happen on compress? */ case LZO_E_OUTPUT_OVERRUN: return -ENOMEM; case LZO_E_LOOKBEHIND_OVERRUN: return -EINVAL; case LZO_E_EOF_NOT_FOUND: return -ENOENT; /* Can't happen on compress? */ case LZO_E_INPUT_NOT_CONSUMED: return -EINVAL; case LZO_E_NOT_YET_IMPLEMENTED: return -ENOSYS; default: fprintf(stderr,"Unknown lzo error %d\n",err); return -EINVAL; } write32(outbuf, len); /* Original length */ write32(outbuf, min((uint32_t)len,(uint32_t)dst_len)); /* CRC32 of the uncompressed buffer */ #if 0 write32(outbuf, lzo_crc32(CRC32_INIT_VALUE, (void*)buffer, len)); #endif write32(outbuf, lzo_adler32(ADLER32_INIT_VALUE, (const void*)buffer, len)); write_buf(outbuf, b2, dst_len); /* Return the number of bytes compressed */ return len; }
void send_protected_args(int fd, char *args[]) { int i; #ifdef ICONV_OPTION int convert = ic_send != (iconv_t)-1; xbuf outbuf, inbuf; if (convert) alloc_xbuf(&outbuf, 1024); #endif for (i = 0; args[i]; i++) {} /* find first NULL */ args[i] = "rsync"; /* set a new arg0 */ if (DEBUG_GTE(CMD, 1)) print_child_argv("protected args:", args + i + 1); do { if (!args[i][0]) write_buf(fd, ".", 2); #ifdef ICONV_OPTION else if (convert) { INIT_XBUF_STRLEN(inbuf, args[i]); iconvbufs(ic_send, &inbuf, &outbuf, ICB_EXPAND_OUT | ICB_INCLUDE_BAD | ICB_INCLUDE_INCOMPLETE | ICB_INIT); outbuf.buf[outbuf.len] = '\0'; write_buf(fd, outbuf.buf, outbuf.len + 1); outbuf.len = 0; } #endif else write_buf(fd, args[i], strlen(args[i]) + 1); } while (args[++i]); write_byte(fd, 0); #ifdef ICONV_OPTION if (convert) free(outbuf.buf); #endif }
rv_t inomap_dump( drive_t *drivep ) { seg_addr_t addr; hnk_t *hnkp; hnk_t tmphnkp; /* use write_buf to dump the hunks */ for ( addr.hnkoff = 0 ; addr.hnkoff <= inomap.lastseg.hnkoff ; addr.hnkoff++ ) { intgen_t rval; rv_t rv; drive_ops_t *dop = drivep->d_opsp; hnkp = inomap_addr2hnk( &addr ); xlate_hnk(hnkp, &tmphnkp, 1); rval = write_buf( ( char * )&tmphnkp, sizeof( tmphnkp ), ( void * )drivep, ( gwbfp_t )dop->do_get_write_buf, ( wfp_t )dop->do_write ); switch ( rval ) { case 0: rv = RV_OK; break; case DRIVE_ERROR_MEDIA: case DRIVE_ERROR_EOM: rv = RV_EOM; break; case DRIVE_ERROR_EOF: rv = RV_EOF; break; case DRIVE_ERROR_DEVICE: rv = RV_DRIVE; break; case DRIVE_ERROR_CORE: default: rv = RV_CORE; break; } if ( rv != RV_OK ) { return rv; } } return RV_OK; }
/* send a sums struct down a fd */ static void send_sums(struct sum_struct *s,int f_out) { int i; /* tell the other guy how many we are going to be doing and how many bytes there are in the last chunk */ write_int(f_out,s?s->count:0); write_int(f_out,s?s->n:block_size); write_int(f_out,s?s->remainder:0); if (s) for (i=0;i<s->count;i++) { write_int(f_out,s->sums[i].sum1); write_buf(f_out,s->sums[i].sum2,csum_length); } }
/* flush out any data in a stream buffer. Return -1 on failure */ static int flush_buffer(struct stream_info *sinfo, int stream) { int c_type = CTYPE_NONE; i64 c_len = sinfo->s[stream].buflen; if (seekto(sinfo, sinfo->s[stream].last_head) != 0) return -1; if (write_i64(sinfo->fd, sinfo->cur_pos) != 0) return -1; sinfo->s[stream].last_head = sinfo->cur_pos + 17; if (seekto(sinfo, sinfo->cur_pos) != 0) return -1; if (!(control.flags & FLAG_NO_COMPRESS)) { if (LZMA_COMPRESS(control.flags)) lzma_compress_buf(&sinfo->s[stream], &c_type, &c_len); else if (control.flags & FLAG_LZO_COMPRESS) lzo_compress_buf(&sinfo->s[stream], &c_type, &c_len); else if (control.flags & FLAG_BZIP2_COMPRESS) bzip2_compress_buf(&sinfo->s[stream], &c_type, &c_len); else if (control.flags & FLAG_ZLIB_COMPRESS) gzip_compress_buf(&sinfo->s[stream], &c_type, &c_len); else if (control.flags & FLAG_ZPAQ_COMPRESS) zpaq_compress_buf(&sinfo->s[stream], &c_type, &c_len); else fatal("Dunno wtf compression to use!\n"); } if (write_u8(sinfo->fd, c_type) != 0 || write_i64(sinfo->fd, c_len) != 0 || write_i64(sinfo->fd, sinfo->s[stream].buflen) != 0 || write_i64(sinfo->fd, 0) != 0) { return -1; } sinfo->cur_pos += 25; if (write_buf(sinfo->fd, sinfo->s[stream].buf, c_len) != 0) return -1; sinfo->cur_pos += c_len; sinfo->s[stream].buflen = 0; free(sinfo->s[stream].buf); sinfo->s[stream].buf = malloc(sinfo->bufsize); if (!sinfo->s[stream].buf) return -1; return 0; }
/* write RTP record into TS stream */ static ssize_t write_rtp2ts( int fd, const char* data, size_t len, FILE* log ) { void* buf = (void*)data; size_t pldlen = len; const int NO_VERIFY = 0; int rc = 0; assert( (fd > 0) && data && len && log ); rc = RTP_process( &buf, &pldlen, NO_VERIFY, log ); if( -1 == rc ) return -1; assert( !buf_overrun( buf, len, 0, pldlen, log ) ); return write_buf( fd, buf, pldlen, log ); }
int main (void) { int fd; char buf [256]; int i; if ((fd = open ("/tmp/test", O_RDWR | O_CREAT | O_TRUNC, FILE_PERMS)) == -1) { err_msg ("Can't open temp file"); } for (i = 0; i < 100000; i++) write_buf (fd, buf, sizeof (buf)); close (fd); return (0); }