From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sc8-sf-mx2-b.sourceforge.net ([10.3.1.92] helo=mail.sourceforge.net) by sc8-sf-list1-new.sourceforge.net with esmtp (Exim 4.43) id 1GDIUM-0000Hf-Ab for user-mode-linux-devel@lists.sourceforge.net; Wed, 16 Aug 2006 03:19:06 -0700 Received: from nf-out-0910.google.com ([64.233.182.189]) by mail.sourceforge.net with esmtp (Exim 4.44) id 1GDIUK-0000Yq-B5 for user-mode-linux-devel@lists.sourceforge.net; Wed, 16 Aug 2006 03:19:06 -0700 Received: by nf-out-0910.google.com with SMTP id l36so555832nfa for ; Wed, 16 Aug 2006 03:19:02 -0700 (PDT) Message-ID: <39134b110608160319i50ea43d8kd955ef1405da939a@mail.gmail.com> Date: Wed, 16 Aug 2006 18:19:01 +0800 From: "wang lianwei" In-Reply-To: <200608151947.54925.blaisorblade@yahoo.it> MIME-Version: 1.0 References: <39134b110608100842p5acdf798o807b48801ea9a706@mail.gmail.com> <200608122022.42389.blaisorblade@yahoo.it> <39134b110608140407n718d0cf5rfed71f8295ea43e0@mail.gmail.com> <200608151947.54925.blaisorblade@yahoo.it> Subject: Re: [uml-devel] UML hostfs bugs List-Id: The user-mode Linux development list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============1640501755==" Sender: user-mode-linux-devel-bounces@lists.sourceforge.net Errors-To: user-mode-linux-devel-bounces@lists.sourceforge.net To: Blaisorblade Cc: Jeff Dike , user-mode-linux-devel@lists.sourceforge.net --===============1640501755== Content-Type: multipart/alternative; boundary="----=_Part_235439_11416407.1155723541802" ------=_Part_235439_11416407.1155723541802 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline yes, you are right. see this patches. diff -urNp linux-2.6.10/fs/hostfs/hostfs.h linux-2.6.10-src /fs/hostfs/hostfs.h --- linux-2.6.10/fs/hostfs/hostfs.h 2006-04-12 15:12:51.000000000 +0800 +++ linux-2.6.10-src/fs/hostfs/hostfs.h 2006-08-16 15:58:59.149590168+0800 @@ -40,6 +40,7 @@ extern int access_file(char *path, int r extern int open_file(char *path, int r, int w, int append); extern int file_type(const char *path, int *maj, int *min); extern void *open_dir(char *path, int *err_out); +extern void seek_dir(void *stream, unsigned long long pos); extern char *read_dir(void *stream, unsigned long long *pos, unsigned long long *ino_out, int *len_out); extern void close_file(void *stream); diff -urNp linux-2.6.10/fs/hostfs/hostfs_kern.c linux-2.6.10-src /fs/hostfs/hostfs_kern.c --- linux-2.6.10/fs/hostfs/hostfs_kern.c 2006-04-12 15:12:51.000000000 +0800 +++ linux-2.6.10-src/fs/hostfs/hostfs_kern.c 2006-08-16 15:51: 08.105199800 +0800 @@ -338,6 +338,7 @@ int hostfs_readdir(struct file *file, vo kfree(name); if(dir == NULL) return(-error); next = file->f_pos; + seek_dir(dir, next); while((name = read_dir(dir, &next, &ino, &len)) != NULL){ error = (*filldir)(ent, name, len, file->f_pos, ino, DT_UNKNOWN); diff -urNp linux-2.6.10/fs/hostfs/hostfs_user.c linux-2.6.10-src /fs/hostfs/hostfs_user.c --- linux-2.6.x/fs/hostfs/hostfs_user.c 2006-04-12 15:12:52.000000000 +0800 +++ linux-2.6.10-src/fs/hostfs/hostfs_user.c 2006-08-16 15:53: 31.618382480 +0800 @@ -116,13 +116,19 @@ void *open_dir(char *path, int *err_out) return(dir); } +void seek_dir(void *stream, unsigned long long pos) +{ + DIR *dir = stream; + + seekdir(dir, pos); +} + char *read_dir(void *stream, unsigned long long *pos, unsigned long long *ino_out, int *len_out) { DIR *dir = stream; struct dirent *ent; - seekdir(dir, *pos); ent = readdir(dir); if(ent == NULL) return(NULL); *len_out = strlen(ent->d_name); 2006/8/16, Blaisorblade : > > On Monday 14 August 2006 13:07, wang lianwei wrote: > > Answers: > > > > 1. I test it on ext3 filesystem. > > > > 2. You are right. Sometimes the pos telldir returned is not the next > entry > > offset. just as your point out: > > position 0 -> readdir "." -> you call telldir -> it _again_ says > > you're at 0. > > > > 3. I also try to resolve it by remove the seekdir(only use the > > sequence readdir call), It is also worked. > > I can guess what the patch does but please generate with the additional -p > option so it's easier to read (otherwise the recipient _has_ to read the > source). Compliments for the solution, it's really simpler and better than > my > proposal. > > Also, you have to regenerate it anyway for another (tiny) reason: it is > not > always safe to use "seekdir" in kernelspace code, you need (sadly) a new > wrapper in hostfs_user.c and to call it instead of seekdir in > hostfs_kern.c; > almost surely you'll get an "undeclared function" warning but > miscompilations > in some rare cases are also possible, say for stat(): it is defined almost > only as a static inline function, or for some structures having different > definitions in userspace and kernelspace. > > > --- linux-2.6.x/fs/hostfs/hostfs_kern.c 2006-04-12 15:12:51.000000000+0800 > > +++ linux-2.6.10-src/fs/hostfs/hostfs_kern.c 2006-08-14 18:25: > > 13.772237744 +0800 > > @@ -338,6 +338,7 @@ > > kfree(name); > > if(dir == NULL) return(-error); > > next = file->f_pos; > > + seekdir(dir,next); > > while((name = read_dir(dir, &next, &ino, &len)) != NULL){ > > error = (*filldir)(ent, name, len, file->f_pos, > > ino, DT_UNKNOWN); > > > > > > --- linux-2.6.x/fs/hostfs/hostfs_user.c 2006-04-12 15:12:52.000000000+0800 > > +++ linux-2.6.10-src/fs/hostfs/hostfs_user.c 2006-08-14 18:36: > > 24.276305632 +0800 > > @@ -122,7 +122,6 @@ > > DIR *dir = stream; > > struct dirent *ent; > > > > - seekdir(dir, *pos); > > ent = readdir(dir); > > if(ent == NULL) return(NULL); > > *len_out = strlen(ent->d_name); > > -- > Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!". > Paolo Giarrusso, aka Blaisorblade > http://www.user-mode-linux.org/~blaisorblade > Chiacchiera con i tuoi amici in tempo reale! > http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com > > ------=_Part_235439_11416407.1155723541802 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
yes, you are right. see this patches.
 

