예제 #1
0
파일: sheap.cpp 프로젝트: kolyden/mirror
inline
void *Heap::Alloc(size_t sz)
{
	Stat(sz);
	if(sz <= 224) {
		if(sz == 0) sz = 1;
		return Allok(((int)sz - 1) >> 4);
	}
	if(sz <= 576)
		return Allok(sz <= 368 ? sz <= 288 ? 14 : 15 : sz <= 448 ? 16 : 17);
	return LAlloc(sz);
}
예제 #2
0
Prediction::Prediction(int _numCluster, int _dim_feature)
{
    num_cluster = _numCluster;
    dim_feature = _dim_feature;
    svm = RankingSVM(dim_feature);
    curRounds = -1;
    for (int i=0; i<num_cluster; i++ )
    {
         clusters.push_back(Cluster(num_cluster, dim_feature));
    }
    rougeStat = Stat();
}
예제 #3
0
VOID LoadElements()
{
    ClearElements();
    CHAR ElementList[MAX_STRING*10] = {0};
    CHAR szBuffer[MAX_STRING], CurrentHUD[MAX_STRING] = {0};
    CHAR ClassDesc[MAX_STRING], ZoneName[MAX_STRING] = {0};
    int argn=1;
    GetArg(CurrentHUD,HUDNames,argn,0,0,0,',');
    while (*CurrentHUD) {
        GetPrivateProfileString(CurrentHUD,NULL,"",ElementList,MAX_STRING*10,INIFileName);
        PCHAR pElementList = ElementList;
        while (pElementList[0]!=0) {
            GetPrivateProfileString(CurrentHUD,pElementList,"",szBuffer,MAX_STRING,INIFileName);
            if (szBuffer[0]!=0) {
                AddElement(szBuffer);
            }
            pElementList+=strlen(pElementList)+1;
        }
        GetArg(CurrentHUD,HUDNames,++argn,0,0,0,',');
    }
    if (gGameState==GAMESTATE_INGAME) {
        if (bClassHUD && ((ppCharData) && (pCharData))) {
			if (PCHARINFO2 pChar2 = GetCharInfo2()) {
				sprintf_s(ClassDesc, "%s", GetClassDesc(pChar2->Class));
				GetPrivateProfileString(ClassDesc, NULL, "", ElementList, MAX_STRING * 10, INIFileName);
				PCHAR pElementList = ElementList;
				while (pElementList[0] != 0) {
					GetPrivateProfileString(ClassDesc, pElementList, "", szBuffer, MAX_STRING, INIFileName);
					if (szBuffer[0] != 0) {
						AddElement(szBuffer);
					}
					pElementList += strlen(pElementList) + 1;
				}
			}
        }
        if (bZoneHUD && (pZoneInfo)) {
            sprintf_s(ZoneName,"%s",((PZONEINFO)pZoneInfo)->LongName);
            GetPrivateProfileString(ZoneName,NULL,"",ElementList,MAX_STRING*10,INIFileName);
            PCHAR pElementList = ElementList;
            while (pElementList[0]!=0) {
                GetPrivateProfileString(ZoneName,pElementList,"",szBuffer,MAX_STRING,INIFileName);
                if (szBuffer[0]!=0) {
                    AddElement(szBuffer);
                }
                pElementList+=strlen(pElementList)+1;
            }
        }
    }

    if (!Stat(INIFileName,LastRead))
        ZeroMemory(&LastRead,sizeof(struct _stat));
}
예제 #4
0
status_t
Inode::LoadAttrDirHandle()
{
	if (fInfo.fAttrDir.fSize != 0)
		return B_OK;

	FileHandle handle;
	status_t result;

	if (fFileSystem->NamedAttrs()) {
		result = NFS4Inode::OpenAttrDir(&handle);
		if (result == B_OK) {
			fInfo.fAttrDir = handle;
			return B_OK;
		}

		if (result != B_UNSUPPORTED)
			return result;

		fFileSystem->SetNamedAttrs(false);
	}

	if (!fFileSystem->GetConfiguration().fEmulateNamedAttrs)
		return B_UNSUPPORTED;

	char* attrDir
		= reinterpret_cast<char*>(malloc(strlen(Name()) + 32));
	if (attrDir == NULL)
		return B_NO_MEMORY;
	strcpy(attrDir, ".");
	strcat(attrDir, Name());
	strcat(attrDir, "-haiku-attrs");

	result = NFS4Inode::LookUp(attrDir, NULL, NULL, &handle, true);
	if (result == B_ENTRY_NOT_FOUND) {
		ChangeInfo change;
		struct stat st;
		Stat(&st);
		st.st_mode |= S_IXUSR | S_IXGRP | S_IXOTH;
		result = NFS4Inode::CreateObject(attrDir, NULL, st.st_mode, NF4DIR,
			&change, NULL, &handle, true);
	}

	free(attrDir);

	if (result != B_OK)
		return result;

	fInfo.fAttrDir = handle;
	return B_OK;
}
예제 #5
0
파일: filan.c 프로젝트: dest-unreach/socat2
/* analyse a file system entry, referred by file name */
int filan_file(const char *filename, FILE *outfile) {
   int fd = -1;
   int result;
#if HAVE_STAT64
   struct stat64 buf = {0};
#else
   struct stat buf = {0};
#endif /* !HAVE_STAT64 */

   if (filan_followsymlinks) {
#if HAVE_STAT64
      result = Stat64(filename, &buf);
#else
      result = Stat(filename, &buf);
#endif /* !HAVE_STAT64 */
      if (result < 0) {
	 Warn3("stat(\"%s\", %p): %s", filename, &buf, strerror(errno));
      }
   } else {
#if HAVE_STAT64
      result = Lstat64(filename, &buf);
#else
      result = Lstat(filename, &buf);
#endif /* !HAVE_STAT64 */
      if (result < 0) {
	 Warn3("lstat(\"%s\", %p): %s", filename, &buf, strerror(errno));
      }
   }
   switch (buf.st_mode&S_IFMT) {
#ifdef S_IFSOCK
   case S_IFSOCK: /* probably, it's useless to make a socket and describe it */
      break;
#endif /* S_IFSOCK */
   default:
      if ((fd =
	   Open(filename,  O_RDONLY|O_NOCTTY|O_NONBLOCK
#ifdef O_LARGEFILE
		|O_LARGEFILE
#endif
		, 0700))
	  < 0) {
	 Warn2("open(\"%s\", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_LARGEFILE, 0700): %s",
	       filename, strerror(errno));
      }
   }
     
   result = filan_stat(&buf, fd, -1, outfile);
   fputc('\n', outfile);
   return result;
}
예제 #6
0
void PrintDirectory(char *name)
{
    int i;
    int fd;
    int ret;
    int count;
    fileStat stat;
    dirEntry dirItem;

    // read the directory
    fd = Open(name, O_READ);
    if (fd < 0) {
	Print("Error unable to open %s\n", name);
	return;
    }

    // stat the directory and see if its a directory
    ret = Stat(fd, &stat);
    if (!stat.isDirectory) {
        Print("Error, %s is not a directory\n", name);
	return;
    }

    ret = 0;
    while (ret >= 0) {
	ret = Read(fd, (char *) &dirItem, sizeof(dirItem));
	if (ret >= 0) {
	    if (dirItem.stats.isDirectory) 
		Print("d ");
	    else 
		Print("f ");
	    Print("%d ", dirItem.stats.size);
	    Print("%s ", dirItem.name);
	    count = 0;
	    for (i=0; i < 4; i++) {
	        if (dirItem.stats.acls[i].uid) {
		    if (count) Print(", ");
		    Print("%d(", dirItem.stats.acls[i].uid);
		    if (dirItem.stats.acls[i].permission & O_READ) Print("r");
		    if (dirItem.stats.acls[i].permission & O_WRITE) Print("w");
		    Print(")");
		    count = 1;
		}
	    }
	    Print("\n");
	}
    }

    Close(fd);
}
예제 #7
0
rpmRC rpmpythonRunFile(rpmpython python, const char * fn, const char ** resultp)
{
    rpmRC rc = RPMRC_FAIL;


if (_rpmpython_debug)
fprintf(stderr, "==> %s(%p,%s)\n", __FUNCTION__, python, fn);

    if (python == NULL) python = rpmpythonI();

    if (fn != NULL) {
#if defined(WITH_PYTHONEMBED)
	const char * pyfn = ((fn == NULL || !strcmp(fn, "-")) ? "<stdin>" : fn);
	FILE * pyfp = (!strcmp(pyfn, "<stdin>") ? stdin : fopen(fn, "rb"));
	int closeit = (pyfp != stdin);
	PyCompilerFlags cf = { .cf_flags = 0 };
	
	if (pyfp != NULL) {
	    PyRun_AnyFileExFlags(pyfp, pyfn, closeit, &cf);
	    rc = RPMRC_OK;
	}
#endif
    }
    return rc;
}

