Sebastian Herbszt
2010-Mar-07 15:02 UTC
[syslinux] [PATCH] fs: fix call to fs_ops->readdir
Check if fs_ops->readdir is available before calling it. At least PXELINUX doesn't implement it. Signed-off-by: Sebastian Herbszt <herbszt at gmx.de> diff --git a/core/fs/readdir.c b/core/fs/readdir.c index d2b112b..d20fc33 100644 --- a/core/fs/readdir.c +++ b/core/fs/readdir.c @@ -28,8 +28,11 @@ struct dirent *readdir(DIR *dir) struct file *dd_dir = (struct file *)dir; int rv = -1; - if (dd_dir) - rv = dd_dir->fs->fs_ops->readdir(dd_dir, &buf); + if (dd_dir) { + if (dd_dir->fs->fs_ops->readdir) { + rv = dd_dir->fs->fs_ops->readdir(dd_dir, &buf); + } + } return rv < 0 ? NULL : &buf; }
On Sun, Mar 7, 2010 at 10:02 AM, Sebastian Herbszt <herbszt at gmx.de> wrote:> Check if fs_ops->readdir is available before calling it. > At least PXELINUX doesn't implement it. > > Signed-off-by: Sebastian Herbszt <herbszt at gmx.de> > > diff --git a/core/fs/readdir.c b/core/fs/readdir.c > index d2b112b..d20fc33 100644 > --- a/core/fs/readdir.c > +++ b/core/fs/readdir.c > @@ -28,8 +28,11 @@ struct dirent *readdir(DIR *dir) > ? ? struct file *dd_dir = (struct file *)dir; > ? ? int rv = -1; > > - ? ?if (dd_dir) > - ? ? ? rv = dd_dir->fs->fs_ops->readdir(dd_dir, &buf); > + ? ?if (dd_dir) { > + ? ? ? ?if (dd_dir->fs->fs_ops->readdir) { > + ? ? ? ? ? rv = dd_dir->fs->fs_ops->readdir(dd_dir, &buf); > + ? ? ? ?} > + ? ?} > > ? ? return rv < 0 ? NULL : &buf; > ?} >This brings up a few questions. 1) This appears to be for Syslinux-4.00 if I'm looking at -pre36 and the code correct. Is this assumption correct? 2) Since I release the initial run of code for the directory-related functions and 3.x, I had posted a git archive as requested and never heard back from anyone again. This can probably be chalked up to "life happens." 3) I'd like to investigate the completeness of the directory-related functions and see about completing them if they are not. I also have an improved version of ROSH (Read-Only SHell) although I still do not consider it complete. -Gene