(_major): Ditto.
(device::is_fs_special): New function.
* fhandler_disk_file.cc (fhandler_base::fstat_helper): Set the size to 0 for
devices rather than reporting the size of the symlink.
(fhandler_disk_file::readdir): Use is_fs_special to determine if .lnk should be
stripped.
* path.cc: Rename symlink_info::is_symlink to symlink_info::issymlink
throughout.
(symlink_info::isdevice): New field.
(path_conv::check): Use 'isdevice' to determine if just-parsed entity is a
device rather than relying on non-zero major/minor.
(symlink_info::parse_device): Set isdevice to true if we've discovered a
device.
(symlink_info::check): Clear isdevice field prior to processing. Use isdevice
to control debugging output.
(symlink_info::set): Set isdevice to false.
* path.h (path_conv::is_fs_special): New function.
* devices.cc: Regenerate.
+2005-12-01 Christopher Faylor <cgf@timesys.com>
+
+ * devices.h (_minor): Coerce argument to proper type before
+ manipulating.
+ (_major): Ditto.
+ (device::is_fs_special): New function.
+ * fhandler_disk_file.cc (fhandler_base::fstat_helper): Set the size to
+ 0 for devices rather than reporting the size of the symlink.
+ (fhandler_disk_file::readdir): Use is_fs_special to determine if .lnk
+ should be stripped.
+ * path.cc: Rename symlink_info::is_symlink to symlink_info::issymlink
+ throughout.
+ (symlink_info::isdevice): New field.
+ (path_conv::check): Use 'isdevice' to determine if just-parsed entity
+ is a device rather than relying on non-zero major/minor.
+ (symlink_info::parse_device): Set isdevice to true if we've discovered
+ a device.
+ (symlink_info::check): Clear isdevice field prior to processing. Use
+ isdevice to control debugging output.
+ (symlink_info::set): Set isdevice to false.
+ * path.h (path_conv::is_fs_special): New function.
+ * devices.cc: Regenerate.
+
2005-11-30 Christopher Faylor <cgf@timesys.com>
* times.cc (hires_ms::prime): Remove debugging stuff.
(mmap_record::autogrow): Call global autogrow function.
(list::anonymous): New method. Use throughout were appropriate.
(mmap_record::compatible_flags): Drop now useless ifdef.
- (mmap_record::alloc_page_map): Accomodate private anonymous maps.
- (mmap_record::map_pages): Accomodate MAP_NORESERVE mappings.
- (mmap_record::unmap_pages): Accomodate private anonymous maps.
+ (mmap_record::alloc_page_map): Accommodate private anonymous maps.
+ (mmap_record::map_pages): Accommodate MAP_NORESERVE mappings.
+ (mmap_record::unmap_pages): Accommodate private anonymous maps.
(mmap64): Simplify argument check. Don't remove the MAP_PRIVATE flag
for anonymous mappings on 9x anymore since that's now handled
gracefully.
- (mprotect): Accomodate MAP_NORESERVE mappings. Fix case when
+ (mprotect): Accommodate MAP_NORESERVE mappings. Fix case when
non-mmap areas are just MEM_RESERVEd.
(fhandler_dev_zero::mmap): Implement anonymous mapping here.
(fhandler_dev_zero::munmap): Ditto.
(fhandler_dev_zero::msyn): Ditto.
(fhandler_dev_zero::fixup_mmap_after_fork): Ditto.
- (fixup_mmaps_after_fork): Accomodate private anonymous maps. Enhance
+ (fixup_mmaps_after_fork): Accommodate private anonymous maps. Enhance
debug output in case VirtualProtect fails.
* include/sys/mman.h: Really define MAP_NORESERVE now.
typedef __dev32_t _dev_t;
#define FHDEV(maj, min) ((((unsigned) (maj)) << (sizeof (_major_t) * 8)) | (unsigned) (min))
-#define _minor(dev) ((dev) & ((1 << (sizeof (_minor_t) * 8)) - 1))
-#define _major(dev) ((dev) >> (sizeof (_major_t) * 8))
+#define _minor(dev) (((_minor_t) dev) & ((1 << (sizeof (_minor_t) * 8)) - 1))
+#define _major(dev) (((_major_t) dev) >> (sizeof (_major_t) * 8))
enum fh_devices
{
inline operator int () const {return devn;}
inline void setfs (bool x) {dev_on_fs = x;}
inline bool isfs () const {return dev_on_fs || devn == FH_FS;}
+ inline bool is_fs_special () const {return dev_on_fs && devn != FH_FS;}
};
extern const device *console_dev;
{
buf->st_dev = dev ();
buf->st_mode = dev ().mode;
+ buf->st_size = 0;
}
}
else
{
buf->st_dev = dev ();
buf->st_mode = dev ().mode;
+ buf->st_size = 0;
}
else
{
strcpy (fbuf, dir->__d_dirname);
strcpy (fbuf + strlen (fbuf) - 1, c);
path_conv fpath (fbuf, PC_SYM_NOFOLLOW);
- if (fpath.issymlink () || fpath.isspecial ())
+ if (fpath.issymlink () || fpath.is_fs_special ())
c[len - 4] = '\0';
}
}
int extn;
unsigned pflags;
DWORD fileattr;
- int is_symlink;
+ int issymlink;
bool ext_tacked_on;
int error;
bool case_clash;
+ bool isdevice;
_major_t major;
_minor_t minor;
_mode_t mode;
is_virtual_symlink:
- if (sym.minor || sym.major)
+ if (sym.isdevice)
{
dev.parse (sym.major, sym.minor);
dev.setfs (1);
/* If symlink.check found an existing non-symlink file, then
it sets the appropriate flag. It also sets any suffix found
into `ext_here'. */
- if (!sym.is_symlink && sym.fileattr != INVALID_FILE_ATTRIBUTES)
+ if (!sym.issymlink && sym.fileattr != INVALID_FILE_ATTRIBUTES)
{
error = sym.error;
if (component == 0)
mymajor = strtol (contents += 2, &endptr, 16);
if (endptr == contents)
- return false;
+ return isdevice = false;
contents = endptr;
myminor = strtol (++contents, &endptr, 16);
if (endptr == contents)
- return false;
+ return isdevice = false;
contents = endptr;
mymode = strtol (++contents, &endptr, 16);
if (endptr == contents)
- return false;
+ return isdevice = false;
- switch (mymode & S_IFMT)
+ if ((mymode & S_IFMT) == S_IFIFO)
{
- case S_IFIFO:
mymajor = _major (FH_FIFO);
myminor = _minor (FH_FIFO);
- break;
- case S_IFBLK:
- case S_IFCHR:
- if (mymajor || myminor)
- break;
- default:
- return false;
}
major = mymajor;
minor = myminor;
mode = mymode;
- return true;
+ return isdevice = true;
}
/* Check if PATH is a symlink. PATH must be a valid Win32 path name.
suffix_scan suffix;
contents[0] = '\0';
- is_symlink = true;
+ issymlink = true;
+ isdevice = false;
ext_here = suffix.has (path, suffixes);
extn = ext_here - path;
major = 0;
minor = 0;
+ mode = 0;
pflags &= ~(PATH_SYMLINK | PATH_LNK);
unsigned pflags_or = pflags & PATH_NO_ACCESS_CHECK;
break;
file_not_symlink:
- is_symlink = false;
- syscall_printf ("%s", (major || minor) ? "is a device" : "not a symlink");
+ issymlink = false;
+ syscall_printf ("%s", isdevice ? "is a device" : "not a symlink");
res = 0;
break;
}
pflags = PATH_SYMLINK;
fileattr = FILE_ATTRIBUTE_NORMAL;
error = 0;
- is_symlink = true;
+ issymlink = true;
+ isdevice = false;
ext_tacked_on = case_clash = false;
ext_here = NULL;
extn = major = minor = mode = 0;
int isspecial () const {return dev.devn && dev.devn != FH_FS;}
int is_auto_device () const {return isdevice () && !is_fs_special ();}
int is_fs_device () const {return isdevice () && is_fs_special ();}
- int is_fs_special () const {return isspecial () && dev.isfs ();}
+ int is_fs_special () const {return dev.is_fs_special ();}
int is_lnk_special () const {return is_fs_device () || isfifo () || is_lnk_symlink ();}
int issocket () const {return dev.devn == FH_UNIX;}
int iscygexec () const {return path_flags & PATH_CYGWIN_EXEC;}