public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "jjtsai" <jjtsai@itri.org.tw>
To: <ecos-discuss@sources.redhat.com>
Subject: [ECOS] [eCos] a question about ROMFS
Date: Mon, 16 Jul 2001 00:47:00 -0000	[thread overview]
Message-ID: <005701c10dcb$d2cc2180$8c78608c@ccl.itri.org.tw> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 655 bytes --]

Hi, 
    I have a question about ROM files 
system.
 
[Question Description]
    A fseek(,,SEEK_CUR) after fread() will 
cause inconsistency between "(CYG_StdioStream) 
real_stream.position"
    and "fp->f_offset". See also 
stream.inl and rom_fs.c.
    
    Here is my test program. See 
attchment: fseek_test.c  .
 
[My modfication]
 
See attachment: stream_inl_patch.pat.
Instruction about how to apply it: cd 
$(ECOS_REPOSITORY)/packages/language/c/libc/stdio/current/include patch -p0 
< $(WHERE_THE_PATCH_IS)/stream_inl_patch.pat
regards,
Jang-Jer
fseek_test.c
stream_inl_patch.pat


[-- Attachment #2: fseek_test.c --]
[-- Type: text/x-c, Size: 1464 bytes --]

#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <cyg/fileio/fileio.h>
#include <pkgconf/fs_rom.h>	// Address of ROMFS

//==========================================================================

MTAB_ENTRY( romfs_mte1,
                   "/",
                   "romfs",
                   "",
                   (CYG_ADDRWORD) CYGNUM_FS_ROM_BASE_ADDRESS );

//==========================================================================
// main

int main( int argc, char **argv )
{
    FILE *fd;
    int err;
    int i;
    int length;
    char s[1000];
    struct stat sbuf;
    
    stat("/HelloWorld.jar", &sbuf);

    printf("leng=%d\n",sbuf.st_size);  

    if( (fd=fopen("/HelloWorld.jar","rw")) == NULL)
	printf("fopen error\n");
    else {
	length=0;

	do{
	err=ftell(fd); printf("ftell=%d\n",err); //ftell should return 0;

	if( (err=fseek(fd, 195, SEEK_SET))<0)
		printf("fseek=%d\n",err);

	err=ftell(fd); printf("ftell=%d\n",err); //ftell should return 195

	if( (err=fread((s+length),sizeof(char), 30, fd))!=30) 
		printf("fread=%d\n",err);

	err=ftell(fd); printf("ftell=%d\n",err); //ftell should return 225

	if( (err=fseek(fd, 0, SEEK_CUR))<0)
		printf("fseek=%d\n",err);

	err=ftell(fd); printf("ftell=%d\n",err); //ftell should return 225

	if( (err=fseek(fd, 1, SEEK_CUR))<0)
		printf("fseek=%d\n",err);

	err=ftell(fd); printf("ftell=%d\n",err); //ftell should return 226

	}
	while(0);

	fclose(fd);
	}

    return 0;

}


[-- Attachment #3: stream_inl_patch.pat --]
[-- Type: text/x-diff, Size: 566 bytes --]

--- stream.inl	Sat Apr  7 01:20:40 2001
+++ stream.inl.my	Mon Jul 16 14:37:34 2001
@@ -406,7 +406,16 @@
     if (!lock_me())
         return EBADF; // assume file is now invalid
 
-    err = cyg_stdio_lseek( my_device, &newpos, whence );
+    //add jjt
+    if( whence == SEEK_CUR ){ 
+	newpos = position + pos;
+	err = cyg_stdio_lseek( my_device, &newpos, SEEK_SET);
+	}
+    else {
+    	err = cyg_stdio_lseek( my_device, &newpos, whence );
+	}
+    //end jjt
+    //err = cyg_stdio_lseek( my_device, &newpos, whence ); //del jjt
 
     if( err == ENOERR )
     {

             reply	other threads:[~2001-07-16  0:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-16  0:47 jjtsai [this message]
2001-07-16 14:01 ` Jonathan Larmour
2001-07-17  0:11   ` jjtsai
2001-07-17 13:09     ` Jonathan Larmour
2001-07-18  0:07       ` jjtsai
2001-07-19 23:42         ` Jonathan Larmour

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='005701c10dcb$d2cc2180$8c78608c@ccl.itri.org.tw' \
    --to=jjtsai@itri.org.tw \
    --cc=ecos-discuss@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).