FileStatus NamenodeProxy::getFileInfo(const std::string & src, bool *exist) { NAMENODE_HA_RETRY_BEGIN(); return namenode->getFileInfo(src, exist); NAMENODE_HA_RETRY_END(); assert(!"should not reach here"); return FileStatus(); }
/* fSyncFile - Attempt to make logical file and physical file the same * * When editing in a network or multi-tasking environment, we need to make * sure that changes made underneath us are properly reflected to the * user. We do this by snapshotting the time-of-last-write and periodically * comparing it with the version on disk. When a mismatch is found, we * prompt the user and give him the opportunity to reread the file * * pFileLoc file structure of interest * fPrompt TRUE => prompt user for permission to refresh, else just * refresh. * * returns TRUE iff the logical file and the physical file are the same. */ flagType fSyncFile ( PFILE pFileLoc, flagType fPrompt ) { if (pFileLoc == NULL) { pFileLoc = pFileHead; } switch (FileStatus (pFileLoc, NULL)) { case FILECHANGED: if (!confirmx("%s has been changed. Refresh? ", pFileLoc->pName)) { /* No, validate this edit session */ SetModTime (pFileLoc); return FALSE; } FileRead (strcpy( buf, pFileLoc->pName ), pFileLoc, TRUE); RSETFLAG (FLAGS (pFileLoc), DIRTY); SETFLAG (fDisplay, RSTATUS); return TRUE; case FILEDELETED: domessage ("File has been deleted"); break; default: break; } return TRUE; }
wxString CEC_PartFile_Tag::GetFileStatusString() const { uint8 nFileStatus = FileStatus(); if ((nFileStatus == PS_HASHING) || (nFileStatus == PS_WAITINGFORHASH)) { return _("Hashing"); } else { switch (nFileStatus) { case PS_COMPLETING: return _("Completing"); case PS_COMPLETE: return _("Complete"); case PS_PAUSED: return _("Paused"); case PS_ERROR: return _("Erroneous"); default: if (SourceXferCount() > 0) { return _("Downloading"); } else { return _("Waiting"); } } // if stopped } }
void FetchFiles::commitOne() { BACKTRACE_BEGIN auto task = _digestDrafts.digestedTaskQueue().get(); if ( task.draft == boost::filesystem::path() ) { TRACE_INFO( "Reenqueueing '" << task.path << "' (" << task.hash << "), it will be verified on each object store before another fetch attempt" ); struct ToVerify reenqueued = { task.path, task.status, task.hash, "verify" }; _fetchQueue.put( std::move( reenqueued ) ); return; } boost::filesystem::path absolute = _directory / task.path; boost::filesystem::rename( task.draft, absolute ); ApplyFileStatus( absolute, task.status ).applyExistingRegular(); ASSERT_VERBOSE( FileStatus( absolute ) == task.status, absolute << ": " << FileStatus( absolute ) << " != " << task.status ); _fetchCompleted += 1; possiblySignalProducerDone(); BACKTRACE_END }
ProcessStatus::ProcessStatus(pid_t processId) { #ifdef __linux String path = Format("/proc/%%/stat") << processId; Ref<File, Owner> file = new File(path); file->open(File::Read); Ref<LineSource, Owner> source = new LineSource(file); String line = source->readLine(); { // extract command name first, because it may contain whitespace int i0 = line->find('(') + 1, i1 = line->find(')'); commandName_ = line->copy(i0, i1); for (int i = i0; i < i1; ++i) line->set(i, 'x'); } Ref<StringList, Owner> parts = line.split(" "); processId_ = parts->at(0).toInt(); parentProcessId_ = parts->at(3).toInt(); processGroupId_ = parts->at(4).toInt(); foregroundProcessGroupId_ = parts->at(7).toInt(); /*{ int code = parts->get(6).toInt(); int major = (code >> 8) & 0xFF; int minor = (code & 0xFF) | ((code >> 20) << 8); // interpretation according to lanana.org if (major == 4) terminalName_ = Format("tty%%") << minor; else if ((136 <= major) && (major <= 143)) terminalName_ = Format("pts/%%") << minor; else if (major == 3) terminalName_ = Format("ttyp%%") << minor; }*/ loginName_ = User(FileStatus(path).ownerId()).loginName(); processStatus_ = parts->at(2)->get(0); file->close(); #else // def __linux #ifdef KERN_PROC2 // e.g. on OpenBSD size_t sz = sizeof(kinfo_proc2); struct kinfo_proc2* proc = (kinfo_proc2*)ftl::malloc(sz); mem::clr(proc, sz); int mib[] = { CTL_KERN, KERN_PROC2, KERN_PROC_PID, processId, sz, 1 }; if (::sysctl(mib, sizeof(mib)/sizeof(mib[0]), proc, &sz, NULL, 0) == -1) FTL_SYSTEM_EXCEPTION; processId_ = proc->p_pid; parentProcessId_ = proc->p_ppid; processGroupId_ = proc->p__pgid; foregroundProcessGroupId_ = proc->p_tpgid; /*const int ttyNameSize = 256; char ttyName[ttyNameSize]; terminalName_ = devname_r(proc->kp_eproc.e_tdev, S_IFCHR, ttyName, ttyNameSize);*/ loginName_ = User(proc->p_ruid).loginName(); commandName_ = proc->p_comm; processStatus_ = proc->p_stat; if (processStatus_ == SIDL) processStatus_ = 'W'; else if (processStatus_ == SRUN) processStatus_ = 'R'; #ifdef SONPROC else if (processStatus_ == SONPROC) processStatus_ = 'R'; #endif else if (processStatus_ == SSLEEP) processStatus_ = 'S'; else if (processStatus_ == SSTOP) processStatus_ = 'T'; else if (processStatus_ == SZOMB) processStatus_ = 'Z'; #ifdef SDEAD else if (processStatus_ == SDEAD) processStatus_ = 'Z'; #endif else processStatus_ = '?'; ftl::free(proc); #else // def KERN_PROC2 struct kinfo_proc* proc; int mib[4]; mib[0] = CTL_KERN; mib[1] = KERN_PROC; mib[2] = KERN_PROC_PID; mib[3] = processId; size_t sz = 0; if (::sysctl(mib, 4, NULL, &sz, NULL, 0) == -1) FTL_SYSTEM_EXCEPTION; proc = (kinfo_proc*)ftl::malloc(sz); mem::clr(proc, sz); if (::sysctl(mib, 4, proc, &sz, NULL, 0) == -1) FTL_SYSTEM_EXCEPTION; processId_ = proc->kp_proc.p_pid; parentProcessId_ = proc->kp_eproc.e_ppid; processGroupId_ = proc->kp_eproc.e_pgid; foregroundProcessGroupId_ = proc->kp_eproc.e_tpgid; /*const int ttyNameSize = 256; char ttyName[ttyNameSize]; terminalName_ = devname_r(proc->kp_eproc.e_tdev, S_IFCHR, ttyName, ttyNameSize);*/ loginName_ = User(proc->kp_eproc.e_pcred.p_ruid).loginName(); commandName_ = proc->kp_proc.p_comm; processStatus_ = proc->kp_proc.p_stat; if (processStatus_ == SIDL) processStatus_ = 'W'; else if (processStatus_ == SRUN) processStatus_ = 'R'; #ifdef SONPROC else if (processStatus_ == SONPROC) processStatus_ = 'R'; #endif #ifdef __MACH__ else if (processStatus_ == SSLEEP) processStatus_ = (proc->kp_proc.sigwait) ? 'S' : 'D'; #else else if (processStatus_ == SSLEEP) processStatus_ = 'S'; #endif else if (processStatus_ == SSTOP) processStatus_ = 'T'; else if (processStatus_ == SZOMB) processStatus_ = 'Z'; #ifdef SDEAD else if (processStatus_ == SDEAD) processStatus_ = 'Z'; #endif else processStatus_ = '?'; ftl::free(proc); #endif // def KERN_PROC2 #endif // def __linux }