static const char * rpmpythonSlurp(const char * arg)
	/*@*/
{
    rpmiob iob = NULL;
    const char * val = NULL;
    struct stat sb;
    int xx;

    if (!strcmp(arg, "-")) {	/* Macros from stdin arg. */
	xx = rpmiobSlurp(arg, &iob);
    } else
    if ((arg[0] == '/' || strchr(arg, ' ') == NULL)
     && !Stat(arg, &sb)
     && S_ISREG(sb.st_mode)) {	/* Macros from a file arg. */
	xx = rpmiobSlurp(arg, &iob);
    } else {			/* Macros from string arg. */
	iob = rpmiobAppend(rpmiobNew(strlen(arg)+1), arg, 0);
    }

    val = xstrdup(rpmiobStr(iob));
    iob = rpmiobFree(iob);
    return val;
}
예제 #8
0
int bbcp_FS_Unix::Stat(const char *path, const char *dent, int fd,
                       int chklnks, bbcp_FileInfo *sbuff)
{
   struct stat xbuff;
   char lbuff[2048];
   int n;

// Perform the stat function
//
#ifdef AT_SYMLINK_NOFOLLOW
   if (fstatat(fd, dent, &xbuff, AT_SYMLINK_NOFOLLOW)) return -errno;
   if ((xbuff.st_mode & S_IFMT) != S_IFLNK)
      return (sbuff ? Stat(xbuff, sbuff) : 0);
   if (chklnks > 0) return -ENOENT;
   if (!sbuff) return 0;
   if ((n = READLINK(fd,dent,path,lbuff,sizeof(lbuff)-1)) < 0) return -errno;
// if ((n = readlinkat(fd, dent, lbuff, sizeof(lbuff)-1)) < 0) return -errno;
   lbuff[n] = 0;
   if(sbuff->SLink) free(sbuff->SLink);
   sbuff->SLink = strdup(lbuff);
   if (!chklnks && fstatat(fd, dent, &xbuff, 0)) return -errno;
   return Stat(xbuff, sbuff);
#else
   if (lstat(path, &xbuff)) return -errno;
   if ((xbuff.st_mode & S_IFMT) != S_IFLNK)
      return (sbuff ? Stat(xbuff, sbuff) : 0);
   if (chklnks > 0) return -ENOENT;
   if (!sbuff) return 0;
   if ((n = readlink(path, lbuff, sizeof(lbuff)-1)) < 0) return -errno;
   lbuff[n] = 0;
   if(sbuff->SLink) free(sbuff->SLink);
   sbuff->SLink = strdup(lbuff);
   if (!chklnks && stat(path, &xbuff)) return -errno;
   return Stat(xbuff, sbuff);
#endif
}
예제 #9
0
void gtm_dump_core(void)
{
    struct sigaction        act;
    char                    newname[20];
    int                     suffix, status;
    struct stat             fs1;

    sigemptyset(&act.sa_mask);
#ifdef _AIX
    act.sa_flags = SA_FULLDUMP;
#else
    act.sa_flags = 0;
#endif
    act.sa_handler = SIG_DFL;
    sigaction(SIGQUIT, &act, 0);

    /* We are about to generate a core file. If one already exists on the disk,
       make a simplistic attempt to rename it so we can get the most useful info
       possible. */

    if (0 == Stat("core", &fs1))            /* If core exists (and stat command works) */
    {
        status = -1;
        for (suffix = 1; 0 != status && suffix < 100; ++suffix)
        {
            sprintf(&newname[0], "core%d", suffix);         /* Make new file name */
            status = Stat(&newname[0], &fs1);               /* This file exist ? */
            if (0 != status)
                status = rename("core", &newname[0]);   /* No, attempt the rename */
            else
                status = -1;                            /* Yes, reset status for another iteration */
        }
    }
    kill(getpid(), SIGQUIT);
    sleep(30);	/* In case of async kill */
}
예제 #10
0
rpmwf rpmwfNew(const char * fn)
{
    struct stat sb, *st = &sb;
    rpmwf wf;
    int xx;

/*@-globs@*/
    if ((xx = Stat(fn, st)) < 0)
	return NULL;
/*@=globs@*/
    wf = rpmwfGetPool(_rpmwfPool);
    wf->fn = xstrdup(fn);
    wf->nb = (size_t)st->st_size;

    return rpmwfLink(wf, "rpmwfNew");
}
예제 #11
0
파일: syscall.c 프로젝트: khwang18c/CMSC412
/*
 * Get file metadata.
 * Params:
 *   state->ebx - address of user string containing path of file
 *   state->ecx - length of path
 *   state->edx - user address of struct VFS_File_Stat object to store metadata in
 *
 * Returns: 0 if successful, error code (< 0) if unsuccessful
 */
