Bug 2581 - DT_UNKNOWN happens on Debian when reading a file from CD
Summary: DT_UNKNOWN happens on Debian when reading a file from CD
Status: RESOLVED INVALID
Alias: None
Product: glibc
Classification: Unclassified
Component: manual (show other bugs)
Version: unspecified
: P2 minor
Target Milestone: ---
Assignee: Roland McGrath
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-17 22:31 UTC by Siward de Groot
Modified: 2019-04-10 08:47 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Siward de Groot 2006-04-17 22:31:43 UTC
DT_UNKNOWN happens on Debian when reading a file from CD.
I think it would be nice if this could be mentioned in the manual.

(manual only says that some systems can only return DT_UNKNOWN,
  so i thought it only existed for MS-DOS compatibility)

This applies to manual of january 2005 and also to current web version.

have fun !

Siward
Comment 1 Siward de Groot 2006-04-17 22:48:34 UTC
P.S. Where i said 'file' i mean regular file. 
     Directories on CDROM have type DT_DIR. 
 
Comment 2 Dwayne Grant McConnell 2006-04-19 20:47:26 UTC
When you say "reading a file" what glibc function are you calling?

When you say "the manual" what manual are you referring to and what section in
the manual are you referring to?

Can you propose text which you think would resolve this problem?
Comment 3 Siward de Groot 2006-04-27 08:15:14 UTC
Subject: Re:  DT_UNKNOWN happens on Debian when reading a file from CD

On Wednesday 19 April 2006 22:47, decimal at us dot ibm dot com wrote:
> 
> ------- Additional Comments From decimal at us dot ibm dot com  2006-04-19 20:47 -------
> When you say "reading a file" what glibc function are you calling?
> 
> When you say "the manual" what manual are you referring to and what section in
> the manual are you referring to?
info libc, both my version i downloaded at 20050115 and latest version on gnu.org
 15 - File System Interface
 15.2 - Accessing Directories
 READING AND CLOSING A DIRECTORY pf
 struct dirent * readdir( DIR * pd )

> Can you propose text which you think would resolve this problem?
Current text :

  15.2 - Accessing Directories
 FORMAT OF A DIRECTORY ENTRY
 DATATYPE struct dirent
	 unsigned char d_type	 This is type of file, possibly unknown.
				 following constants are defined for its value :
				 DT_UNKNOWN	 Type is unknown.
						 On some systems this is only value returned.
				 DT_REG		 A regular file.

Proposed text :

	 unsigned char d_type	 This is type of file, possibly unknown.
				 following constants are defined for its value :
				 DT_UNKNOWN	 Type is unknown.
						 On Debian this can occur when reading files and directories from CDROM,
						   in that case stat() does show correct filetype.
						 On some systems this is only value returned.
----
It probably happens on all linuxes, not just debian, but i have only seen this on debian.
It may be relevant that i am using a 2.6 kernel,
  so that the ATAPI CDROM is seen by the kernel as a SCSI device,
  without me needing to specify any append clause in my /etc/lilo.conf
---
TEST :

#include <stdio.h>
#include <dirent.h>
#include <sys/stat.h>

int main( void ){
  DIR *		  pd	 ;
  struct dirent * psd	 ;
  struct stat	  stats	 ;
  int		  ck	 ;

  pd = opendir("/cdrom"); if( pd == NULL ){ printf("NULL opendir1\n"); return(0); }
  while( NULL != (psd = readdir( pd ) ) ){
    if( 0 == strcmp( psd->d_name, "README.html") ){
      printf("name=%s type=%d DT_UNKNOWN=%d\n",psd->d_name, psd->d_type, DT_UNKNOWN );
      }
    if( 0 == strcmp( psd->d_name, "debian") ){
      printf("name=%s type=%d DT_UNKNOWN=%d\n",psd->d_name, psd->d_type, DT_UNKNOWN );
      }
    }
  ck = stat("/cdrom/README.html", &stats ); if( ck != 0 ){ printf("no stat"); }
  printf("mode=%d isreg=%d isdir=%d\n", stats.st_mode, S_ISREG(stats.st_mode), S_ISDIR(stats.st_mode) );
  ck = stat("/cdrom/debian"     , &stats ); if( ck != 0 ){ printf("no stat"); }
  printf("mode=%d isreg=%d isdir=%d\n", stats.st_mode, S_ISREG(stats.st_mode), S_ISDIR(stats.st_mode) );
  return(0);
  }

TESTOUTPUT:

name=debian type=0 DT_UNKNOWN=0
name=README.html type=0 DT_UNKNOWN=0
mode=33060 isreg=1 isdir=0
mode=16749 isreg=0 isdir=1


----------------------------------------------------------------------------
geen Windows maar Linux :-)
Comment 4 Siward de Groot 2006-04-27 08:47:14 UTC
(In reply to comment #1)
> P.S. Where i said 'file' i mean regular file. 
>      Directories on CDROM have type DT_DIR. 
>  
OOPS. that was not correct. directories also report DT_UNKNOWN
Comment 5 Andreas Jaeger 2006-09-21 04:15:13 UTC
The description is clear, read it again:
"This is type of file, possibly unknown.".

We will not add distribution specific information.