www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1992/07/08/01:11:32

Date: Tue, 7 Jul 92 21:25:12 -0700
From: Hassan Saleh <salehh AT atlantis DOT CS DOT ORST DOT EDU>
To: djgpp AT sun DOT soe DOT clarkson DOT edu

I pulled this out of DEMACS.

/* DJGCC's stat () can't get the status of root directory. */
/* We can't redefine stat () to sys_stat () because structure named stat
   is declared in <sys/stat.h>. So we must rewite stat () to sys_stat ()
   in all file it appears. */

int
sys_stat (name, buf)
     char *name;
     struct stat *buf;
{
  extern int stat ();

  if (strcmp (name, "/") && strcmp (name + 1, ":/"))
    {
      int len = strlen (name);
      char *tmp = (char *) alloca (len + 1);

      strcpy (tmp, name);
      if (tmp[len - 1] == '/') tmp[len - 1] = 0;
      return stat (tmp, buf);
    }
  else
    {
      buf->st_rdev = buf->st_ino = 0;
      buf->st_dev = 0;
      buf->st_nlink = 1;
      buf->st_uid = buf->st_gid = 0;
      buf->st_size = 0;
      buf->st_atime = buf->st_mtime = buf->st_ctime = 0;
      buf->st_mode = S_IREAD | S_IWRITE | S_IFDIR;
      return 0;
    }
}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019