static int Sys_Stat(struct Interrupt_State *state) {
  char *path;
  int rc = get_path_from_registers(state->ebx, state->ecx, &path);
  struct VFS_File_Stat vfs;
  Enable_Interrupts();
  rc = Stat(path, &vfs);
  Free(path);
  Disable_Interrupts();

  if(rc == 0) {
  if (!Copy_To_User(state->edx, &vfs, sizeof(struct VFS_File_Stat))) {
    return EINVALID;
  }
  }
  return rc;
}
예제 #12
0
파일: args.cpp 프로젝트: ihenrypan/work
// 获取开辟进程数和split词表文件时的时间戳等其他参数,并生成
int getExtraArgs()
{
    // 获取词表文件的大小
    // 词表文件名:g_pConf->pDictPath/g_pArgs->pDictName
    char pTmpName[MAX_NAME];
    sprintf(pTmpName, "%s%s", g_pConf->pDictPath, g_pArgs->pDictName);

    struct stat statBuffer;
    if (Stat(pTmpName, &statBuffer) != 0) {
        return -1;
    }
    // 文件字节大小
    int iFileByte = statBuffer.st_size;
    const int TMP_SIZE = 10485760; // 10M
    int iFileNum = iFileByte / TMP_SIZE + 1; // 向上取整
    if (iFileNum > 10) {
        iFileNum = 10;    // 最多开辟10个线程
    }

    g_pArgs->iThreadNum = iFileNum; // 赋值给全局线程数
    int iPerSize = iFileByte / iFileNum + 5000; // split -C iPerSize -d -a 1 DictName dict_,加5000为了向上取整,避免剩余的字节数单独生成一个文件。

    char pStrTime[MAX_NAME];
    getCurrentTime(pStrTime);
    strcpy(g_pArgs->pStrTimestamp, pStrTime);  // 赋值给全局时间戳名

    // 创建./dict/timestamp文件夹
    sprintf(pTmpName, "%s%s", g_pConf->pDictPath, g_pArgs->pStrTimestamp);
    checkDataPath(pTmpName);

    // check res file dir exist or not. if not exist, create it.
    // 创建./res/
    sprintf(pTmpName, "%s", g_pConf->pResPath);
    checkDataPath(pTmpName);
    sprintf(pTmpName, "%s%s", g_pConf->pResPath, g_pArgs->pStrTimestamp);
    checkDataPath(pTmpName);
    // 创建时间戳下的online、offline和diff_ret文件夹
    sprintf(pTmpName, "%s%s/%s", g_pConf->pResPath, g_pArgs->pStrTimestamp, "online");
    checkDataPath(pTmpName);
    sprintf(pTmpName, "%s%s/%s", g_pConf->pResPath, g_pArgs->pStrTimestamp, "offline");
    checkDataPath(pTmpName);
    sprintf(pTmpName, "%s%s/%s", g_pConf->pResPath, g_pArgs->pStrTimestamp, "diff_ret");
    checkDataPath(pTmpName);

    return splitDictFile(iPerSize);
}
예제 #13
0
파일: p1.c 프로젝트: HellBlazzar/Learning
int main() {
    Gradebook gb;
    int num;
    int i,j,k,l;
    srand(time(NULL));
    printf("Enter the number of grades: ");
    scanf("%d", &num);
    for(i=0; i<num; i++)
    {
        gb.grade[i]=60+rand()%41;
    }
    ListGrade(&gb,num);
    printf("\n");
    Stat(&gb,num);
    system("pause");
    return 1;
}
예제 #14
0
void clSFTP::Read(const wxString& remotePath, wxMemoryBuffer& buffer) throw(clException)
{
    if(!m_sftp) {
        throw clException("SFTP is not initialized");
    }

    sftp_file file = sftp_open(m_sftp, remotePath.mb_str(wxConvUTF8).data(), O_RDONLY, 0);
    if(file == NULL) {
        throw clException(wxString() << _("Failed to open remote file: ") << remotePath << ". "
                                     << ssh_get_error(m_ssh->GetSession()),
                          sftp_get_error(m_sftp));
    }

    SFTPAttribute::Ptr_t fileAttr = Stat(remotePath);
    if(!fileAttr) {
        throw clException(wxString() << _("Could not stat file:") << remotePath << ". "
                                     << ssh_get_error(m_ssh->GetSession()),
                          sftp_get_error(m_sftp));
    }
    wxInt64 fileSize = fileAttr->GetSize();
    if(fileSize == 0) return;

    // Allocate buffer for the file content
    char pBuffer[65536]; // buffer

    // Read the entire file content
    wxInt64 bytesLeft = fileSize;
    wxInt64 bytesRead = 0;
    while(bytesLeft > 0) {
        wxInt64 nbytes = sftp_read(file, pBuffer, sizeof(pBuffer));
        bytesRead += nbytes;
        bytesLeft -= nbytes;
        buffer.AppendData(pBuffer, nbytes);
    }

    if(bytesRead != fileSize) {
        sftp_close(file);
        buffer.Clear();
        throw clException(wxString() << _("Could not read file:") << remotePath << ". "
                                     << ssh_get_error(m_ssh->GetSession()),
                          sftp_get_error(m_sftp));
    }
    sftp_close(file);
}
예제 #15
0
void CTestRangeMap::TestIntervalTree(void) const
{
    Filling("CIntervalTree");

    typedef CIntervalTree TMap;
    typedef TMap::const_iterator TMapCI;

    TMap m;

    // fill
    for ( int count = 0; count < m_RangeNumber; ) {
        TRange range = RandomRange();
        m.Insert(range, CConstRef<CObject>(0));
        ++count;
        Added(range);
    }
    
    if ( m_PrintSize ) {
        Filled(m.Size());
        Stat(m.Stat());
    }

    for ( TMapCI i = m.AllIntervals(); i; ++i ) {
        FromAll(i.GetInterval());
    }

    size_t scannedCount = 0;
    for ( int count = 0; count < m_ScanCount; ++count ) {
        for ( int pos = 0; pos <= m_Length + 2*m_RangeLength;
              pos += m_ScanStep ) {
            TRange range(pos, pos + m_ScanLength - 1);
            
            StartFrom(range);
            
            for ( TMapCI i = m.IntervalsOverlapping(range); i; ++i ) {
                From(range, i.GetInterval());
                ++scannedCount;
            }
        }
    }
    PrintTotalScannedNumber(scannedCount);

    End();
}
예제 #16
0
int tBasicDelete() {
    int fd, retD, retS;
    struct VFS_File_Stat s;

    fd = Open("/d/basic5f", O_CREATE | O_WRITE);
    if (fd < 0)
        return -1;

    if (Close(fd) < 0) {
        Print("failed to close");
        return -1;
    }

    retD = Delete("/d/basic5f", false);

    retS = Stat("/d/basic5f", &s);

    return (retD >= 0 && retS < 0) ? 1 : -1;
}
예제 #17
0
파일: vfs.c 프로젝트: sinabeuro/geekos5
/*
 * Completely read named file into a buffer.
 * Params:
 *   path - full path of file
 *   pBuffer - reference to variable where pointer to allocated buffer
 *     should be stored
 *   pLen - reference to variable where length of file should
 *     be stored
 * Returns: 0 if successful, error code (< 0) if not
 */
