Procházet zdrojové kódy

Stupid filesystems like cramfs fail to guarantee that st_ino and st_dev
uniquely identify a file, contrary to SuSv3, so we cannot be quite so
precise as to require an exact match. Settle for something less...
Grumble...
-Erik

Eric Andersen před 23 roky
rodič
revize
5e7ec59ff0
1 změnil soubory, kde provedl 11 přidání a 2 odebrání
  1. 11 2
      libc/termios/ttyname.c

+ 11 - 2
libc/termios/ttyname.c

@@ -21,8 +21,17 @@ static int __check_dir_for_tty_match(char * dirname, struct stat *st, char *buf,
     while ((d = readdir(fp)) != 0) {
 	strncpy(buf+len, d->d_name, buflen);
 	buf[buflen]='\0';
-	if (stat(buf, &dst) == 0 && st->st_dev == dst.st_dev 
-		&& st->st_ino == dst.st_ino) 
+#if 0
+	/* Stupid filesystems like cramfs fail to guarantee that
+	 * st_ino and st_dev uniquely identify a file, contrary to
+	 * SuSv3, so we cannot be quite so precise as to require an
+	 * exact match.  Settle for something less...  Grumble... */
+	if (stat(buf, &dst) == 0 &&
+		st->st_dev == dst.st_dev && st->st_ino == dst.st_ino)
+#else
+	if (stat(buf, &dst) == 0 &&
+		S_ISCHR(dst.st_mode) && st->st_rdev == dst.st_rdev)
+#endif
 	{
 	    closedir(fp);
 	    return 0;