This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] Add dirent.d_type support to Cygwin 1.7 ?


Hi Corinna,

Corinna Vinschen wrote:
> > > ...
> > > > 
> > > > +#ifdef _DIRENT_HAVE_D_TYPE
> > > > +  /* Set d_type if type can be determined from file attributes.
> > > > +     FILE_ATTRIBUTE_SYSTEM ommitted to leave DT_UNKNOWN for old
> > > > symlinks.
> > > > +     For new symlinks, d_type will be reset to DT_UNKNOWN
> > > > below.  */ +  if (attr &&
> > > > +      !(attr & ~( FILE_ATTRIBUTE_NORMAL
> > > > +                | FILE_ATTRIBUTE_READONLY
> > > > +                | FILE_ATTRIBUTE_ARCHIVE
> > > > +                | FILE_ATTRIBUTE_HIDDEN
> > > > +                | FILE_ATTRIBUTE_COMPRESSED
> > > > +                | FILE_ATTRIBUTE_ENCRYPTED
> > > > +                | FILE_ATTRIBUTE_SPARSE_FILE
> > > > +                | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
> > > > +                | FILE_ATTRIBUTE_DIRECTORY)))
> > > > 
> 
> I understand why you omit FILE_ATTRIBUTE_REPARSE_POINT in this
> attribute list but what about FILE_ATTRIBUTE_OFFLINE,
> FILE_ATTRIBUTE_TEMPORARY or, FWIW, any other new attributes which will
> be created in later Windows versions?
> 

FILE_ATTRIBUTE_TEMPORARY and _OFFLINE should be added.


> Shouldn't this condition test positively instead like, say,
> 
> !(attr & (FILE_ATTRIBUTE_REPARSE_POINT | FILE_ATTRIBUTE_DEVICE))
> 

If any undocumented flag is set, then DT_UNKNOWN should be returned. MS
might invent new flags, at least on the ntdll layer.


> I must admit I never saw the FILE_ATTRIBUTE_DEVICE attribute actually
> set anywhere...
> 

Meantime, I found FILE_ATTRIBUTE_VALID_FLAGS in winnt.h. It does not
include FILE_ATTRIBUTE_DEVICE.

I would suggest the following logic:

if (attr)
{
  if (attr & ~FILE_ATTRIBUTE_VALID_FLAGS)
    {
      /* undocumented flag: DT_UNKNOWN
         Probably print a warning once:
        "... please inform cygwin at cygwin.com" */
    }
  else if (!(attr & (FILE_ATTRIBUTE_SYSTEM
                    |FILE_ATTRIBUTE_REPARSE_POINT))
    {
      /* DT_REG or DT_DIR */
    }
  else
    /* possible old symlink or something special: DT_UNKNOWN */;
}

Christian




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]