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...
 
const unsigned int retryGapUsec = 500000
 pause before each lock retry More...
 
unsigned int lockAttempts = 0
 how many times to try locking More...
 
bool openByRoot = false
 

Friends

class File
 

Detailed Description

Definition at line 19 of file File.h.

Member Function Documentation

◆ createdIfMissing()

FileOpeningConfig & FileOpeningConfig::createdIfMissing ( )

Definition at line 90 of file File.cc.

References creationMask, Must, and openFlags.

◆ locked()

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

Definition at line 82 of file File.cc.

References lockAttempts.

◆ openedByRoot()

FileOpeningConfig & FileOpeningConfig::openedByRoot ( )
inline

Definition at line 34 of file File.h.

References openByRoot.

◆ ReadOnly()

FileOpeningConfig FileOpeningConfig::ReadOnly ( )
static

Definition at line 32 of file File.cc.

References flockMode, and openFlags.

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

◆ ReadWrite()

FileOpeningConfig FileOpeningConfig::ReadWrite ( )
static

Definition at line 57 of file File.cc.

References flockMode, and openFlags.

Referenced by Instance::WriteOurPid().

Friends And Related Function Documentation

◆ File

friend class File
friend

Definition at line 39 of file File.h.

Member Data Documentation

◆ creationMask

mode_t FileOpeningConfig::creationMask = 0
private

Definition at line 47 of file File.h.

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

◆ flockMode

int FileOpeningConfig::flockMode = LOCK_UN
private

Definition at line 58 of file File.h.

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

◆ lockAttempts

unsigned int FileOpeningConfig::lockAttempts = 0
private

Definition at line 61 of file File.h.

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

◆ openByRoot

bool FileOpeningConfig::openByRoot = false
private

Definition at line 62 of file File.h.

Referenced by openedByRoot().

◆ openFlags

int FileOpeningConfig::openFlags = 0
private

Definition at line 48 of file File.h.

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

◆ openMode

mode_t FileOpeningConfig::openMode = 0644
private

Definition at line 49 of file File.h.

Referenced by File::open().

◆ retryGapUsec

const unsigned int FileOpeningConfig::retryGapUsec = 500000
private

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