@@ -2045,11 +2045,11 @@ struct NVNode * nvp_get_node(const char *path, struct stat *file_st, int result)
20452045 node -> is_large_file = 0 ;
20462046 node -> dr_mem_used = 0 ;
20472047 if (node -> true_length == 0 ) {
2048- clear_tbl_mmap_entry (& _nvp_tbl_mmaps [file_st -> st_ino % APPEND_TBL_MAX ]);
2048+ clear_tbl_mmap_entry (& _nvp_tbl_mmaps [file_st -> st_ino % APPEND_TBL_MAX ], NUM_APP_TBL_MMAP_ENTRIES );
20492049
20502050#if DATA_JOURNALING_ENABLED
20512051
2052- clear_tbl_mmap_entry (& _nvp_over_tbl_mmaps [file_st -> st_ino % OVER_TBL_MAX ]);
2052+ clear_tbl_mmap_entry (& _nvp_over_tbl_mmaps [file_st -> st_ino % OVER_TBL_MAX ], NUM_OVER_TBL_MMAP_ENTRIES );
20532053
20542054#endif // DATA_JOURNALING_ENABLED
20552055
@@ -4994,6 +4994,55 @@ RETT_EXECV _nvp_EXECV(INTF_EXECV) {
49944994 return _nvp_fileops -> EXECV (CALL_EXECV );
49954995}
49964996
4997+ #ifdef TRACE_FP_CALLS
4998+ RETT_FEOF _nvp_FEOF (INTF_FEOF )
4999+ {
5000+ CHECK_RESOLVE_FILEOPS (_nvp_ );
5001+ RETT_FEOF result ;
5002+
5003+ struct NVFile * nvf = & _nvp_fd_lookup [fileno (fp )];
5004+
5005+ NVP_LOCK_NODE_WR (nvf );
5006+ NVP_LOCK_FD_WR (nvf );
5007+ result = (nvf -> file_stream_flags & NVP_IO_EOF_SEEN ) > 0 ;
5008+ NVP_UNLOCK_NODE_WR (nvf );
5009+ NVP_UNLOCK_FD_WR (nvf );
5010+ return result ;
5011+ }
5012+ #endif
5013+
5014+ #ifdef TRACE_FP_CALLS
5015+ RETT_FERROR _nvp_FERROR (INTF_FERROR )
5016+ {
5017+ CHECK_RESOLVE_FILEOPS (_nvp_ );
5018+ RETT_FERROR result ;
5019+
5020+ struct NVFile * nvf = & _nvp_fd_lookup [fileno (fp )];
5021+ NVP_LOCK_NODE_WR (nvf );
5022+ NVP_LOCK_FD_WR (nvf );
5023+ result = (nvf -> file_stream_flags & NVP_IO_ERR_SEEN ) > 0 ;
5024+ NVP_UNLOCK_NODE_WR (nvf );
5025+ NVP_UNLOCK_FD_WR (nvf );
5026+ return result ;
5027+ }
5028+ #endif
5029+
5030+ #ifdef TRACE_FP_CALLS
5031+ RETT_CLEARERR _nvp_CLEARERR (INTF_CLEARERR )
5032+ {
5033+ CHECK_RESOLVE_FILEOPS (_nvp_ );
5034+ int fd = -1 ;
5035+
5036+ struct NVFile * nvf = & _nvp_fd_lookup [fileno (fp )];
5037+
5038+ NVP_LOCK_NODE_WR (nvf );
5039+ NVP_LOCK_FD_WR (nvf );
5040+ nvf -> file_stream_flags &= ~(NVP_IO_ERR_SEEN | NVP_IO_EOF_SEEN );
5041+ NVP_UNLOCK_NODE_WR (nvf );
5042+ NVP_UNLOCK_FD_WR (nvf );
5043+ }
5044+ #endif
5045+
49975046#ifdef TRACE_FP_CALLS
49985047RETT_FCLOSE _nvp_FCLOSE (INTF_FCLOSE )
49995048{
@@ -5064,7 +5113,7 @@ RETT_FREAD _nvp_FREAD(INTF_FREAD)
50645113 result = _nvp_do_pread (fileno (fp ),
50655114 buf ,
50665115 length * nmemb ,
5067- __sync_fetch_and_add (nvf -> offset , length ),
5116+ __sync_fetch_and_add (nvf -> offset , ( length * nmemb ) ),
50685117 0 ,
50695118 cpuid ,
50705119 nvf ,
@@ -5081,19 +5130,24 @@ RETT_FREAD _nvp_FREAD(INTF_FREAD)
50815130 DEBUG ("_nvp_READ: PREAD failed; not changing offset. "
50825131 "(returned %i)\n" , result );
50835132 //assert(0); // TODO: this is for testing only
5084- __sync_fetch_and_sub (nvf -> offset , length );
5133+ __sync_fetch_and_sub (nvf -> offset , (length * nmemb ));
5134+ if (result < 0 )
5135+ nvf -> file_stream_flags |= NVP_IO_ERR_SEEN ;
5136+ else
5137+ nvf -> file_stream_flags |= NVP_IO_EOF_SEEN ;
50855138 } else {
50865139 DEBUG ("_nvp_READ: PREAD failed; Not fully read. "
50875140 "(returned %i)\n" , result );
50885141 // assert(0); // TODO: this is for testing only
5089- __sync_fetch_and_sub (nvf -> offset , length - result );
5142+ __sync_fetch_and_sub (nvf -> offset , (length * nmemb ) - result );
5143+ nvf -> file_stream_flags |= NVP_IO_EOF_SEEN ;
50905144 }
50915145
50925146 NVP_UNLOCK_FD_RD (nvf , cpuid );
50935147
50945148 num_read ++ ;
50955149 read_size += result ;
5096-
5150+ result = result / length ;
50975151 return result ;
50985152}
50995153#endif
@@ -5252,7 +5306,7 @@ RETT_FWRITE _nvp_FWRITE(INTF_FWRITE)
52525306 result = _nvp_do_pwrite (fileno (fp ),
52535307 buf ,
52545308 length * nmemb ,
5255- __sync_fetch_and_add (nvf -> offset , length ),
5309+ __sync_fetch_and_add (nvf -> offset , ( length * nmemb ) ),
52565310 0 ,
52575311 cpuid ,
52585312 nvf ,
@@ -5265,6 +5319,7 @@ RETT_FWRITE _nvp_FWRITE(INTF_FWRITE)
52655319 nvf -> node -> maplength );
52665320
52675321 write_size += result ;
5322+ result = result /length ;
52685323 return result ;
52695324}
52705325#endif
@@ -5761,8 +5816,8 @@ RETT_FTRUNC64 _nvp_FTRUNC64(INTF_FTRUNC64)
57615816 if (nvf -> node -> true_length >= LARGE_FILE_THRESHOLD )
57625817 nvf -> node -> is_large_file = 1 ;
57635818 START_TIMING (clear_mmap_tbl_t , clear_mmap_tbl_time );
5764- clear_tbl_mmap_entry (tbl_app );
5765- clear_tbl_mmap_entry (tbl_over );
5819+ clear_tbl_mmap_entry (tbl_app , NUM_APP_TBL_MMAP_ENTRIES );
5820+ clear_tbl_mmap_entry (tbl_over , NUM_OVER_TBL_MMAP_ENTRIES );
57665821 END_TIMING (clear_mmap_tbl_t , clear_mmap_tbl_time );
57675822
57685823 if (tbl_over != NULL )
@@ -6111,11 +6166,11 @@ RETT_UNLINK _nvp_UNLINK(INTF_UNLINK)
61116166 if (tbl_over != NULL ) {
61126167 TBL_ENTRY_LOCK_WR (tbl_over );
61136168 }
6114- clear_tbl_mmap_entry (tbl_app );
6169+ clear_tbl_mmap_entry (tbl_app , NUM_APP_TBL_MMAP_ENTRIES );
61156170
61166171#if DATA_JOURNALING_ENABLED
61176172
6118- clear_tbl_mmap_entry (tbl_over );
6173+ clear_tbl_mmap_entry (tbl_over , NUM_OVER_TBL_MMAP_ENTRIES );
61196174
61206175#endif // DATA_JOURNALING_ENABLED
61216176
0 commit comments