mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 11:42:21 +00:00
src/lib/libast/features/lib, src/lib/libast/path/pathicase.c: - FAT32 file systems on Linux don't support FS_CASEFOLD_FL, which caused globbing to break. Reproducer using a UEFI boot partition: $ echo /boot/eF* /boot/eF* This is fixed by checking for FAT attributes with ioctl, then checking for FS_CASEFOLD_FL if that fails. - The check for FS_CASEFOLD_FL didn't work correctly; I still wasn't able to get --globcasedetect to work on a case-insensitive ext4 folder. Fix that by adding missing parentheses.
This commit is contained in:
parent
bd38c8049d
commit
ca3ec2000c
2 changed files with 27 additions and 6 deletions
|
@ -4,7 +4,7 @@ cmd universe
|
||||||
|
|
||||||
hdr dirent,direntry,filio,fmtmsg,fnmatch,jioctl,libgen,limits
|
hdr dirent,direntry,filio,fmtmsg,fnmatch,jioctl,libgen,limits
|
||||||
hdr locale,ndir,nl_types,process,spawn,syslog,utime,vfork
|
hdr locale,ndir,nl_types,process,spawn,syslog,utime,vfork
|
||||||
hdr linux/fs,sys/ioctl
|
hdr linux/fs,linux/msdos_fs,sys/ioctl
|
||||||
hdr wchar note{ <wchar.h> and isw*() really work }end execute{
|
hdr wchar note{ <wchar.h> and isw*() really work }end execute{
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
int
|
int
|
||||||
|
|
|
@ -17,11 +17,23 @@
|
||||||
#include <ast.h>
|
#include <ast.h>
|
||||||
#include <error.h>
|
#include <error.h>
|
||||||
|
|
||||||
#if _hdr_linux_fs && _hdr_sys_ioctl
|
#if _hdr_linux_fs
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
|
#endif
|
||||||
|
#if _hdr_linux_msdos_fs
|
||||||
|
#include <linux/msdos_fs.h>
|
||||||
|
#endif
|
||||||
|
#if _hdr_sys_ioctl
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if _hdr_sys_ioctl && _hdr_linux_fs && defined(FS_IOC_GETFLAGS) && defined(FS_CASEFOLD_FL)
|
||||||
|
#define _linux_casefold 1
|
||||||
|
#endif
|
||||||
|
#if _hdr_sys_ioctl && _hdr_linux_msdos_fs && defined(FAT_IOCTL_GET_ATTRIBUTES)
|
||||||
|
#define _linux_fatfs 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return 1 if the given path is on a case insensitive file system, 0 if not, -1 on error.
|
* Return 1 if the given path is on a case insensitive file system, 0 if not, -1 on error.
|
||||||
*/
|
*/
|
||||||
|
@ -40,14 +52,23 @@ pathicase(const char *path)
|
||||||
/* Cygwin */
|
/* Cygwin */
|
||||||
long r = pathconf(path, _PC_CASE_INSENSITIVE);
|
long r = pathconf(path, _PC_CASE_INSENSITIVE);
|
||||||
return r < 0L ? -1 : r > 0L;
|
return r < 0L ? -1 : r > 0L;
|
||||||
#elif _hdr_linux_fs && _hdr_sys_ioctl && defined(FS_IOC_GETFLAGS) && defined(FS_CASEFOLD_FL)
|
#elif _linux_fatfs
|
||||||
/* Linux 5.2+ */
|
/* Linux */
|
||||||
int attr = 0, fd, r;
|
int attr = 0, fd, r;
|
||||||
if ((fd = open(path, O_RDONLY|O_NONBLOCK)) < 0)
|
if ((fd = open(path, O_RDONLY|O_NONBLOCK)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
r = ioctl(fd, FS_IOC_GETFLAGS, &attr);
|
r = ioctl(fd, FAT_IOCTL_GET_ATTRIBUTES, &attr);
|
||||||
|
# if _linux_casefold
|
||||||
|
/* Linux 5.2+ */
|
||||||
|
if (r < 0 && errno == ENOTTY) /* if it's not VFAT/FAT32...*/
|
||||||
|
{
|
||||||
|
r = ioctl(fd, FS_IOC_GETFLAGS, &attr);
|
||||||
|
close(fd);
|
||||||
|
return r < 0 ? -1 : (attr & FS_CASEFOLD_FL) != 0;
|
||||||
|
}
|
||||||
|
# endif /* _linux_casefold */
|
||||||
close(fd);
|
close(fd);
|
||||||
return r < 0 ? -1 : attr & FS_CASEFOLD_FL != 0;
|
return r < 0 ? (errno != ENOTTY ? -1 : 0) : 1;
|
||||||
#elif _WINIX || __APPLE__
|
#elif _WINIX || __APPLE__
|
||||||
/* Windows or Mac without pathconf probe: assume case insensitive */
|
/* Windows or Mac without pathconf probe: assume case insensitive */
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in a new issue