int Read_Fully(const char *path, void **pBuffer, ulong_t *pLen)
{
    struct File *file = 0;
    struct VFS_File_Stat stat;
    int rc;
    char *buf = 0;
    int numBytesRead;

    if ((rc = Stat(path, &stat)) < 0 || (rc = Open(path, O_READ, &file)) < 0)
		goto fail;
    if (stat.size < 0) {
		rc = ENOTFOUND;
		goto fail;
    }

    buf = (char*) Malloc(stat.size);
    if (buf == 0)
	goto memfail;

    /* Read until buffer is full */
    numBytesRead = 0;
    while (numBytesRead < stat.size) {
	rc = Read(file, buf + numBytesRead, stat.size - numBytesRead);
	if (rc < 0)
	    goto fail;
	numBytesRead += rc;
    }

    /* Success! */
    Close(file);
    *pBuffer = (void*) buf;
    *pLen = stat.size;
    return 0;

memfail:
    rc = ENOMEM;
fail:
    if (file != 0)
	Close(file);
    if (buf != 0)
	Free(buf);
    return rc;
}
예제 #18
0
파일: tget.c 프로젝트: hahnakane/junkcode
static int tgetInit(rpmtget tget, size_t nbuf)
{
    int rc;
    int xx;

    if (_rpmsw_stats) {
	tget->sop = xcalloc(1, sizeof(*tget->sop));
	tget->gop = xcalloc(1, sizeof(*tget->gop));
    }

fprintf(stderr, "===== %s\n", tget->uri);
    xx = rpmswEnter(tget->sop, 0);
    rc = Stat(tget->uri, &tget->sb);
    xx = rpmswExit(tget->sop, 1);
    if (rc < 0)
	goto exit;

    printStat(tget);

    if (nbuf == 0 && tget->sb.st_size > 0)
	nbuf = tget->sb.st_size;

    tget->fd = Fopen(tget->uri, "r.ufdio");
    if (tget->fd == NULL || Ferror(tget->fd)) {
	rc = -1;
	goto exit;
    }
    tget->nbuf = nbuf;
    tget->buf = xmalloc(tget->nbuf + 2);
    tget->buf[0] = '\0';

    tget->b = NULL;
    tget->nb = 0;

    rc = 0;

exit:
    if (rc)
	(void) tgetFini(tget);
    return rc;
}
예제 #19
0
파일: iuctl.cpp 프로젝트: wjmelements/iu
int join_iuctl() {
    struct stat info;
    Stat(QUEUE_PATH, &info);
    int fd = open(QUEUE_PATH, O_RDONLY);
    
    if (fd == -1) {
        return errno;
    }
    char server_pid_str[32];
    Read(fd, server_pid_str, min<size_t>(sizeof(server_pid_str),info.st_size));
    Close(fd);
    server_pid = atoi(server_pid_str);
    assert(server_pid > 0);
    if(kill(server_pid, 0) != 0) {
        return errno;
    }
    self_pid = getpid();
    assert(self_pid > 0);
    init_iuctl(false);
    return 0;
}
예제 #20
0
int tStatFile()
{
  int fd, retW, retS;
  char buffer[11];
  struct VFS_File_Stat s;

  fd = Open("/d/basic9f", O_CREATE|O_WRITE);
  if (fd < 0)
    return -1;

  retW = Write( fd, buffer, 10);
  if (retW < 0)
    return -1;

  Close(fd);

  retS = Stat("/d/basic9f", &s);

  Delete("/d/basic9f");

  return ( (retS >= 0) && (s.size == 10) ) ? 1 : -1;
}
예제 #21
0
void PrintDirectory(char *name)
{
    int fd;
    int ret;
    fileStat stat;
    dirEntry dirItem;

    // read the directory
    fd = Open(name, O_READ);
    if (fd < 0) {
	Print("Error unable to open %s\n", name);
	return;
    }

    // stat the directory and see if its a directory
    ret = Stat(fd, &stat);
    if (!stat.isDirectory) {
        Print("Error, %s is not a directory\n", name);
	return;
    }

    ret = 0;
    while (ret >= 0) {
	ret = Read(fd, (char *) &dirItem, sizeof(dirItem));
	if (ret >= 0) {
	    if (dirItem.stats.isDirectory) 
		Print("d ");
	    else 
		Print("f ");
	    Print("%d ", dirItem.stats.size);
	    Print("%s\n", dirItem.name);
	}
    }

    Close(fd);
}
예제 #22
0
파일: statcheck.c 프로젝트: dreamsxin/CSAPP
int main(int argc,char **argv)
{
	struct stat stat;

	char *type,*readok;

	Stat(argv[1],&stat); //包裹函数

	if(S_ISREG(stat.st_mode))
		type = "reg";
	else if(S_ISDIR(stat.st_mode))
		type = "dir";
	else 
		type = "other";

	if(stat.st_mode & S_IRUSR)
		readok = "yes";
	else
		readok = "no";

	printf("type:%s,read: %s\n",type,readok);

	return 0;
}
예제 #23
0
int tStatFile() {
    int fd, retW, retS;
    char buffer[11];
    struct VFS_File_Stat s;

    fd = Open("/d/basic9f", O_CREATE | O_WRITE);
    if (fd < 0)
        return -1;

    retW = Write(fd, buffer, 10);
    if (retW < 0)
        return -1;

    if (Close(fd) < 0) {
        Print("failed to close");
        return -1;
    }

    retS = Stat("/d/basic9f", &s);

    (void)Delete("/d/basic9f", false);

    return ((retS >= 0) && (s.size == 10)) ? 1 : -1;
}
예제 #24
0
파일: test35.c 프로젝트: AjeyBohare/minix
void test35a()
{				/* Test normal operation. */
  struct stat st;
  struct utimbuf ub;
  time_t time1, time2;
  int cnt;

  subtest = 1;

  /* Creat scratch file. */
  Creat("foo");

  /* Set file times back two seconds. */
  Stat("foo", &st);
  ub.actime = st.st_atime - 2;
  ub.modtime = st.st_mtime - 2;
  Time(&time1);
  utime("foo", &ub);
  Time(&time2);
  Stat("foo", &st);
  if (ub.actime != st.st_atime) e(1);
  if (ub.modtime != st.st_mtime) e(2);

  /* The status changed time sould be changed. */
#ifndef V1_FILESYSTEM
  if (st.st_ctime < time1) e(3);
#endif
  if (st.st_ctime > time2) e(4);

  /* Add twenty seconds. */
  Stat("foo", &st);
  ub.actime = st.st_atime + 20;
  ub.modtime = st.st_mtime + 20;
  Time(&time1);
  utime("foo", &ub);
  Time(&time2);
  Stat("foo", &st);
  if (ub.actime != st.st_atime) e(5);
  if (ub.modtime != st.st_mtime) e(6);
  if (st.st_ctime < time1) e(7);
#ifndef V1_FILESYSTEM
  if (st.st_ctime > time2) e(8);
#endif

  /* Try 100 times to do utime in less than one second. */
  cnt = 0;
  do {
	Time(&time1);
	utime("foo", (struct utimbuf *) NULL);
	Time(&time2);
  } while (time1 != time2 && cnt++ < 100);
  if (time1 == time2) {
	Stat("foo", &st);
	Time(&time2);
	if (st.st_atime != time1) e(9);
	if (st.st_mtime != time1) e(10);
  } else {
	Stat("foo", &st);
	if (st.st_atime > time2) e(11);
	if (st.st_mtime > time2) e(12);
	Time(&time2);
	if (st.st_atime < time1) e(13);
	if (st.st_mtime < time1) e(14);
  }
  if (st.st_ctime < time1) e(15);
  if (st.st_ctime > time2) e(16);

  System("rm -rf ../DIR_35/*");
}
예제 #25
0
파일: rpmlua.c 프로젝트: cobexer/RPM5
/*@-globs -mods@*/	/* XXX hide rpmGlobalMacroContext mods for now. */
rpmlua rpmluaNew(void)
{
    rpmlua lua = rpmluaGetPool(_rpmluaPool);
    lua_State *L = lua_open();
    /*@-readonlytrans -nullassign @*/
    /*@observer@*/ /*@unchecked@*/
    static const luaL_reg lualibs[] = {
        /* standard LUA libraries */
        {"", luaopen_base},
        /* XXX 5.1.4 internal has not */
#if defined(LUA_COLIBNAME) && LUA_VERSION_NUM > 501
        {LUA_COLIBNAME, luaopen_coroutine},
#endif
#if defined(LUA_TABLIBNAME)
        {LUA_TABLIBNAME, luaopen_table},
#endif
#if defined(LUA_IOLIBNAME)
        {LUA_IOLIBNAME, luaopen_io},
#endif
#if defined(LUA_OSLIBNAME)
        {LUA_OSLIBNAME, luaopen_os},
#endif
#if defined(LUA_STRLIBNAME)
        {LUA_STRLIBNAME, luaopen_string},
#endif
#if defined(LUA_BITLIBNAME)	/* XXX lua >= 5.2.0 only */
        {LUA_BITLIBNAME, luaopen_bit32},
#endif
#if defined(LUA_MATHLIBNAME)
        {LUA_MATHLIBNAME, luaopen_math},
#endif
#if defined(LUA_DBLIBNAME)
        {LUA_DBLIBNAME, luaopen_debug},
#endif
#if defined(LUA_LOADLIBNAME)
        {LUA_LOADLIBNAME, luaopen_package},
#endif
#ifdef	WITH_SYCK
        {"lsyck", luaopen_syck},
#endif	/* WITH_SYCK */
        /* local LUA libraries (RPM only) */
#ifdef WITH_LUA_INTERNAL
        {"posix", luaopen_posix},
#ifdef	HACK
        {"rex_posix", luaopen_rex_posix},
        {"rex_pcre", luaopen_rex_pcre},
#endif
        {"uuid", luaopen_uuid},
        {"wrs", luaopen_wrs},
#ifdef	USE_LUA_CRYPTO		/* XXX external lua modules instead. */
        {"crypto", luaopen_crypto},
        {"lxp", luaopen_lxp},
#endif
#ifdef	USE_LUA_SOCKET		/* XXX external lua modules instead. */
        {"socket", luaopen_socket_core},
#endif
        {"local", luaopen_local},
#endif
        {"rpm", luaopen_rpm},
        {NULL, NULL},
    };
    /*@=readonlytrans =nullassign @*/
    /*@observer@*/ /*@unchecked@*/
    const luaL_reg *lib = lualibs;
    char *path_buf;
    char *path_next;
    char *path;

    lua->L = L;
    lua->pushsize = 0;
    lua->storeprint = 0;
    /* XXX TODO: use an rpmiob here. */
    lua->printbufsize = 0;
    lua->printbufused = 0;
    lua->printbuf = NULL;

    for (; lib->name; lib++) {
        /*@-noeffectuncon@*/
        lua_pushcfunction(L, lib->func);
        lua_pushstring(L, lib->name);
        lua_call(L, 1, 0);
        /*@=noeffectuncon@*/
    }
    {   const char * _lua_path = rpmGetPath(rpmluaPath, NULL);
        if (_lua_path != NULL) {
            lua_pushliteral(L, "LUA_PATH");
            lua_pushstring(L, _lua_path);
            _lua_path = _free(_lua_path);
        }
    }
#if defined(LUA_GLOBALSINDEX)
    lua_rawset(L, LUA_GLOBALSINDEX);
#else
    lua_pushglobaltable(L);
#endif
    lua_pushliteral(L, "print");
    lua_pushcfunction(L, rpm_print);
#if defined(LUA_GLOBALSINDEX)
    lua_rawset(L, LUA_GLOBALSINDEX);
#else
    lua_pushglobaltable(L);
#endif
    rpmluaSetData(lua, "lua", lua);

    /* load all standard RPM Lua script files */
    path_buf = xstrdup(rpmluaFiles);
    for (path = path_buf; path != NULL && *path != '\0'; path = path_next) {
        const char **av;
        struct stat st;
        int ac, i;

        /* locate start of next path element */
        path_next = strchr(path, ':');
        if (path_next != NULL && *path_next == ':')
            *path_next++ = '\0';
        else
            path_next = path + strlen(path);

        /* glob-expand the path element */
        ac = 0;
        av = NULL;
        if ((i = rpmGlob(path, &ac, &av)) != 0)
            continue;

        /* work-off each resulting file from the path element */
        for (i = 0; i < ac; i++) {
            const char *fn = av[i];
            if (fn[0] == '@' /* attention */) {
                fn++;
#if defined(RPM_VENDOR_OPENPKG) /* stick-with-rpm-file-sanity-checking */ || \
    !defined(POPT_ERROR_BADCONFIG)	/* XXX POPT 1.15 retrofit */
                if (!rpmSecuritySaneFile(fn))
#else
                if (!poptSaneFile(fn))
#endif
                {
                    rpmlog(RPMLOG_WARNING, "existing RPM Lua script file \"%s\" considered INSECURE -- not loaded\n", fn);
                    /*@innercontinue@*/ continue;
                }
            }
            if (Stat(fn, &st) != -1)
                (void)rpmluaRunScriptFile(lua, fn);
            av[i] = _free(av[i]);
        }
        av = _free(av);
    }
    path_buf = _free(path_buf);

    return ((rpmlua)rpmioLinkPoolItem((rpmioItem)lua, __FUNCTION__, __FILE__, __LINE__));
}
예제 #26
0
파일: p4a.c 프로젝트: Dreamgoing/myGeekos
void Main(void)
{
    int fd;
    int ret;
    int read;
    struct VFS_File_Stat stat;
    char buffer[47];

    /* test set effective uid */
    ret = SetEffectiveUid(33);
    if (ret != 0) {
        Print ("invalid return code for first set euid\n");
    } else {
        Print("Passed Test #1\n");
    }
    ret = SetEffectiveUid(34);
    if (ret == 0) {
        Print ("invalid return code for second set euid\n");
    } else {
        Print("Passed Test #2\n");
    }

    ret = Open("/nosuchmount", O_READ);
    if (ret != -1) {
        Print ("invalid return code open of invalid mount point\n");
    } else {
        Print("Passed Test #3\n");
    }

    fd = Open("/c/a.exe", O_READ);
    if (fd != 0) {
        Print ("invalid return code (%d) for open 0th file\n", ret);
    } else {
        Print("Passed Test #4\n");
    }

    ret = Write(fd, buffer, sizeof(buffer));
    if (ret != -1) {
        Print ("invalid return code (%d) for write to readonly file\n", ret);
    } else {
        Print("Passed Test #5\n");
    }

    ret = Read(fd, buffer, sizeof(buffer));
    if (ret != sizeof(buffer)) {
        Print ("invalid return code (%d) for read at start of file\n", ret);
    } else {
        Print("Passed Test #6\n");
    }

    read = 0;
    while (ret > 0) {
	read += ret;
	ret = Read(fd, buffer, sizeof(buffer));
    }

    ret = Stat(93, &stat);
    if (ret != -1) {
        Print ("invalid return code (%d) for stat of non-open file\n", ret);
    } else {
        Print("Passed Test #7\n");
    }

    ret = Stat(fd, &stat);
    if (ret != 0) {
        Print ("invalid return code (%d) for stat of open file\n", ret);
    } else {
        Print("Passed Test #8\n");
    }

    if (read != stat.size) {
        Print ("%d bytes read from file, stat reports %d int file\n", read, stat.size);
    } else {
        Print("Passed Test #9\n");
    }

    ret = Close(72);
    if (ret != -1) {
        Print ("invalid return code (%d) for close of non-open file\n", ret);
    } else {
        Print("Passed Test #10\n");
    }

    ret = Close(fd);
    if (ret != 0) {
        Print ("invalid return code (%d) for close of open file\n", ret);
    } else {
        Print("Passed Test #11\n");
    }
}
예제 #27
0
파일: Parser.cpp 프로젝트: Newky/3rdYear
void Parser::Stat() {
    int type;
    wchar_t* name;
    Obj *obj;
    int adr, adr2, loopstart;
    switch (la->kind) {
    case 1: {
        Ident(name);
        obj = tab->Find(name);
        if (la->kind == 17) {
            Get();
            if (obj->kind != var) Err(L"cannot assign to procedure");
            Expr(type);
            Expect(18);
            if (type != obj->type) Err(L"incompatible types");
            if (obj->level == 0) gen->Emit(STOG, obj->adr);
            else gen->Emit(STO, obj->adr);
        } else if (la->kind == 10) {
            Get();
            Expect(11);
            Expect(18);
            if (obj->kind != proc) Err(L"object is not a procedure");
            gen->Emit(CALL, obj->adr);
        } else SynErr(36);
        break;
    }
    case 1: {
        Ident(name);
        obj = tab->Find(name);
        Expect(17);
        Expr(type);
        Expect(19);
        Expr(type2);
        Expect(20);
        Expr(type3);
        Expect(18);
        break;
    }
    case 21: {
        Get();
        Expect(10);
        Expr(type);
        Expect(11);
        if (type != boolean) Err(L"boolean type expected");
        gen->Emit(FJMP, 0);
        adr = gen->pc - 2;
        Stat();
        if (la->kind == 22) {
            Get();
            gen->Emit(JMP, 0);
            adr2 = gen->pc - 2;
            gen->Patch(adr, gen->pc);
            adr = adr2;
            Stat();
        }
        gen->Patch(adr, gen->pc);
        break;
    }
    case 23: {
        Get();
        loopstart = gen->pc;
        Expect(10);
        Expr(type);
        Expect(11);
        if (type != boolean) Err(L"boolean type expected");
        gen->Emit(FJMP, 0);
        adr = gen->pc - 2;
        Stat();
        gen->Emit(JMP, loopstart);
        gen->Patch(adr, gen->pc);
        break;
    }
    case 24: {
        Get();
        loopstart = gen->pc;
        Expect(10);
        Expr(ty);
        Expect(18);
        Expr(type);
        Expect(18);
        Expr(ty);
        Expect(11);
        if (type != boolean) Err(L"boolean type expected");
        gen->Emit(FJMP, 0);
        adr = gen->pc - 2;
        Stat();
        break;
    }
    case 25: {
        Get();
        Ident(name);
        Expect(18);
        obj = tab->Find(name);
        if (obj->type != integer) Err(L"integer type expected");
        gen->Emit(READ);
        if (obj->level == 0) gen->Emit(STOG, obj->adr);
        else gen->Emit(STO, obj->adr);
        break;
    }
    case 26: {
        Get();
        Expr(type);
        Expect(18);
        if (type != integer) Err(L"integer type expected");
        gen->Emit(WRITE);
        break;
    }
    case 12: {
        Get();
        while (StartOf(1)) {
            if (StartOf(2)) {
                Stat();
            } else {
                VarDecl();
            }
        }
        Expect(13);
        break;
    }
    default:
        SynErr(37);
        break;
    }
}
예제 #28
0
TVerdict CTestSyscalls::doTestStepL()
	{
	int err;
	if(TestStepName() == KCreat)
   		{
   		INFO_PRINTF1(_L("Creat():"));
   		err = Creat();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
	else if(TestStepName() == Kopen1)
		{
		INFO_PRINTF1(_L("open1():"));
		err = open1();
		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
   	   	
	else if(TestStepName() == Kopen2)
		{
		INFO_PRINTF1(_L("open2():"));
		err = open2();
		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Kopen3)
		{
		INFO_PRINTF1(_L("open3():"));
		err = open3();
		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Kopen4)
		{
		INFO_PRINTF1(_L("open4():"));
		err = open4();
		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Kopen5)
		{
		INFO_PRINTF1(_L("open5():"));
		err = open5();
		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Kopen6)
		{
		INFO_PRINTF1(_L("open6():"));
		err = open6();
		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KOpenTruncate1)
		{
		INFO_PRINTF1(_L("OpenTruncate1:"));
		err = OpenTruncate1();
		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KOpenTruncate2)
		{
		INFO_PRINTF1(_L("OpenTruncate2:"));
		err = OpenTruncate2();
		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Kopen7)
   		{
   		INFO_PRINTF1(_L("open7():"));
   		err = open7();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KOpenInAppendMode)
   		{
   		INFO_PRINTF1(_L("OpenInAppendMode():"));
   		err = OpenInAppendMode();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Kwrite1)
		{
   		INFO_PRINTF1(_L("write1():"));
		err = write1();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
	else if(TestStepName() == Kwrite2)
   		{
   		INFO_PRINTF1(_L("write2():"));
   		err = write2();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Kwrite3)
   		{
   		INFO_PRINTF1(_L("write3():"));
   		err = write3();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
	else if(TestStepName() == Kwrite5)
		{
   		INFO_PRINTF1(_L("write5():"));
   		err = write5();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
	else if(TestStepName() == Kread1)
   		{
   		INFO_PRINTF1(_L("read1():"));
   		err = read1();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
	else if(TestStepName() == Kread2)
   		{
		INFO_PRINTF1(_L("read2():"));
   		err = read2();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
	else if(TestStepName() == Kread3)
   		{
		INFO_PRINTF1(_L("read3():"));
   		err = read3();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
	else if(TestStepName() == Kread4)
		{
		INFO_PRINTF1(_L("read4():"));
		err = read4();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
	else if(TestStepName() == KOpendir)
   		{
   	   	INFO_PRINTF1(_L("Opendir():"));
   	   	err = Opendir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KClosedir)
   		{
   	   	INFO_PRINTF1(_L("Closedir():"));
   	   	err = Closedir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KReaddir)
   		{
   	   	INFO_PRINTF1(_L("Readdir():"));
   	   	err = Readdir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KLseek)
   		{
   	   	INFO_PRINTF1(_L("Lseek():"));
   	   	err = Lseek();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KLseek1)
   		{
   	   	INFO_PRINTF1(_L("Lseek1():"));
   	   	err = Lseek1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
    else if(TestStepName() == KAccess)
   		{
   	   	INFO_PRINTF1(_L("Access():"));
   	   	err = Access();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KAccess1)
   		{
   	   	INFO_PRINTF1(_L("Access1():"));
   	   	err = Access1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KDup)
   		{
   	   	INFO_PRINTF1(_L("Dup():"));
   	   	err = Dup();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KDup2)
   		{
   	   	INFO_PRINTF1(_L("Dup2():"));
   	   	err = Dup2();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KRename)
   		{
   	   	INFO_PRINTF1(_L("Rename():"));
   	   	err = Rename();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KRename1)
   		{
   	   	INFO_PRINTF1(_L("Rename1():"));
   	   	err = Rename1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KChmod)
   		{
   	   	INFO_PRINTF1(_L("Chmod():"));
   	   	err = Chmod();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KChmod1)
   		{
   	   	INFO_PRINTF1(_L("Chmod1():"));
   	   	err = Chmod1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
    else if(TestStepName() == KChmod_dir)
   		{
   	   	INFO_PRINTF1(_L("Chmod_dir():"));
   	   	err = Chmod_dir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KFChmod)
   		{
   	   	INFO_PRINTF1(_L("FChmod():"));
   	   	err = FChmod();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KFChmod_dir)
   		{
   	   	INFO_PRINTF1(_L("FChmod_dir():"));
   	   	err = FChmod_dir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KExit)
   		{
   	   	INFO_PRINTF1(_L("Exit():"));
   	   	err = Exit();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KClose)
   		{
   	   	INFO_PRINTF1(_L("Close():"));
   	   	err = Close();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KMkdir)
   		{
   	   	INFO_PRINTF1(_L("Mkdir():"));
   	   	err = Mkdir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KMk_dir)
   		{
   	   	INFO_PRINTF1(_L("Mk_dir():"));
   	   	err = Mk_dir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
	else if(TestStepName() == KRmdir)
   		{
   	   	INFO_PRINTF1(_L("Rmdir():"));
   	   	err = Rmdir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
	else if(TestStepName() == KRm_dir)
   		{
   	   	INFO_PRINTF1(_L("Rm_dir():"));
   	   	err = Rm_dir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
    else if(TestStepName() == KRmdir1)
   		{
   	   	INFO_PRINTF1(_L("Rmdir1():"));
   	   	err = Rmdir1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KRmdir_Chdir)
   		{
   	   	INFO_PRINTF1(_L("Rmdir_Chdir():"));
   	   	err = Rmdir_Chdir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KFsync)
   		{
   	   	INFO_PRINTF1(_L("Fsync():"));
   	   	err = Fsync();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KUtimes)
   		{
   	   	INFO_PRINTF1(_L("Utimes():"));
   	   	err = Utimes();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
   	else if(TestStepName() == KUtime)
   		{
   	   	INFO_PRINTF1(_L("Utime():"));
   	   	err = Utime();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KChdir)
   		{
   	   	INFO_PRINTF1(_L("Chdir():"));
   	   	err = Chdir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KFcntl)
   		{
   	   	INFO_PRINTF1(_L("Fcntl():"));
   	   	err = Fcntl();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KIoctl)
   		{
   	   	INFO_PRINTF1(_L("Ioctl():"));
   	   	err = Ioctl();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KFstat)
   		{
   	   	INFO_PRINTF1(_L("Fstat():"));
   	   	err = Fstat();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KStat)
   		{
   	   	INFO_PRINTF1(_L("Stat():"));
   	   	err = Stat();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KStat1)
   		{
   	   	INFO_PRINTF1(_L("Stat1():"));
   	   	err = Stat1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KStat2)
   		{
   	   	INFO_PRINTF1(_L("Stat2():"));
   	   	err = Stat2();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
	else if(TestStepName() == KStat3)
   		{
   	   	INFO_PRINTF1(_L("Stat3():"));
   	   	err = Stat3();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KGetpid)
   		{
   	   	INFO_PRINTF1(_L("Getpid():"));
   	   	err = Getpid();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KClock)
   		{
   	   	INFO_PRINTF1(_L("Clock():"));
   	   	err = Clock();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KTime)
   		{
   	   	INFO_PRINTF1(_L("Time():"));
   	   	err = Time();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KWaitPid)
   		{
   	   	INFO_PRINTF1(_L("WaitPid():"));
   	   	err = WaitPid();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KReadV)
   		{
   	   	INFO_PRINTF1(_L("ReadV():"));
   	   	err = ReadV();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KWriteV)
   		{
   	   	INFO_PRINTF1(_L("WriteV():"));
   	   	err = WriteV();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KSleep)
   		{
   	   	INFO_PRINTF1(_L("Sleep():"));
   	   	err = Sleep();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
	else if(TestStepName() == KSeekDir)
   		{
   	   	INFO_PRINTF1(_L("SeekDir():"));
   	   	err = SeekDir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KRewindDir)
   		{
   	   	INFO_PRINTF1(_L("RewindDir():"));
   	   	err = RewindDir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KTelldir)
   		{
   	   	INFO_PRINTF1(_L("Telldir():"));
   	   	err = Telldir();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KTestClock)
   		{
   	   	INFO_PRINTF1(_L("TestClock():"));
   	   	err = TestClock();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KCreat2)
   		{
   		INFO_PRINTF1(_L("Creat2():"));
   		err = Creat2();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
   	else if(TestStepName() == Kopen8)
   		{
   		INFO_PRINTF1(_L("open8():"));
   		err = open8();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
   	else if(TestStepName() == KTestStat)
   		{
   		INFO_PRINTF1(_L("KTestStat():"));
   		err = TestStat();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KLseekttytest1)
   		{
   		INFO_PRINTF1(_L("Lseekttytest1():"));
   		err = Lseekttytest1();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KLseekttytest2)
   		{
   		INFO_PRINTF1(_L("Lseekttytest2():"));
   		err = Lseekttytest2();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KWaitPidtest)
   		{
   		INFO_PRINTF1(_L("WaitPidtest():"));
   		err = WaitPidtest();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KWaittest)
   		{
   		INFO_PRINTF1(_L("Waittest():"));
   		err = Waittest();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KOpen_FileDes_Test)
   		{
   		INFO_PRINTF1(_L("Open_FileDes_Test():"));
   		err = Open_FileDes_Test();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Kopenuid)
   		{
   		INFO_PRINTF1(_L("openuid():"));
   		err = openuid();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KMkdir1)
   		{
   	   	INFO_PRINTF1(_L("Mkdir1():"));
   	   	err = Mkdir1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KMkdir2)
   		{
   	   	INFO_PRINTF1(_L("Mkdir2():"));
   	   	err = Mkdir2();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
	else if(TestStepName() == KRename2)
   		{
   	   	INFO_PRINTF1(_L("Rename2():"));
   	   	err = Rename2();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == Ktestfsync)
   		{
   		INFO_PRINTF1(_L("testfsync():"));
   		err = testfsync();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Ktestrename)
   		{
   		INFO_PRINTF1(_L("testrename():"));
   		err = testrename();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Ktestopenvalidate)
   		{
   		INFO_PRINTF1(_L("testopenvalidate():"));
   		err = testopenvalidate();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == Ksync_safe)
   		{
   		INFO_PRINTF1(_L("sync_safe():"));
   		err = sync_safe();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
   	else if(TestStepName() == KFstat1)
   		{
   	   	INFO_PRINTF1(_L("Fstat1():"));
   	   	err = Fstat1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KUtimes1)
   		{
   	   	INFO_PRINTF1(_L("Utimes1():"));
   	   	err = Utimes1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else if(TestStepName() == KMkdir_test1)
   		{
   	   	INFO_PRINTF1(_L("Mkdir_test1():"));
   	   	err = Mkdir_test1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KChmod_test)
   		{
   	   	INFO_PRINTF1(_L("Chmod_test():"));
   	   	err = Chmod_test();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
	else if(TestStepName() == KChdir1)
   		{
   	   	INFO_PRINTF1(_L("Chdir1():"));
   	   	err = Chdir1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}   
   	else if(TestStepName() == KRmdir2)
   		{
   	   	INFO_PRINTF1(_L("Rmdir2():"));
   	   	err = Rmdir2();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KRename_test)
   		{
   	   	INFO_PRINTF1(_L("Rename_test():"));
   	   	err = Rename_test();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KRename3)
   		{
   	   	INFO_PRINTF1(_L("Rename3():"));
   	   	err = Rename3();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
   	else if(TestStepName() == KCreat1)
   		{
   		INFO_PRINTF1(_L("Creat1():"));
   		err = Creat1();
   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   		}
   	else if(TestStepName() == KReadV1)
   		{
   	   	INFO_PRINTF1(_L("ReadV1():"));
   	   	err = ReadV1();
   	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   	}
 	else if(TestStepName() == KUtimes2)
    		{
    	   	INFO_PRINTF1(_L("Utimes2():"));
    	   	err = Utimes2();
    	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
 		}
 	else if(TestStepName() == KStat_test)
    		{
    	   	INFO_PRINTF1(_L("Stat_test():"));
    	   	err = Stat_test();
    	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
    	   	}
    	else if(TestStepName() == KMkdir_test2)
    		{
    	   	INFO_PRINTF1(_L("Mkdir_test2():"));
    	   	err = Mkdir_test2();
    	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
    	   	}
    	else if(TestStepName() == KChmod2)
    		{
    	   	INFO_PRINTF1(_L("Chmod2():"));
    	   	err = Chmod2();
    	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
    	   	}
    	else if(TestStepName() == KChdir2)
    		{
    	   	INFO_PRINTF1(_L("Chdir2():"));
    	   	err = Chdir2();
    	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
    	   	} 
    	else if(TestStepName() == KRename4)
    		{
    	   	INFO_PRINTF1(_L("Rename4():"));
    	   	err = Rename4();
    	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
    	   	}
 	else if(TestStepName() == KRename5)
    		{
    	   	INFO_PRINTF1(_L("Rename5():"));
    	   	err = Rename5();
    	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
    	   	}  
 	else if(TestStepName() == KRmdir3)
    		{
    	   	INFO_PRINTF1(_L("Rmdir3():"));
    	   	err = Rmdir3();
    	   	SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
    	   	}  
    	else if(TestStepName() == Kread5)
 		{
 		INFO_PRINTF1(_L("read5():"));
 		err = read5();
    		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
    		} 	   	 
	return TestStepResult(); 
	}
예제 #29
0
int omi_prc_conn(omi_conn *cptr, char *xend, char *buff, char *bend)
{
    omi_si	si, eightbit, chartran, ss_len, ext_cnt;
    omi_li	li_min, li_max, ext;
    uns_short	li_val;
    int		len, i;
    char	*bptr, *eptr;
    char	*ag_name, *ag_pass, *s;

    bptr = buff;

/*  Version numbers */
    OMI_SI_READ(&si, cptr->xptr);
    if (si.value != OMI_PROTO_MAJOR)
	return -OMI_ER_SE_VRSNOTSUPP;
    OMI_SI_WRIT(OMI_PROTO_MAJOR, bptr);
/*  XXX minor version numbers */
    OMI_SI_READ(&si, cptr->xptr);
    OMI_SI_WRIT(OMI_PROTO_MINOR, bptr);

/*  Minimum and maximum parameters */

/*  Data */
    OMI_LI_READ(&li_min, cptr->xptr);
    if (OMI_MAX_DATA < li_min.value)
    {
	cptr->state = OMI_ST_CLOS;
	return -OMI_ER_SE_LENMIN;
    }
    OMI_LI_READ(&li_max, cptr->xptr);
    li_val = MIN(li_max.value, OMI_MAX_DATA);
    OMI_LI_WRIT(li_val, bptr);

/*  Subscript */
    OMI_LI_READ(&li_min, cptr->xptr);
    if (OMI_MAX_SUBSCR < li_min.value)
    {
	cptr->state = OMI_ST_CLOS;
	return -OMI_ER_SE_LENMIN;
    }
    OMI_LI_READ(&li_max, cptr->xptr);
    li_val = MIN(li_max.value, OMI_MAX_SUBSCR);
    OMI_LI_WRIT(li_val, bptr);

/*  Reference */
    OMI_LI_READ(&li_min, cptr->xptr);
    if (OMI_MAX_REF < li_min.value)
    {
	cptr->state = OMI_ST_CLOS;
	return -OMI_ER_SE_LENMIN;
    }
    OMI_LI_READ(&li_max, cptr->xptr);
    li_val = MIN(li_max.value, OMI_MAX_REF);
    OMI_LI_WRIT(li_val, bptr);

/*  Message */
    OMI_LI_READ(&li_min, cptr->xptr);
    if (cptr->bsiz < li_min.value)
    {
	cptr->state = OMI_ST_CLOS;
	return -OMI_ER_SE_LENMIN;
    }
    OMI_LI_READ(&li_max, cptr->xptr);
    li_val = MIN(li_max.value, cptr->bsiz);
    OMI_LI_WRIT(li_val, bptr);

/*  Oustanding */
    OMI_LI_READ(&li_min, cptr->xptr);
    if (1 < li_min.value)
    {
	cptr->state = OMI_ST_CLOS;
	return -OMI_ER_SE_LENMIN;
    }
    OMI_LI_READ(&li_max, cptr->xptr);
    li_val = MIN(li_max.value, 1);
    OMI_LI_WRIT(li_val, bptr);

/*  Other parameters */
    OMI_SI_READ(&eightbit, cptr->xptr);
    OMI_SI_WRIT(eightbit.value, bptr);
    OMI_SI_READ(&chartran, cptr->xptr);
    OMI_SI_WRIT(chartran.value, bptr);

/*  Bounds checking */
    if (cptr->xptr > xend || bptr >= bend)
	return -OMI_ER_PR_INVMSGFMT;

/*  Implementation ID (in) */
    OMI_SI_READ(&ss_len,   cptr->xptr);
    cptr->xptr += ss_len.value;

/*  Agent name (in) */
    OMI_SI_READ(&ss_len, cptr->xptr);
    if ((ag_name = (char *) malloc(ss_len.value + 1)) == NULL)
    {
	    OMI_DBG((omi_debug, "%s:  memory allocation error (insufficient resources) while\n", SRVR_NAME));
	    OMI_DBG((omi_debug, "processing connect request from connection %d, %s.\n",
	    		cptr->stats.id, gtcm_hname(&cptr->stats.ai)));
	    return -OMI_ER_DB_UNRECOVER;
    }
    assert(ss_len.value < MAX_USER_NAME && ss_len.value > 0);
    memcpy(ag_name, cptr->xptr, ss_len.value);
    ag_name[ss_len.value] = '\0';
    strcpy(cptr->ag_name, ag_name);
    cptr->xptr += ss_len.value;

/*  Agent password (in) */
    OMI_SI_READ(&ss_len, cptr->xptr);
    if ((ag_pass = (char *) malloc(ss_len.value + 1)) == NULL)
    {
	    OMI_DBG((omi_debug, "%s:  memory allocation error (insufficient resources) while\n", SRVR_NAME));
	    OMI_DBG((omi_debug, "processing connect request from connection %d, %s.\n",
	    		cptr->stats.id, gtcm_hname(&cptr->stats.ai)));
	    return -OMI_ER_DB_UNRECOVER;
    }

    memcpy(ag_pass, cptr->xptr, ss_len.value);
    ag_pass[ss_len.value] = '\0';
    cptr->xptr += ss_len.value;

/* No support for authentication on SCO, Linux, Cygwin, or z/OS at the moment...*/
#if !(defined(SCO) || defined(__linux__) || defined(__CYGWIN__) || defined(__MVS__))
    if (authenticate)  /* verify password and user name */
    {
#ifdef SHADOWPW
	    struct spwd *spass, *getspnam();
	    struct stat buf;
#endif
	    struct passwd *pass;
	    char *pw, *syspw;

	    /* lowercase agent name */
	    for(s = ag_name; *s; s++)
		    if (ISUPPER_ASCII(*s))
			    *s = TOLOWER(*s);

#ifdef SHADOWPW
	    if (!Stat("/etc/shadow", &buf))
	    {
		if ((spass = getspnam(ag_name)) == NULL)
		{
		    if (errno)
		    {
			OMI_DBG((omi_debug, "%s:  error opening /etc/shadow for input\n",
				 SRVR_NAME, ag_name));
			PERROR("/etc/shadow");
			return -OMI_ER_DB_USERNOAUTH;
		    }
		    OMI_DBG((omi_debug, "%s:  user %s not found in /etc/shadow\n",
			     SRVR_NAME, ag_name));
		    return -OMI_ER_DB_USERNOAUTH;
		}
		syspw = spass->sp_pwdp;
	    } else if ((pass = getpwnam(ag_name)) == NULL)
	    {
		    OMI_DBG((omi_debug, "%s:  user %s not found in /etc/passwd\n",
			     SRVR_NAME, ag_name));
		    return -OMI_ER_DB_USERNOAUTH;
	    } else
		syspw = pass->pw_passwd;



#else    /* ndef SHADOWPW */
	    if ((pass = getpwnam(ag_name)) == NULL)
	    {
		    OMI_DBG((omi_debug, "%s:  user %s not found in /etc/passwd\n",
			     SRVR_NAME, ag_name));
		    return -OMI_ER_DB_USERNOAUTH;
	    } else
		syspw = pass->pw_passwd;

#endif   /* SHADOWPW */

	    pw = (char *) crypt(ag_pass, syspw);

	    if (strcmp(pw, syspw) != 0)
	    {
		    OMI_DBG((omi_debug, "%s:  login attempt for user %s failed.\n",
			     SRVR_NAME, ag_name));
		    return -OMI_ER_DB_USERNOAUTH;
	    }
    }
#endif  /* SCO or linux or cygwin or z/OS */


/*  Server name (in) */
    OMI_SI_READ(&ss_len,   cptr->xptr);
    cptr->xptr += ss_len.value;

/*  Implementation ID (out) */
    len = SIZEOF(GTM_RELEASE_NAME) - 1;
    OMI_SI_WRIT(len, bptr);
    (void) memcpy(bptr, GTM_RELEASE_NAME, len);
    bptr += len;
/*  Server name (out) */
    OMI_SI_WRIT(0, bptr);
/*  Server password (out) */
    OMI_SI_WRIT(0, bptr);

/*  Bounds checking */
    if (cptr->xptr > xend || bptr >= bend)
	return -OMI_ER_PR_INVMSGFMT;

/*  Extensions (in) -- count through them */
    OMI_SI_READ(&ext_cnt, cptr->xptr);
    for (i = 0; i < ext_cnt.value; i++)
    {
	OMI_LI_READ(&ext, cptr->xptr);
	cptr->exts |= (1 << (ext.value - 1));
    }

/*  Mask off extensions we don't support */
    cptr->exts &= OMI_EXTENSIONS;

/*  Negotiate extension combinations */
    if (cptr->exts & OMI_XTF_RC && cptr->exts & OMI_XTF_BUNCH)
	cptr->exts &= ~OMI_XTF_BUNCH;
#ifdef GTCM_RC
    if (cptr->exts & OMI_XTF_RC)
	cptr->of = rc_oflow_alc();
#endif /* defined(GTCM_RC) */

/*  Extensions (out) */
    eptr  = bptr;
    bptr += OMI_SI_SIZ;
    i     = 0;
    if (cptr->exts & OMI_XTF_BUNCH)
    {
	OMI_LI_WRIT(OMI_XTN_BUNCH, bptr);
	i++;
    }
    if (cptr->exts & OMI_XTF_GGR)
    {
	OMI_LI_WRIT(OMI_XTN_GGR, bptr);
	i++;
    }
    if (cptr->exts & OMI_XTF_NEWOP)
    {
	OMI_LI_WRIT(OMI_XTN_NEWOP, bptr);
	i++;
    }
    if (cptr->exts & OMI_XTF_RC)
    {
	OMI_LI_WRIT(OMI_XTN_RC, bptr);
	i++;
    }
/*  Number of extensions */
    OMI_SI_WRIT(i, eptr);

/*  Bounds checking */
    if (cptr->xptr > xend || bptr >= bend)
	return -OMI_ER_PR_INVMSGFMT;

/*  Change the state of the connection */
    cptr->state = OMI_ST_CONN;

    return (int)(bptr - buff);

}
예제 #30
0
int tBigDir() {
    int retC, retD, fi, retS;
    char fname[50];
    struct VFS_File_Stat s;

    retC = Create_Directory("/d/bigdir");
    if (retC == EEXIST) {
        Delete("/d/bigdir", false);
        retC = Create_Directory("/d/bigdir");
    }
    if (retC != 0) {
        Print("couldn't create /d/bigdir: %d\n", retC);
        return -1;
    }

    for (fi = 0; fi < 100; fi++) {
        int fd;

        snprintf(fname, 50, "/d/bigdir/%04dabcdefghijklmnopqrstuvwxyz%04d",
                 fi, fi);
        Print((fi % 25 == 0) ? ":" : ".");
        fd = Open(fname, O_WRITE | O_CREATE);
        if (fd < 0) {
            Print("bad open/creat at %d\n", fi);
            return -1;
        }
        if (Close(fd) < 0) {
            Print("failed to close");
            return -1;
        }
        retS = Stat(fname, &s);
        if (retS < 0) {
            Print("bad stat at %d\n", fi);
            return -1;
        }
    }

    snprintf(fname, 50, "/d/bigdir/%04dabcdefghijklmnopqrstuvwxyz%04d", fi,
             fi);
    retS = Stat(fname, &s);
    if (retS == 0) {
        Print("bad extra stat at %d\n", fi);
        return -1;
    }

    for (fi = 0; fi < 100; fi++) {
        snprintf(fname, 50, "/d/bigdir/%04dabcdefghijklmnopqrstuvwxyz%04d",
                 fi, fi);
        Print((fi % 25 == 0) ? ":" : ".");
        (void)Delete(fname, false);
        retS = Stat(fname, &s);
        if (retS == 0) {
            return -1;
        }
    }

    retD = Delete("/d/bigdir", false);
    if (retD != 0) {
        Print("failed to remove /d/bigdir: %d", retD);
        return retD;
    }

    return 0;
}