Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bareos/bareos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Storz <philipp.storz@bareos.com>2022-11-03 19:49:09 +0300
committerPhilipp Storz <philipp.storz@bareos.com>2022-11-11 22:25:05 +0300
commit0712d53a1bd0942fb8d4a5e09a04f9204ac23c14 (patch)
tree875b6860239a25ac1b853fa074bc505985b8743b
parent3321c531c8e0d54ec9b22e60d32c9207ddb5651c (diff)
BareosFilePacket: rename fid -> filedes
-rw-r--r--core/src/findlib/attribs.cc11
-rw-r--r--core/src/findlib/bfile.cc62
-rw-r--r--core/src/findlib/bfile.h9
-rw-r--r--core/src/findlib/create_file.cc9
4 files changed, 46 insertions, 45 deletions
diff --git a/core/src/findlib/attribs.cc b/core/src/findlib/attribs.cc
index 3db3c5c53..5f20c085b 100644
--- a/core/src/findlib/attribs.cc
+++ b/core/src/findlib/attribs.cc
@@ -206,7 +206,7 @@ static inline bool RestoreFileAttributes(JobControlRecord* jcr,
// Restore owner and group.
#ifdef HAVE_FCHOWN
if (file_is_open) {
- if (fchown(ofd->fid, attr->statp.st_uid, attr->statp.st_gid) < 0
+ if (fchown(ofd->filedes, attr->statp.st_uid, attr->statp.st_gid) < 0
&& !suppress_errors) {
BErrNo be;
@@ -231,7 +231,7 @@ static inline bool RestoreFileAttributes(JobControlRecord* jcr,
// Restore filemode.
#ifdef HAVE_FCHMOD
if (file_is_open) {
- if (fchmod(ofd->fid, attr->statp.st_mode) < 0 && !suppress_errors) {
+ if (fchmod(ofd->filedes, attr->statp.st_mode) < 0 && !suppress_errors) {
BErrNo be;
Jmsg2(jcr, M_ERROR, 0, _("Unable to set file modes %s: ERR=%s\n"),
@@ -266,7 +266,7 @@ static inline bool RestoreFileAttributes(JobControlRecord* jcr,
restore_times[1].tv_sec = attr->statp.st_mtime;
restore_times[1].tv_usec = 0;
- if (futimes(ofd->fid, restore_times) < 0 && !suppress_errors) {
+ if (futimes(ofd->filedes, restore_times) < 0 && !suppress_errors) {
BErrNo be;
Jmsg2(jcr, M_ERROR, 0, _("Unable to set file times %s: ERR=%s\n"),
@@ -283,7 +283,7 @@ static inline bool RestoreFileAttributes(JobControlRecord* jcr,
restore_times[1].tv_sec = attr->statp.st_mtime;
restore_times[1].tv_nsec = 0;
- if (futimens(ofd->fid, restore_times) < 0 && !suppress_errors) {
+ if (futimens(ofd->filedes, restore_times) < 0 && !suppress_errors) {
BErrNo be;
Jmsg2(jcr, M_ERROR, 0, _("Unable to set file times %s: ERR=%s\n"),
@@ -626,7 +626,8 @@ static bool set_win32_attributes(JobControlRecord* jcr,
if (!(p_SetFileAttributesW || p_SetFileAttributesA)) { return false; }
if (!p || !*p) { /* we should have attributes */
- Dmsg2(100, "Attributes missing. of=%s ofd=%d\n", attr->ofname, ofd->fid);
+ Dmsg2(100, "Attributes missing. of=%s ofd=%d\n", attr->ofname,
+ ofd->filedes);
if (IsBopen(ofd)) { bclose(ofd); }
return false;
} else {
diff --git a/core/src/findlib/bfile.cc b/core/src/findlib/bfile.cc
index 56bcd9585..09bd9f7a2 100644
--- a/core/src/findlib/bfile.cc
+++ b/core/src/findlib/bfile.cc
@@ -373,7 +373,7 @@ extern "C" HANDLE get_osfhandle(int fd);
void binit(BareosFilePacket* bfd)
{
new (bfd) BareosFilePacket();
- bfd->fid = -1;
+ bfd->filedes = -1;
bfd->use_backup_api = have_win32_api();
}
@@ -944,7 +944,7 @@ boffset_t blseek(BareosFilePacket* bfd, boffset_t offset, int whence)
*
* ===============================================================
*/
-void binit(BareosFilePacket* bfd) { bfd->fid = -1; }
+void binit(BareosFilePacket* bfd) { bfd->filedes = -1; }
bool have_win32_api() { return false; /* no can do */ }
@@ -1046,37 +1046,37 @@ int bopen(BareosFilePacket* bfd,
if (bfd->cmd_plugin && plugin_bopen) {
Dmsg1(400, "call plugin_bopen fname=%s\n", fname);
- bfd->fid = plugin_bopen(bfd, fname, flags, mode);
- Dmsg1(400, "Plugin bopen stat=%d\n", bfd->fid);
- return bfd->fid;
+ bfd->filedes = plugin_bopen(bfd, fname, flags, mode);
+ Dmsg1(400, "Plugin bopen stat=%d\n", bfd->filedes);
+ return bfd->filedes;
}
/* Normal file open */
Dmsg1(debuglevel, "open file %s\n", fname);
/* We use fnctl to set O_NOATIME if requested to avoid open error */
- bfd->fid = open(fname, flags & ~O_NOATIME, mode);
+ bfd->filedes = open(fname, flags & ~O_NOATIME, mode);
/* Set O_NOATIME if possible */
- if (bfd->fid != -1 && flags & O_NOATIME) {
- int oldflags = fcntl(bfd->fid, F_GETFL, 0);
+ if (bfd->filedes != -1 && flags & O_NOATIME) {
+ int oldflags = fcntl(bfd->filedes, F_GETFL, 0);
if (oldflags == -1) {
bfd->BErrNo = errno;
- close(bfd->fid);
- bfd->fid = -1;
+ close(bfd->filedes);
+ bfd->filedes = -1;
} else {
- int ret = fcntl(bfd->fid, F_SETFL, oldflags | O_NOATIME);
+ int ret = fcntl(bfd->filedes, F_SETFL, oldflags | O_NOATIME);
/* EPERM means setting O_NOATIME was not allowed */
if (ret == -1 && errno != EPERM) {
bfd->BErrNo = errno;
- close(bfd->fid);
- bfd->fid = -1;
+ close(bfd->filedes);
+ bfd->filedes = -1;
}
}
}
bfd->BErrNo = errno;
bfd->flags_ = flags;
- Dmsg1(400, "Open file %d\n", bfd->fid);
+ Dmsg1(400, "Open file %d\n", bfd->filedes);
errno = bfd->BErrNo;
bfd->win32Decomplugin_private_context.bIsInData = false;
@@ -1084,14 +1084,14 @@ int bopen(BareosFilePacket* bfd,
# if defined(HAVE_POSIX_FADVISE) && defined(POSIX_FADV_WILLNEED)
/* If not RDWR or WRONLY must be Read Only */
- if (bfd->fid != -1 && !(flags & (O_RDWR | O_WRONLY))) {
- int status = posix_fadvise(bfd->fid, 0, 0, POSIX_FADV_WILLNEED);
- Dmsg3(400, "Did posix_fadvise WILLNEED on %s fid=%d status=%d\n", fname,
- bfd->fid, status);
+ if (bfd->filedes != -1 && !(flags & (O_RDWR | O_WRONLY))) {
+ int status = posix_fadvise(bfd->filedes, 0, 0, POSIX_FADV_WILLNEED);
+ Dmsg3(400, "Did posix_fadvise WILLNEED on %s filedes=%d status=%d\n", fname,
+ bfd->filedes, status);
}
# endif
- return bfd->fid;
+ return bfd->filedes;
}
# ifdef HAVE_DARWIN_OS
@@ -1106,7 +1106,7 @@ int BopenRsrc(BareosFilePacket* bfd, const char* fname, int flags, mode_t mode)
bopen(bfd, rsrc_fname, flags, mode, 0);
FreePoolMemory(rsrc_fname);
- return bfd->fid;
+ return bfd->filedes;
}
# else
int BopenRsrc(BareosFilePacket*, const char*, int, mode_t) { return -1; }
@@ -1116,28 +1116,28 @@ int bclose(BareosFilePacket* bfd)
{
int status;
- if (bfd->fid == -1) { return 0; }
+ if (bfd->filedes == -1) { return 0; }
- Dmsg1(400, "Close file %d\n", bfd->fid);
+ Dmsg1(400, "Close file %d\n", bfd->filedes);
if (bfd->cmd_plugin && plugin_bclose) {
status = plugin_bclose(bfd);
- bfd->fid = -1;
+ bfd->filedes = -1;
bfd->cmd_plugin = false;
} else {
# if defined(HAVE_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED)
/* If not RDWR or WRONLY must be Read Only */
if (!(bfd->flags_ & (O_RDWR | O_WRONLY))) {
/* Tell OS we don't need it any more */
- posix_fadvise(bfd->fid, 0, 0, POSIX_FADV_DONTNEED);
- Dmsg1(400, "Did posix_fadvise DONTNEED on fid=%d\n", bfd->fid);
+ posix_fadvise(bfd->filedes, 0, 0, POSIX_FADV_DONTNEED);
+ Dmsg1(400, "Did posix_fadvise DONTNEED on filedes=%d\n", bfd->filedes);
}
# endif
/* Close normal file */
- status = close(bfd->fid);
+ status = close(bfd->filedes);
bfd->BErrNo = errno;
- bfd->fid = -1;
+ bfd->filedes = -1;
bfd->cmd_plugin = false;
}
@@ -1150,7 +1150,7 @@ ssize_t bread(BareosFilePacket* bfd, void* buf, size_t count)
if (bfd->cmd_plugin && plugin_bread) { return plugin_bread(bfd, buf, count); }
- status = read(bfd->fid, buf, count);
+ status = read(bfd->filedes, buf, count);
bfd->BErrNo = errno;
return status;
}
@@ -1162,12 +1162,12 @@ ssize_t bwrite(BareosFilePacket* bfd, void* buf, size_t count)
if (bfd->cmd_plugin && plugin_bwrite) {
return plugin_bwrite(bfd, buf, count);
}
- status = write(bfd->fid, buf, count);
+ status = write(bfd->filedes, buf, count);
bfd->BErrNo = errno;
return status;
}
-bool IsBopen(BareosFilePacket* bfd) { return bfd->fid >= 0; }
+bool IsBopen(BareosFilePacket* bfd) { return bfd->filedes >= 0; }
boffset_t blseek(BareosFilePacket* bfd, boffset_t offset, int whence)
{
@@ -1176,7 +1176,7 @@ boffset_t blseek(BareosFilePacket* bfd, boffset_t offset, int whence)
if (bfd->cmd_plugin && plugin_bwrite) {
return plugin_blseek(bfd, offset, whence);
}
- pos = (boffset_t)lseek(bfd->fid, offset, whence);
+ pos = (boffset_t)lseek(bfd->filedes, offset, whence);
bfd->BErrNo = errno;
return pos;
}
diff --git a/core/src/findlib/bfile.h b/core/src/findlib/bfile.h
index e88a1ad6e..7575938e2 100644
--- a/core/src/findlib/bfile.h
+++ b/core/src/findlib/bfile.h
@@ -76,7 +76,7 @@ struct BareosFilePacket {
bool encrypted = false; /**< set if using ReadEncryptedFileRaw/WriteEncryptedFileRaw */
int mode = BF_CLOSED; /**< set if file is open */
HANDLE fh = INVALID_HANDLE_VALUE; /**< Win32 file handle */
- int fid = 0; /**< fd if doing Unix style */
+ int filedes = 0; /**< fd if doing Unix style */
LPVOID lplugin_private_context = nullptr; /**< BackupRead/Write context */
PVOID pvContext = nullptr; /**< Encryption context */
POOLMEM* errmsg = nullptr; /**< error message buffer */
@@ -107,7 +107,7 @@ HANDLE BgetHandle(BareosFilePacket* bfd);
/* Basic Unix low level I/O file packet */
/* clang-format off */
struct BareosFilePacket {
- int fid{0}; /**< file id on Unix */
+ int filedes{0}; /**< filedescriptor on Unix */
int flags_{0}; /**< open flags */
int BErrNo{0}; /**< errno */
int32_t lerror{0}; /**< not used - simplies Win32 builds */
@@ -137,10 +137,7 @@ int bopen(BareosFilePacket* bfd,
int flags,
mode_t mode,
dev_t rdev);
-int BopenRsrc(BareosFilePacket* bfd,
- const char* fname,
- int flags,
- mode_t mode);
+int BopenRsrc(BareosFilePacket* bfd, const char* fname, int flags, mode_t mode);
int bclose(BareosFilePacket* bfd);
ssize_t bread(BareosFilePacket* bfd, void* buf, size_t count);
ssize_t bwrite(BareosFilePacket* bfd, void* buf, size_t count);
diff --git a/core/src/findlib/create_file.cc b/core/src/findlib/create_file.cc
index 45ad3d688..c87fec8a2 100644
--- a/core/src/findlib/create_file.cc
+++ b/core/src/findlib/create_file.cc
@@ -223,7 +223,8 @@ int CreateFile(JobControlRecord* jcr,
}
if (IsBopen(bfd)) {
- Qmsg1(jcr, M_ERROR, 0, _("bpkt already open fid=%d\n"), bfd->fid);
+ Qmsg1(jcr, M_ERROR, 0, _("bpkt already open filedes=%d\n"),
+ bfd->filedes);
bclose(bfd);
}
@@ -312,7 +313,8 @@ int CreateFile(JobControlRecord* jcr,
tid = NULL;
}
if (IsBopen(bfd)) {
- Qmsg1(jcr, M_ERROR, 0, _("bpkt already open fid=%d\n"), bfd->fid);
+ Qmsg1(jcr, M_ERROR, 0, _("bpkt already open filedes=%d\n"),
+ bfd->filedes);
}
Dmsg2(400, "open %s flags=%08o\n", attr->ofname, flags);
if ((bopen(bfd, attr->ofname, flags, 0, 0)) < 0) {
@@ -441,7 +443,8 @@ int CreateFile(JobControlRecord* jcr,
*/
if (!IsPortableBackup(bfd)) {
if (IsBopen(bfd)) {
- Qmsg1(jcr, M_ERROR, 0, _("bpkt already open fid=%d\n"), bfd->fid);
+ Qmsg1(jcr, M_ERROR, 0, _("bpkt already open filedes=%d\n"),
+ bfd->filedes);
}
if (bopen(bfd, attr->ofname, O_WRONLY | O_BINARY, 0,
attr->statp.st_rdev)