How should a file be opened/created? Should it be locked? More...

#include <File.h>

Collaboration diagram for FileOpeningConfig:

Public Member Functions

FileOpeningConfiglocked (unsigned int attempts=5)
 protect concurrent accesses by attempting to obtain an appropriate lock More...
 
FileOpeningConfigcreatedIfMissing ()
 when opening a file for writing, create it if it does not exist More...
 
FileOpeningConfigopenedByRoot ()
 enter_suid() to open the file; leaves suid ASAP after that More...
 

Static Public Member Functions

static FileOpeningConfig ReadOnly ()
 
static FileOpeningConfig ReadWrite ()
 

Private Attributes

mode_t creationMask = 0
 umask() parameter; the default is S_IWGRP|S_IWOTH More...
 
int openFlags = 0
 opening flags; 2nd open(2) parameter More...
 
mode_t openMode = 0644
 access mode; 3rd open(2) parameter More...
 
int flockMode = LOCK_UN
 2nd flock(2) parameter More...
 
unsigned int lockAttempts = 0
 pause before each lock retry More...
 
bool openByRoot = false
 

Static Private Attributes

static const unsigned int RetryGapUsec = 500000
 

Friends

class File
 

Detailed Description

Definition at line 19 of file File.h.

Member Function Documentation

FileOpeningConfig & FileOpeningConfig::createdIfMissing ( )

Definition at line 89 of file File.cc.

References creationMask, Must, and openFlags.

FileOpeningConfig & FileOpeningConfig::locked ( unsigned int  attempts = 5)

Definition at line 81 of file File.cc.

References lockAttempts.

FileOpeningConfig& FileOpeningConfig::openedByRoot ( )
inline

Definition at line 34 of file File.h.

References openByRoot.

FileOpeningConfig FileOpeningConfig::ReadOnly ( )
static

Definition at line 31 of file File.cc.

References flockMode, and openFlags.

Referenced by Instance::Other(), and Instance::ThrowIfAlreadyRunning().

FileOpeningConfig FileOpeningConfig::ReadWrite ( )
static

Definition at line 56 of file File.cc.

References flockMode, and openFlags.

Referenced by Instance::WriteOurPid().

Friends And Related Function Documentation

friend class File
friend

Definition at line 39 of file File.h.

Member Data Documentation

mode_t FileOpeningConfig::creationMask = 0
private

Definition at line 47 of file File.h.

Referenced by createdIfMissing(), and File::open().

int FileOpeningConfig::flockMode = LOCK_UN
private

Definition at line 58 of file File.h.

Referenced by File::lockOnce(), ReadOnly(), and ReadWrite().

unsigned int FileOpeningConfig::lockAttempts = 0
private

how many times to try locking

Definition at line 61 of file File.h.

Referenced by File::lock(), and locked().

bool FileOpeningConfig::openByRoot = false
private

Definition at line 62 of file File.h.

Referenced by openedByRoot().

int FileOpeningConfig::openFlags = 0
private

Definition at line 48 of file File.h.

Referenced by createdIfMissing(), File::open(), ReadOnly(), and ReadWrite().

mode_t FileOpeningConfig::openMode = 0644
private

Definition at line 49 of file File.h.

Referenced by File::open().

const unsigned int FileOpeningConfig::RetryGapUsec = 500000
staticprivate

Definition at line 60 of file File.h.

Referenced by File::lock().


The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors