fsize = blseek(ofd, 0, SEEK_CUR);
bclose(ofd); /* first close file */
if (fsize > 0 && fsize != attr->statp.st_size) {
- Jmsg3(jcr, M_ERROR, 0, _("File size of restored file %s not correct. Original %s, restored %s.\n"),
+ Jmsg3(jcr, M_ERROR, 0, _("File size of restored file %s not correct. Original %s, restored %s.\n"),
attr->ofname, edit_uint64(attr->statp.st_size, ec1),
edit_uint64(fsize, ec2));
}
/* Change owner of link, not of real file */
if (lchown(attr->ofname, attr->statp.st_uid, attr->statp.st_gid) < 0) {
berrno be;
- Jmsg2(jcr, M_ERROR, 0, _("Unable to set file owner %s: ERR=%s\n"),
+ Jmsg2(jcr, M_ERROR, 0, _("Unable to set file owner %s: ERR=%s\n"),
attr->ofname, be.strerror());
ok = false;
}
} else {
if (chown(attr->ofname, attr->statp.st_uid, attr->statp.st_gid) < 0) {
berrno be;
- Jmsg2(jcr, M_ERROR, 0, _("Unable to set file owner %s: ERR=%s\n"),
+ Jmsg2(jcr, M_ERROR, 0, _("Unable to set file owner %s: ERR=%s\n"),
attr->ofname, be.strerror());
ok = false;
}
if (chmod(attr->ofname, attr->statp.st_mode) < 0) {
berrno be;
- Jmsg2(jcr, M_ERROR, 0, _("Unable to set file modes %s: ERR=%s\n"),
+ Jmsg2(jcr, M_ERROR, 0, _("Unable to set file modes %s: ERR=%s\n"),
attr->ofname, be.strerror());
ok = false;
}
*/
if (utime(attr->ofname, &ut) < 0) {
berrno be;
- Jmsg2(jcr, M_ERROR, 0, _("Unable to set file times %s: ERR=%s\n"),
+ Jmsg2(jcr, M_ERROR, 0, _("Unable to set file times %s: ERR=%s\n"),
attr->ofname, be.strerror());
ok = false;
}
*/
if (chflags(attr->ofname, attr->statp.st_flags) < 0) {
berrno be;
- Jmsg2(jcr, M_ERROR, 0, _("Unable to set file flags %s: ERR=%s\n"),
+ Jmsg2(jcr, M_ERROR, 0, _("Unable to set file flags %s: ERR=%s\n"),
attr->ofname, be.strerror());
ok = false;
}
int encode_attribsEx(JCR *jcr, char *attribsEx, FF_PKT *ff_pkt)
{
#ifdef HAVE_DARWIN_OS
+ /*
+ * We save the Mac resource fork length so that on a
+ * restore, we can be sure we put back the whole resource.
+ */
char *p;
p = attribsEx;
if (ff_pkt->flags & FO_HFSPLUS) {
/* Define attributes that are legal to set with SetFileAttributes() */
#define SET_ATTRS ( \
- FILE_ATTRIBUTE_ARCHIVE| \
- FILE_ATTRIBUTE_HIDDEN| \
- FILE_ATTRIBUTE_NORMAL| \
- FILE_ATTRIBUTE_NOT_CONTENT_INDEXED| \
- FILE_ATTRIBUTE_OFFLINE| \
- FILE_ATTRIBUTE_READONLY| \
- FILE_ATTRIBUTE_SYSTEM| \
+ FILE_ATTRIBUTE_ARCHIVE| \
+ FILE_ATTRIBUTE_HIDDEN| \
+ FILE_ATTRIBUTE_NORMAL| \
+ FILE_ATTRIBUTE_NOT_CONTENT_INDEXED| \
+ FILE_ATTRIBUTE_OFFLINE| \
+ FILE_ATTRIBUTE_READONLY| \
+ FILE_ATTRIBUTE_SYSTEM| \
FILE_ATTRIBUTE_TEMPORARY)
&atts.ftCreationTime,
&atts.ftLastAccessTime,
&atts.ftLastWriteTime)) {
- win_error(jcr, "SetFileTime:", win32_ofile);
+ win_error(jcr, "SetFileTime:", win32_ofile);
}
bclose(ofd);
}
Dmsg1(100, "SetFileAtts %s\n", attr->ofname);
if (!(atts.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
if (!SetFileAttributes(win32_ofile, atts.dwFileAttributes & SET_ATTRS)) {
- win_error(jcr, "SetFileAttributes:", win32_ofile);
+ win_error(jcr, "SetFileAttributes:", win32_ofile);
}
}
free_pool_memory(win32_ofile);
#include <grp.h>
#endif
+static pthread_mutex_t timer_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t timer = PTHREAD_COND_INITIALIZER;
+
+/*
+ * This routine will sleep (sec, microsec). Note, however, that if a
+ * signal occurs, it will return early. It is up to the caller
+ * to recall this routine if he/she REALLY wants to sleep the
+ * requested time.
+ */
+int bmicrosleep(time_t sec, long usec)
+{
+ struct timespec timeout;
+ struct timeval tv;
+ struct timezone tz;
+ int stat;
+
+ timeout.tv_sec = sec;
+ timeout.tv_nsec = usec * 1000;
+
+#ifdef HAVE_NANOSLEEP
+ stat = nanosleep(&timeout, NULL);
+ if (!(stat < 0 && errno == ENOSYS)) {
+ return stat;
+ }
+ /* If we reach here it is because nanosleep is not supported by the OS */
+#endif
+
+ /* Do it the old way */
+ gettimeofday(&tv, &tz);
+ timeout.tv_nsec += tv.tv_usec * 1000;
+ timeout.tv_sec += tv.tv_sec;
+ while (timeout.tv_nsec >= 1000000000) {
+ timeout.tv_nsec -= 1000000000;
+ timeout.tv_sec++;
+ }
+
+ Dmsg2(200, "pthread_cond_timedwait sec=%d usec=%d\n", sec, usec);
+ /* Note, this unlocks mutex during the sleep */
+ P(timer_mutex);
+ stat = pthread_cond_timedwait(&timer, &timer_mutex, &timeout);
+ if (stat != 0) {
+ berrno be;
+ Dmsg2(200, "pthread_cond_timedwait stat=%d ERR=%s\n", stat,
+ be.strerror(stat));
+ }
+ V(timer_mutex);
+ return stat;
+}
+
/*
* Guarantee that the string is properly terminated */
char *bstrncpy(char *dest, const char *src, int maxlen)
e_msg(file, line, M_ERROR, 0, _("Possible mutex deadlock.\n"));
/* We didn't get the lock, so do it definitely now */
if ((errstat=pthread_mutex_lock(m))) {
- e_msg(file, line, M_ABORT, 0, _("Mutex lock failure. ERR=%s\n"),
+ e_msg(file, line, M_ABORT, 0, _("Mutex lock failure. ERR=%s\n"),
strerror(errstat));
} else {
- e_msg(file, line, M_ERROR, 0, _("Possible mutex deadlock resolved.\n"));
+ e_msg(file, line, M_ERROR, 0, _("Possible mutex deadlock resolved.\n"));
}
}
*pidbuf = 0;
if ((pidfd = open(fname, O_RDONLY|O_BINARY, 0)) < 0 ||
read(pidfd, &pidbuf, sizeof(pidbuf)) < 0 ||
- sscanf(pidbuf, "%d", &oldpid) != 1) {
- Emsg2(M_ERROR_TERM, 0, _("Cannot open pid file. %s ERR=%s\n"), fname, strerror(errno));
+ sscanf(pidbuf, "%d", &oldpid) != 1) {
+ Emsg2(M_ERROR_TERM, 0, _("Cannot open pid file. %s ERR=%s\n"), fname, strerror(errno));
}
/* See if other Bacula is still alive */
if (kill(oldpid, 0) != -1 || errno != ESRCH) {
- Emsg3(M_ERROR_TERM, 0, _("%s is already running. pid=%d\nCheck file %s\n"),
+ Emsg3(M_ERROR_TERM, 0, _("%s is already running. pid=%d\nCheck file %s\n"),
progname, oldpid, fname);
}
/* He is not alive, so take over file ownership */
gid_t gr_list[1];
if ((group = getgrnam(gid)) == NULL) {
- Emsg1(M_ERROR_TERM, 0, _("Could not find specified group: %s\n"), gid);
+ Emsg1(M_ERROR_TERM, 0, _("Could not find specified group: %s\n"), gid);
}
if (setgid(group->gr_gid)) {
- Emsg1(M_ERROR_TERM, 0, _("Could not set specified group: %s\n"), gid);
+ Emsg1(M_ERROR_TERM, 0, _("Could not set specified group: %s\n"), gid);
}
gr_list[0] = group->gr_gid;
if (setgroups(1, gr_list)) {
- Emsg1(M_ERROR_TERM, 0, _("Could not set specified group: %s\n"), gid);
+ Emsg1(M_ERROR_TERM, 0, _("Could not set specified group: %s\n"), gid);
}
}
#endif
if (uid) {
struct passwd *passw;
if ((passw = getpwnam(uid)) == NULL) {
- Emsg1(M_ERROR_TERM, 0, _("Could not find specified userid: %s\n"), uid);
+ Emsg1(M_ERROR_TERM, 0, _("Could not find specified userid: %s\n"), uid);
}
if (setuid(passw->pw_uid)) {
- Emsg1(M_ERROR_TERM, 0, _("Could not set specified userid: %s\n"), uid);
+ Emsg1(M_ERROR_TERM, 0, _("Could not set specified userid: %s\n"), uid);
}
}
#endif
}
-static pthread_mutex_t timer_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t timer = PTHREAD_COND_INITIALIZER;
-
-/*
- * This routine will sleep (sec, microsec). Note, however, that if a
- * signal occurs, it will return early. It is up to the caller
- * to recall this routine if he/she REALLY wants to sleep the
- * requested time.
- */
-int bmicrosleep(time_t sec, long usec)
-{
- struct timespec timeout;
- struct timeval tv;
- struct timezone tz;
- int stat;
-
- timeout.tv_sec = sec;
- timeout.tv_nsec = usec * 1000;
-
-#ifdef HAVE_NANOSLEEP
- stat = nanosleep(&timeout, NULL);
- if (!(stat < 0 && errno == ENOSYS)) {
- return stat;
- }
- /* If we reach here it is because nanosleep is not supported by the OS */
-#endif
-
- /* Do it the old way */
- gettimeofday(&tv, &tz);
- timeout.tv_nsec += tv.tv_usec * 1000;
- timeout.tv_sec += tv.tv_sec;
- while (timeout.tv_nsec >= 1000000000) {
- timeout.tv_nsec -= 1000000000;
- timeout.tv_sec++;
- }
-
- Dmsg2(200, "pthread_cond_timedwait sec=%d usec=%d\n", sec, usec);
- /* Note, this unlocks mutex during the sleep */
- P(timer_mutex);
- stat = pthread_cond_timedwait(&timer, &timer_mutex, &timeout);
- if (stat != 0) {
- berrno be;
- Dmsg2(200, "pthread_cond_timedwait stat=%d ERR=%s\n", stat,
- be.strerror(stat));
- }
- V(timer_mutex);
- return stat;
-}
/* BSDI does not have this. This is a *poor* simulation */
#ifndef HAVE_STRTOLL
*p = 0;
if (ch == '\r') { /* Support for Mac/Windows file format */
ch = fgetc(fd);
- if (ch == '\n') { /* Windows (\r\n) */
+ if (ch == '\n') { /* Windows (\r\n) */
*p++ = ch;
*p = 0;
}
- else { /* Mac (\r only) */
+ else { /* Mac (\r only) */
ungetc(ch, fd); /* Push next character back to fd */
}
break;