[Patch] Make add_item smarter
2004-05-30 Pierre Humblet <[EMAIL PROTECTED]> * path.cc (mount_info::add_item): Make sure native path has drive or UNC form. Call normalize_xxx_path instead of [back]slashify. Remove test for double slashes. Reorganize to always debug_print. Index: path.cc === RCS file: /cvs/src/src/winsup/cygwin/path.cc,v retrieving revision 1.313 diff -u -p -b -r1.313 path.cc --- path.cc 28 May 2004 19:50:06 - 1.313 +++ path.cc 30 May 2004 04:06:43 - @@ -2176,41 +2176,40 @@ mount_info::sort () int mount_info::add_item (const char *native, const char *posix, unsigned mountflags, int reg_p) { + char nativetmp[CYG_MAX_PATH]; + char posixtmp[CYG_MAX_PATH]; + char *tail; + int err[2]; + /* Something's wrong if either path is NULL or empty, or if it's not a UNC or absolute path. */ - if ((native == NULL) || (*native == 0) || - (posix == NULL) || (*posix == 0) || - !isabspath (native) || !isabspath (posix) || + if (native == NULL || *native == 0 || !isabspath (native) || + !(is_unc_share (native) || isdrive (native))) +err[0] = EINVAL; + else +err[0] = normalize_win32_path (native, nativetmp, &tail); + + if (posix == NULL || *posix == 0 || !isabspath (posix) || is_unc_share (posix) || isdrive (posix)) +err[1] = EINVAL; + else +err[1] = normalize_posix_path (posix, posixtmp, &tail); + + debug_printf ("%s[%s], %s[%s], %p", +native, err[0]?"error":nativetmp, posix, err[1]?"error":posixtmp, +mountflags); + + if (err[0] || err[1]) { - set_errno (EINVAL); + set_errno (err[0]?:err[1]); return -1; } /* Make sure both paths do not end in /. */ - char nativetmp[CYG_MAX_PATH]; - char posixtmp[CYG_MAX_PATH]; - - backslashify (native, nativetmp, 0); nofinalslash (nativetmp, nativetmp); - - slashify (posix, posixtmp, 0); nofinalslash (posixtmp, posixtmp); - debug_printf ("%s[%s], %s[%s], %p", - native, nativetmp, posix, posixtmp, mountflags); - - /* Duplicate /'s in path are an error. */ - for (char *p = posixtmp + 1; *p; ++p) -{ - if (p[-1] == '/' && p[0] == '/') - { - set_errno (EINVAL); - return -1; - } -} - /* Write over an existing mount item with the same POSIX path if it exists and is from the same registry area. */ int i;
Re: [Patch] Make add_item smarter
On Sun, May 30, 2004 at 12:21:48AM -0400, Pierre A. Humblet wrote: >2004-05-30 Pierre Humblet <[EMAIL PROTECTED]> > > * path.cc (mount_info::add_item): Make sure native path has drive > or UNC form. Call normalize_xxx_path instead of [back]slashify. > Remove test for double slashes. Reorganize to always debug_print. >Index: path.cc >=== >RCS file: /cvs/src/src/winsup/cygwin/path.cc,v >retrieving revision 1.313 >diff -u -p -b -r1.313 path.cc >--- path.cc28 May 2004 19:50:06 - 1.313 >+++ path.cc30 May 2004 04:06:43 - >@@ -2176,41 +2176,40 @@ mount_info::sort () > int > mount_info::add_item (const char *native, const char *posix, unsigned mountflags, > int reg_p) > { >+ char nativetmp[CYG_MAX_PATH]; >+ char posixtmp[CYG_MAX_PATH]; >+ char *tail; >+ int err[2]; Why an array here? It's not really being used as an array. > /* Something's wrong if either path is NULL or empty, or if it's > not a UNC or absolute path. */ > >- if ((native == NULL) || (*native == 0) || >- (posix == NULL) || (*posix == 0) || >- !isabspath (native) || !isabspath (posix) || >+ if (native == NULL || *native == 0 || !isabspath (native) || Do we need an "isabsdospath"? Checking for isabspath and isdrive is a little redundant although the compiler would probably optimize nicely. >+ !(is_unc_share (native) || isdrive (native))) >+err[0] = EINVAL; >+ else >+err[0] = normalize_win32_path (native, nativetmp, &tail); >+ >+ if (posix == NULL || *posix == 0 || !isabspath (posix) || > is_unc_share (posix) || isdrive (posix)) >+err[1] = EINVAL; >+ else >+err[1] = normalize_posix_path (posix, posixtmp, &tail); >+ >+ debug_printf ("%s[%s], %s[%s], %p", >+native, err[0]?"error":nativetmp, posix, err[1]?"error":posixtmp, >+mountflags); >+ >+ if (err[0] || err[1]) > { >- set_errno (EINVAL); >+ set_errno (err[0]?:err[1]); > return -1; > } > > /* Make sure both paths do not end in /. */ >- char nativetmp[CYG_MAX_PATH]; >- char posixtmp[CYG_MAX_PATH]; >- >- backslashify (native, nativetmp, 0); > nofinalslash (nativetmp, nativetmp); Do we still need the nofinalslash? cgf
Re: [Patch] Make add_item smarter
Yes, we need to remove the final slash, it can be present at the output of normalize_path 150 761725 [main] mount 671605 mount_info::add_item: c://[c:\\], /hagfsfd/[/hagfsfd/], 0xA Pierre
Re: [Patch] Make add_item smarter
On Sun, May 30, 2004 at 12:48:13AM -0400, Pierre A. Humblet wrote: >Yes, we need to remove the final slash, it can be present at the >output of normalize_path > > 150 761725 [main] mount 671605 mount_info::add_item: c://[c:\\], >/hagfsfd/[/hagfsfd/], 0xA But wouldn't it be faster to just query *tail? cgf
Re: [Patch] Make add_item smarter
Yes, we could use tail, but then we need to add logic to preserve the first / . I was lazy, or perhaps speed is not so important here. Pierre
Re: ssp.c (usage): Add missing linefeed.
I went ahead and applied this. It doesn't appear to break anything. :) On Mon, 24 May 2004 05:11:51 +0100, John Paul Wallington <[EMAIL PROTECTED]> wrote: > > 2004-05-24 John Paul Wallington <[EMAIL PROTECTED]> > > * ssp.c (usage): Add missing linefeed. > > --- ssp.c 14 Feb 2004 19:43:07 + 1.8 > +++ ssp.c 24 May 2004 05:09:52 +0100 > @@ -801,7 +801,7 @@ usage (FILE * stream) > " ssp -v -s -l -d 0x61001000 0x6108 hello.exe\n" > "\n"); >if (stream == stderr) > -fprintf (stream, "Try '%s --help' for more information.", prog_name); > +fprintf (stream, "Try '%s --help' for more information.\n", prog_name); >exit (stream == stderr ? 1 : 0); > } >
Re: [UG Patch] kmem and check_case typo
> >On Fri, 21 May 2004 10:22:20 -0500, Brian Ford wrote: > >> Ok, then shouldn't we apply the following patch to the users > >> guide? (plus a typo fix) Applied with the "planned for development" euphamism.