libcsdbg  1.28
C++ exception (and generic) stack trace debug library
bool csdbg::util::is_writable ( const fileinfo_t inf)
static

Check if the process has write access to a file.

Parameters
[in]infthe file info
Returns
true if it is writable, false otherwise

Definition at line 464 of file util.cpp.

References likely.

Referenced by csdbg::filebuf::open(), and csdbg::sttybuf::open().

465 {
466  if ( likely(geteuid() == inf.st_uid && (inf.st_mode & S_IWUSR)) )
467  return true;
468 
469  if ( likely(getegid() == inf.st_gid && (inf.st_mode & S_IWGRP)) )
470  return true;
471 
472  return inf.st_mode & S_IWOTH;
473 }
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
Definition: config.hpp:344

+ Here is the caller graph for this function: