]> git.sur5r.net Git - bacula/bacula/commitdiff
Move some variables to eliminate Solaris 2.6 compiler warnings.
authorKern Sibbald <kern@sibbald.com>
Fri, 24 Dec 2004 09:26:23 +0000 (09:26 +0000)
committerKern Sibbald <kern@sibbald.com>
Fri, 24 Dec 2004 09:26:23 +0000 (09:26 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1777 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/findlib/attribs.c
bacula/src/lib/bnet.c
bacula/src/lib/bsys.c

index ad867702f87a20dd9aad7039c553d096fad4ebf3..845f78c9cb396a889d6a1d7380cd353a2801dd0f 100755 (executable)
@@ -334,7 +334,7 @@ bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
       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));
       }
@@ -352,20 +352,20 @@ bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
       /* 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;
       }
@@ -375,7 +375,7 @@ bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
        */
       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;
       }
@@ -389,7 +389,7 @@ bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
        */
       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;
       }
@@ -421,6 +421,10 @@ bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
 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) {
@@ -487,13 +491,13 @@ int encode_attribsEx(JCR *jcr, char *attribsEx, FF_PKT *ff_pkt)
 
 /* 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)
 
 
@@ -571,7 +575,7 @@ static bool set_win32_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
                         &atts.ftCreationTime,
                         &atts.ftLastAccessTime,
                         &atts.ftLastWriteTime)) {
-        win_error(jcr, "SetFileTime:", win32_ofile);
+         win_error(jcr, "SetFileTime:", win32_ofile);
       }
       bclose(ofd);
    }
@@ -579,7 +583,7 @@ static bool set_win32_attributes(JCR *jcr, ATTR *attr, BFILE *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);
index d985c82d70b9766846a1499490e5d844d6d98087..b2775faab541221575e275a350df46a2ed61151c 100644 (file)
@@ -53,6 +53,8 @@ extern time_t watchdog_time;
 #define socketClose(fd)          close(fd)
 #endif
 
+static pthread_mutex_t ip_mutex = PTHREAD_MUTEX_INITIALIZER;
+
 /*
  * Read a nbytes from the network.
  * It is possible that the total bytes require in several
@@ -548,7 +550,6 @@ static const char *gethost_strerror()
 }
 
 
-static pthread_mutex_t ip_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 
 static IPADDR *add_any(int family)
index bfd167accfd3cd86ead6d67a73eeeb8637dbb7cc..9f46bad3d82c7b2ab5e095b8c7a73484db0e3329 100644 (file)
 #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)
@@ -258,10 +307,10 @@ void _p(char *file, int line, pthread_mutex_t *m)
       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"));
       }
 
    }
@@ -317,12 +366,12 @@ void create_pid_file(char *dir, const char *progname, int port)
       *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 */
@@ -467,14 +516,14 @@ void drop(char *uid, char *gid)
       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
@@ -483,64 +532,16 @@ void drop(char *uid, char *gid)
    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
@@ -577,11 +578,11 @@ char *bfgets(char *s, int size, FILE *fd)
       *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;