Changes in uspace/lib/c/generic/io/io.c [82582e4:0803134] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/io/io.c
r82582e4 r0803134 44 44 #include <io/klog.h> 45 45 #include <vfs/vfs.h> 46 #include <vfs/vfs_sess.h> 46 47 #include <ipc/devmap.h> 47 48 #include <adt/list.h> 48 49 #include "../private/io.h" 50 #include "../private/stdio.h" 49 51 50 52 static void _ffillbuf(FILE *stream); … … 56 58 .eof = true, 57 59 .klog = false, 58 . phone = -1,60 .sess = NULL, 59 61 .btype = _IONBF, 60 62 .buf = NULL, … … 70 72 .eof = false, 71 73 .klog = true, 72 . phone = -1,74 .sess = NULL, 73 75 .btype = _IOLBF, 74 76 .buf = NULL, … … 84 86 .eof = false, 85 87 .klog = true, 86 . phone = -1,88 .sess = NULL, 87 89 .btype = _IONBF, 88 90 .buf = NULL, … … 125 127 void __stdio_done(void) 126 128 { 127 link_t *link = files.next; 128 129 while (link != &files) { 130 FILE *file = list_get_instance(link, FILE, link); 129 while (!list_empty(&files)) { 130 FILE *file = list_get_instance(list_first(&files), FILE, link); 131 131 fclose(file); 132 link = files.next;133 132 } 134 133 } … … 255 254 stream->eof = false; 256 255 stream->klog = false; 257 stream-> phone = -1;256 stream->sess = NULL; 258 257 stream->need_sync = false; 259 258 _setvbuf(stream); … … 277 276 stream->eof = false; 278 277 stream->klog = false; 279 stream-> phone = -1;278 stream->sess = NULL; 280 279 stream->need_sync = false; 281 280 _setvbuf(stream); … … 309 308 stream->eof = false; 310 309 stream->klog = false; 311 stream-> phone = -1;310 stream->sess = NULL; 312 311 stream->need_sync = false; 313 312 _setvbuf(stream); … … 324 323 fflush(stream); 325 324 326 if (stream-> phone >= 0)327 async_hangup(stream-> phone);325 if (stream->sess != NULL) 326 async_hangup(stream->sess); 328 327 329 328 if (stream->fd >= 0) … … 595 594 } 596 595 597 buf+= now;596 data += now; 598 597 stream->buf_head += now; 599 598 buf_free -= now; 600 599 bytes_left -= now; 601 600 total_written += now; 601 stream->buf_state = _bs_write; 602 602 603 603 if (buf_free == 0) { … … 607 607 } 608 608 } 609 610 if (total_written > 0)611 stream->buf_state = _bs_write;612 609 613 610 if (need_flush) … … 715 712 off64_t ftell(FILE *stream) 716 713 { 714 _fflushbuf(stream); 717 715 return lseek(stream->fd, 0, SEEK_CUR); 718 716 } … … 732 730 } 733 731 734 if ( stream->fd >= 0 && stream->need_sync) {732 if ((stream->fd >= 0) && (stream->need_sync)) { 735 733 /** 736 734 * Better than syncing always, but probably still not the … … 770 768 } 771 769 772 int fphone(FILE *stream)770 async_sess_t *fsession(exch_mgmt_t mgmt, FILE *stream) 773 771 { 774 772 if (stream->fd >= 0) { 775 if (stream-> phone < 0)776 stream-> phone = fd_phone(stream->fd);777 778 return stream-> phone;779 } 780 781 return -1;773 if (stream->sess == NULL) 774 stream->sess = fd_session(mgmt, stream->fd); 775 776 return stream->sess; 777 } 778 779 return NULL; 782 780 } 783 781
Note:
See TracChangeset
for help on using the changeset viewer.