diff -urNp linux-2.6.10/fs/hostfs/hostfs.h linux-2.6.10-src/fs/hostfs/hostfs.h
--- linux-2.6.10/fs/hostfs/hostfs.h      2006-04-12 15:12:51.000000000 +0800
+++ linux-2.6.10-src/fs/hostfs/hostfs.h   2006-08-16 15:58: 59.149590168 +0800
@@ -40,6 +40,7 @@ extern int access_file(char *path, int r
 extern int open_file(char *path, int r, int w, int append);
 extern int file_type(const char *path, int *maj, int *min);
 extern void *open_dir(char *path, int *err_out);
+extern void seek_dir(void *stream, unsigned long long pos);
 extern char *read_dir(void *stream, unsigned long long *pos,
                      unsigned long long *ino_out, int *len_out);
 extern void close_file(void *stream);
 
 

diff -urNp linux-2.6.10/fs/hostfs/hostfs_kern.c linux-2.6.10-src/fs/hostfs/hostfs_kern.c
--- linux-2.6.10/fs/hostfs/hostfs_kern.c 2006-04-12 15:12:51.000000000 +0800
+++ linux-2.6.10-src/fs/hostfs/hostfs_kern.c      2006-08-16 15:51: 08.105199800 +0800
@@ -338,6 +338,7 @@ int hostfs_readdir(struct file *file, vo
        kfree(name);
        if(dir == NULL) return(-error);
        next = file->f_pos;
+      seek_dir(dir, next);
        while((name = read_dir(dir, &next, &ino, &len)) != NULL){
                error = (*filldir)(ent, name, len, file->f_pos,
                                   ino, DT_UNKNOWN);
 
 

diff -urNp linux-2.6.10/fs/hostfs/hostfs_user.c linux-2.6.10-src/fs/hostfs/hostfs_user.c
--- linux-2.6.x/fs/hostfs/hostfs_user.c 2006-04-12 15:12:52.000000000 +0800
+++ linux-2.6.10-src/fs/hostfs/hostfs_user.c      2006-08-16 15:53: 31.618382480 +0800
@@ -116,13 +116,19 @@ void *open_dir(char *path, int *err_out)
        return(dir);
 }
 
+void seek_dir(void *stream, unsigned long long pos)
+{
+        DIR *dir = stream;
+
+        seekdir(dir, pos);
+}
+
 char *read_dir(void *stream, unsigned long long *pos,
               unsigned long long *ino_out, int *len_out)
 {
        DIR *dir = stream;
        struct dirent *ent;
 
-       seekdir(dir, *pos);
        ent = readdir(dir);
        if(ent == NULL) return(NULL);
        *len_out = strlen(ent->d_name);


 


 
2006/8/16, Blaisorblade <blaisorblade@yahoo.it>:
On Monday 14 August 2006 13:07, wang lianwei wrote:
> Answers:
>
> 1. I test it on ext3 filesystem.
>
> 2. You are right. Sometimes the pos telldir returned is not the next entry
> offset. just as your point out:
>       position 0 -> readdir "." -> you call telldir -> it _again_ says
> you're at 0.
>
> 3. I also try to resolve it by remove the seekdir(only use the
> sequence readdir call), It is also worked.

I can guess what the patch does but please generate with the additional -p
option so it's easier to read (otherwise the recipient _has_ to read the
source). Compliments for the solution, it's really simpler and better than my
proposal.

Also, you have to regenerate it anyway for another (tiny) reason: it is not
always safe to use "seekdir" in kernelspace code, you need (sadly) a new
wrapper in hostfs_user.c and to call it instead of seekdir in hostfs_kern.c;
almost surely you'll get an "undeclared function" warning but miscompilations
in some rare cases are also possible, say for stat(): it is defined almost
only as a static inline function, or for some structures having different
definitions in userspace and kernelspace.

> --- linux-2.6.x /fs/hostfs/hostfs_kern.c 2006-04-12 15:12:51.000000000 +0800
> +++ linux-2.6.10-src/fs/hostfs/hostfs_kern.c      2006-08-14 18:25:
> 13.772237744 +0800
> @@ -338,6 +338,7 @@
>         kfree(name);
>         if(dir == NULL) return(-error);
>         next = file->f_pos;
> +       seekdir(dir,next);
>         while((name = read_dir(dir, &next, &ino, &len)) != NULL){
>                 error = (*filldir)(ent, name, len, file->f_pos,
>                                    ino, DT_UNKNOWN);
>
>
> --- linux-2.6.x/fs/hostfs/hostfs_user.c 2006-04-12 15:12:52.000000000 +0800
> +++ linux-2.6.10-src/fs/hostfs/hostfs_user.c      2006-08-14 18:36:
> 24.276305632 +0800
> @@ -122,7 +122,6 @@
>         DIR *dir = stream;
>         struct dirent *ent;
>
> -       seekdir(dir, *pos);
>         ent = readdir(dir);
>         if(ent == NULL) return(NULL);
>         *len_out = strlen(ent->d_name);

--
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade
http://www.user-mode-linux.org/~blaisorblade
Chiacchiera con i tuoi amici in tempo reale!
http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com


------=_Part_235439_11416407.1155723541802-- --===============1640501755== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 --===============1640501755== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel --===============1640501755==--