mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-13 04:29:09 +08:00
Cygwin: path_conv: simplify, rearrange, rename combined device checks
Some checks in path_conv are checking for various properties to generate a boolean value, mostly to indicate different combinations of on-disk files and devices. Simplify these checks and, especially, document them inline. Drop the isdevice() check in favor of a new isondisk() check. Fixes: 4fc922b2c8a5 ("Cygwin: POSIX msg queues: Convert mqd_t to a descriptor") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
d870655f57
commit
890086ad37
@ -214,21 +214,33 @@ class path_conv
|
||||
{
|
||||
return (path_flags & (PATH_REP | PATH_REP_NOAPI)) == PATH_REP;
|
||||
}
|
||||
int isdevice () const {return dev.not_device (FH_FS) && dev.not_device (FH_FIFO);}
|
||||
int isfifo () const {return dev.is_device (FH_FIFO);}
|
||||
int isspecial () const {return dev.not_device (FH_FS);}
|
||||
int iscygdrive () const {return dev.is_device (FH_CYGDRIVE);}
|
||||
int is_fs_special () const {return dev.is_fs_special ();}
|
||||
|
||||
int is_lnk_special () const {return (isdevice () && is_fs_special ()
|
||||
&& !issocket ())
|
||||
|| isfifo () || is_lnk_symlink ();}
|
||||
int isfifo () const {return dev.is_device (FH_FIFO);}
|
||||
int iscygdrive () const {return dev.is_device (FH_CYGDRIVE);}
|
||||
#ifdef __WITH_AF_UNIX
|
||||
int issocket () const {return dev.is_device (FH_LOCAL)
|
||||
|| dev.is_device (FH_UNIX);}
|
||||
#else
|
||||
int issocket () const {return dev.is_device (FH_LOCAL);}
|
||||
#endif /* __WITH_AF_UNIX */
|
||||
|
||||
/* FIXME: This needs a cleanup with better, descriptive names and checking
|
||||
all usages for correctness. */
|
||||
|
||||
/* Any file or device with representation on disk. This includes local
|
||||
sockets, FIFOs, message queues and devices created with mknod. It does
|
||||
not include the /proc hierarchy. */
|
||||
int isondisk () const {return dev.isfs ();}
|
||||
/* Any device, virtual or with on-disk representation, and anything under
|
||||
/proc. */
|
||||
int isspecial () const {return dev.not_device (FH_FS);}
|
||||
/* Devices with representation on disk. This includes local sockets, FIFOs,
|
||||
message queues and devices created with mknod. It does not include
|
||||
the /proc hierarchy. */
|
||||
int is_fs_special () const {return dev.is_fs_special ();}
|
||||
/* Like is_fs_special but excluding local sockets. */
|
||||
int is_lnk_special () const {return is_fs_special () && !issocket ();}
|
||||
|
||||
int iscygexec () const {return mount_flags & MOUNT_CYGWIN_EXEC;}
|
||||
int isopen () const {return path_flags & PATH_OPEN;}
|
||||
int isctty_capable () const {return path_flags & PATH_CTTY;}
|
||||
|
@ -2080,8 +2080,7 @@ symlink_worker (const char *oldpath, path_conv &win32_newpath, bool isdevice)
|
||||
syscall_printf ("symlink (%s, %S) wsym_type %d", oldpath,
|
||||
win32_newpath.get_nt_native_path (), wsym_type);
|
||||
|
||||
if ((!isdevice && win32_newpath.exists ())
|
||||
|| (win32_newpath.isdevice () && !win32_newpath.is_fs_special ()))
|
||||
if (win32_newpath.exists() && (!isdevice || !win32_newpath.isondisk ()))
|
||||
{
|
||||
set_errno (EEXIST);
|
||||
__leave;
|
||||
|
@ -1136,7 +1136,7 @@ unlink (const char *ourname)
|
||||
set_errno (EROFS);
|
||||
goto done;
|
||||
}
|
||||
if (isdevfd_dev (devn) || (win32_name.isdevice () && !win32_name.issocket ()))
|
||||
if (!win32_name.isondisk ())
|
||||
{
|
||||
set_errno (EPERM);
|
||||
goto done;
|
||||
|
Loading…
x
Reference in New Issue
Block a user