This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: fseek on JFFS2


Jonathan Larmour wrote:

I agree with your analysis, but I think I would prefer a fix like:


Index: include/stream.inl
===================================================================
RCS file: /cvs/ecos/ecos/packages/language/c/libc/stdio/current/include/stream.inl,v
retrieving revision 1.7
diff -u -5 -p -r1.7 stream.inl
--- include/stream.inl 29 Mar 2004 11:24:38 -0000 1.7
+++ include/stream.inl 27 Sep 2006 15:14:52 -0000
@@ -440,10 +440,11 @@ Cyg_StdioStream::set_position( fpos_t po
return ENOERR;
} // endif (bytesavail > posdiff)


         if (whence == SEEK_CUR) {
             position += bytesavail;
+            pos -= bytesavail;
         }
     } //endif (whence != SEEK_END)

Cyg_ErrNo err;

What do you think?

Actually since at worst it doesn't cause any test regressions, I'll check it in, because I'm an optimist. Full patch attached.


Jifl
--
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
------["The best things in life aren't things."]------      Opinions==mine
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/language/c/libc/stdio/current/ChangeLog,v
retrieving revision 1.32.10004.9
diff -u -5 -p -r1.32.10004.9 ChangeLog
--- ChangeLog	26 Sep 2006 18:47:19 -0000	1.32.10004.9
+++ ChangeLog	27 Sep 2006 16:16:05 -0000
@@ -1,5 +1,15 @@
+2006-09-27  Jonathan Larmour  <jifl@eCosCentric.com>
+
+	* include/stdio.h: Make fpos_t be signed to allow negative
+	SEEK_CUR offsets to fseek().
+	* include/stream.inl (set_position): If SEEK_CUR, then if
+	having to reconcile difference between position and underlying
+	file position, then requested seek position needs adjusting
+	for buffer size.
+	Both above reported and analysed by Ivan Djelic.
+
 2006-09-26  Jonathan Larmour  <jifl@eCosCentric.com>
 
 	* src/common/stream.cxx (read): Only update position after direct
 	reads from I/O system so it's updated by the correct number of
 	bytes.
Index: include/stdio.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/language/c/libc/stdio/current/include/stdio.h,v
retrieving revision 1.6.10012.1
diff -u -5 -p -r1.6.10012.1 stdio.h
--- include/stdio.h	14 Sep 2006 12:21:43 -0000	1.6.10012.1
+++ include/stdio.h	27 Sep 2006 16:16:06 -0000
@@ -87,11 +87,11 @@
 
 // TYPE DEFINITIONS
 
 // A type capable of specifying uniquely every file position - ISO C
 // standard chap 7.9.1
-typedef cyg_ucount32 fpos_t;
+typedef cyg_count32 fpos_t;
 
 
 // FILE is just cast to an address here. It is uncast internally to the
 // C library in stream.hxx  as the C++ Cyg_StdioStream class.
 // Optional run-time checking can be enabled to ensure that the cast is
Index: include/stream.inl
===================================================================
RCS file: /cvs/ecos/ecos/packages/language/c/libc/stdio/current/include/stream.inl,v
retrieving revision 1.7
diff -u -5 -p -r1.7 stream.inl
--- include/stream.inl	29 Mar 2004 11:24:38 -0000	1.7
+++ include/stream.inl	27 Sep 2006 16:16:06 -0000
@@ -440,10 +440,11 @@ Cyg_StdioStream::set_position( fpos_t po
             return ENOERR;
         } // endif (bytesavail > posdiff)
 
         if (whence == SEEK_CUR) {
             position += bytesavail;
+            pos -= bytesavail;
         }
     } //endif (whence != SEEK_END)
 
     Cyg_ErrNo err;
 

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]