- Timestamp:
- 04/20/10 14:08:27 (12 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- 5b8f9ee
- Parents:
- 8ed31c2
- Location:
- lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/iow-stdio.c
r22cdd39 rbaef9df 59 59 #define DATA(iow) ((struct stdiow_t *)((iow)->data)) 60 60 61 static int safe_open(const char *filename )61 static int safe_open(const char *filename, int flags) 62 62 { 63 63 int fd; … … 65 65 #ifdef O_DIRECT 66 66 fd = open(filename, 67 O_WRONLY 67 flags 68 |O_WRONLY 68 69 |O_CREAT 69 70 |O_TRUNC … … 75 76 /* If that failed (or we don't support O_DIRECT) try opening without */ 76 77 fd = open(filename, 77 O_WRONLY 78 flags 79 |O_WRONLY 78 80 |O_CREAT 79 81 |O_TRUNC, … … 84 86 } 85 87 86 iow_t *stdio_wopen(const char *filename )88 iow_t *stdio_wopen(const char *filename,int flags) 87 89 { 88 90 iow_t *iow = malloc(sizeof(iow_t)); … … 93 95 DATA(iow)->fd = 1; /* STDOUT */ 94 96 else { 95 DATA(iow)->fd = safe_open(filename );97 DATA(iow)->fd = safe_open(filename, flags); 96 98 } 97 99 -
lib/wandio.c
rb5af22c rbaef9df 112 112 #define READ_TRACE 0 113 113 #define WRITE_TRACE 0 114 #define PIPELINE_TRACE 0 115 116 #if PIPELINE_TRACE 117 #define DEBUG_PIPELINE(x) fprintf(stderr,"PIPELINE: %s\n",x) 118 #else 119 #define DEBUG_PIPELINE(x) 120 #endif 114 121 115 122 io_t *wandio_create(const char *filename) … … 121 128 * the file */ 122 129 130 DEBUG_PIPELINE("stdio"); 131 DEBUG_PIPELINE("peek"); 123 132 io_t *io = peek_open(stdio_open(filename)); 124 133 char buffer[1024]; … … 130 139 /* Auto detect gzip compressed data */ 131 140 if (len>=2 && buffer[0] == '\037' && buffer[1] == '\213') { 141 DEBUG_PIPELINE("zlib"); 132 142 io = zlib_open(io); 133 143 } 134 144 /* Auto detect compress(1) compressed data (gzip can read this) */ 135 145 if (len>=2 && buffer[0] == '\037' && buffer[1] == '\235') { 146 DEBUG_PIPELINE("zlib"); 136 147 io = zlib_open(io); 137 148 } … … 140 151 /* Auto detect bzip compressed data */ 141 152 if (len>=3 && buffer[0] == 'B' && buffer[1] == 'Z' && buffer[2] == 'h') { 153 DEBUG_PIPELINE("bzip"); 142 154 io = bz_open(io); 143 155 } … … 147 159 * to read the data */ 148 160 149 if (use_threads) 161 if (use_threads) { 162 DEBUG_PIPELINE("thread"); 150 163 io = thread_open(io); 164 } 151 165 166 DEBUG_PIPELINE("peek"); 152 167 return peek_open(io); 153 168 } … … 174 189 { 175 190 off_t ret; 191 ret=io->source->read(io,buffer,len); 176 192 #if READ_TRACE 177 fprintf(stderr,"read(%s): %d bytes\n",io->source->name, (int)len); 178 #endif 179 ret=io->source->read(io,buffer,len); 193 fprintf(stderr,"%p: read(%s): %d bytes = %d\n",io,io->source->name, (int)len,(int)ret); 194 #endif 180 195 return ret; 181 196 } … … 207 222 assert ( compression_level >= 0 && compression_level <= 9 ); 208 223 209 iow=stdio_wopen(filename );224 iow=stdio_wopen(filename, flags); 210 225 211 226 /* We prefer zlib if available, otherwise we'll use bzip. If neither -
lib/wandio.h
rb5af22c rbaef9df 60 60 const char *ext; 61 61 /** Internal type identifying the compression method */ 62 int compress_ flag;62 int compress_type; 63 63 }; 64 64 … … 187 187 iow_t *lzo_wopen(iow_t *child, int compress_level); 188 188 iow_t *thread_wopen(iow_t *child); 189 iow_t *stdio_wopen(const char *filename );189 iow_t *stdio_wopen(const char *filename, int fileflags); 190 190 191 191 /* @} */
Note: See TracChangeset
for help on using the changeset viewer.