1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
#include "mntent.h"
#include <errno.h>
FILE* setmntent(const char* filename, const char* type) {
(void)filename;
(void)type;
errno = 0;
return nullptr;
}
struct mntent* getmntent(FILE* fp) {
(void)fp;
errno = 0;
return nullptr;
}
int endmntent(FILE* fp) {
(void)fp;
errno = 0;
return 0;
}
/*******************************************************************************
The code tries to find out, if the recording dir is mounted using
option noatime. On WIN32, we dont have this concept of noatime mounts.
It is enough, to
- define _PATH_MOUNTED to some const char*
- let setmntent return nullptr
- let getmntent return nullptr
- let endmntent return 0
- set errno = 0 in all funcs
- define struct mntent with members mnt_dir, mnt_opts
<snip>
time_t cMarkAdStandalone::GetRecordingStart(time_t start, int fd) {
// get recording start from atime of directory (if the volume is mounted with noatime)
struct mntent *ent;
struct stat statbuf;
FILE *mounts = setmntent(_PATH_MOUNTED, "r");
int mlen;
int oldmlen = 0;
bool useatime = false;
while ((ent = getmntent(mounts)) != nullptr) {
if (strstr(directory, ent->mnt_dir)) {
mlen = strlen(ent->mnt_dir);
if (mlen > oldmlen) {
if (strstr(ent->mnt_opts, "noatime")) {
useatime = true;
}
else {
useatime = false;
}
}
oldmlen = mlen;
}
}
endmntent(mounts);
</snap>
*******************************************************************************/
|