]> git.sur5r.net Git - bacula/bacula/commitdiff
Win32 tweaks -- kes25Nov02
authorKern Sibbald <kern@sibbald.com>
Mon, 25 Nov 2002 11:01:38 +0000 (11:01 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 25 Nov 2002 11:01:38 +0000 (11:01 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@210 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/cats/bdb_find.c
bacula/src/dird/catreq.c
bacula/src/findlib/attribs.c
bacula/src/stored/askdir.c
bacula/src/tools/.cvsignore
bacula/src/tools/Makefile.in
bacula/src/tools/testfind.c
bacula/src/version.h

index d9838b0adf9d1bb4b9b8b19326136a899af0d885..2c51a77094c350ab1860d7f8fa9c6c79a4cf731a 100644 (file)
@@ -49,7 +49,7 @@
 #ifdef HAVE_BACULA_DB
 
 /* Forward referenced functions */
-int db_find_job_start_time(B_DB *mdb, JOB_DBR *jr, char *stime);
+int db_find_job_start_time(B_DB *mdb, JOB_DBR *jr, POOLMEM **stime);
 
 /* -----------------------------------------------------------------------
  *
@@ -66,7 +66,7 @@ int db_find_job_start_time(B_DB *mdb, JOB_DBR *jr, char *stime);
  * Returns: 0 on failure
  *         1 on success, jr unchanged, but stime set
  */
-int db_find_job_start_time(B_DB *mdb, JOB_DBR *jr, char *stime)
+int db_find_job_start_time(B_DB *mdb, JOB_DBR *jr, POOLMEM **stime)
 {
    char cmd[MAXSTRING], Name[MAX_NAME_LENGTH], StartTime[MAXSTRING];
    int Type, Level;
@@ -76,7 +76,7 @@ int db_find_job_start_time(B_DB *mdb, JOB_DBR *jr, char *stime)
    int found;
    long addr;
 
-   strcpy(stime, "0000-00-00 00:00:00");   /* default */
+   pm_strcpy(stime, "0000-00-00 00:00:00");   /* default */
    db_lock(mdb);
    if (!bdb_open_jobs_file(mdb)) {
       db_unlock(mdb);
@@ -124,7 +124,7 @@ StartTime=%100s", &JobId, Name, cType, cLevel, StartTime) == 5) {
            /* Reset for next read */
            fseek(mdb->jobfd, addr, SEEK_SET);
            if (found) {
-              strcpy(stime, StartTime);
+              pm_strcpy(stime, StartTime);
               stat = 1;              /* Got a candidate */
                Dmsg5(200, "Got candidate JobId=%d Type=%c Level=%c Name=%s StartTime=%s\n",
                  JobId, Type, Level, Name, StartTime);
index f8ef8ed748900ec304a48abdbe077b329e4dfaf5..bdb854233445853db2451592473fd3cc1c22362e 100644 (file)
@@ -195,11 +195,12 @@ next_volume:
 MediaType=%s\n", mr.PoolId, jcr->PoolId, mr.VolStatus, mr.Slot, mr.MediaType);
         } else { 
            /* Not suitable volume */
-            bnet_fsend(bs, "1998 Volume not appropriate.\n");
+            bnet_fsend(bs, "1998 Volume \"%s\"not appropriate.\n",
+              mr.VolumeName);
         }
 
       } else {
-         bnet_fsend(bs, "1999 Volume Not Found.\n");
+         bnet_fsend(bs, "1999 Volume \"%s\" not found.\n", mr.VolumeName);
       }
 
    
index c35aaed4c4fd864b3b5005586a352a0d6d76264c..5471759308925f402482978396b808bee280ef3a 100755 (executable)
@@ -40,9 +40,9 @@ static
 int set_win32_attributes(void *jcr, char *fname, char *ofile, char *lname, 
                         int type, int stream, struct stat *statp,
                         char *attribsEx, int *ofd);
-void unix_name_to_win32(char *name);
+void unix_name_to_win32(POOLMEM **win32_name, char *name);
 extern "C" HANDLE get_osfhandle(int fd);
-void win_error(void *jcr, char *prefix, char *ofile);
+void win_error(void *jcr, char *prefix, POOLMEM *ofile);
 #endif
 
 
@@ -247,8 +247,7 @@ int encode_attribsEx(void *jcr, char *attribsEx, FF_PKT *ff_pkt)
 
    attribsEx[0] = 0;                 /* no extended attributes */
 
-   pm_strcpy(&ff_pkt->sys_fname, ff_pkt->fname);
-   unix_name_to_win32(ff_pkt->sys_fname);
+   unix_name_to_win32(&ff_pkt->sys_fname, ff_pkt->fname);
    if (!GetFileAttributesEx(ff_pkt->sys_fname, GetFileExInfoStandard,
                            (LPVOID)&atts)) {
       win_error(jcr, "GetFileAttributesEx:", ff_pkt->sys_fname);
@@ -307,6 +306,7 @@ int set_win32_attributes(void *jcr, char *fname, char *ofile, char *lname,
    WIN32_FILE_ATTRIBUTE_DATA atts;
    ULARGE_INTEGER li;
    int fid, stat;
+   POOLMEM *win32_ofile;
 
    if (!p || !*p) {                  /* we should have attributes */
       Dmsg2(100, "Attributes missing. of=%s ofd=%d\n", ofile, *ofd);
@@ -345,6 +345,10 @@ int set_win32_attributes(void *jcr, char *fname, char *ofile, char *lname,
 
    /* At this point, we have reconstructed the WIN32_FILE_ATTRIBUTE_DATA pkt */
 
+   /* Convert to Windows path format */
+   win32_ofile = get_pool_memory(PM_FNAME);
+   unix_name_to_win32(&win32_ofile, ofile);
+
    if (*ofd == -1) {
       Dmsg1(100, "File not open: %s\n", ofile);
       fid = open(ofile, O_RDWR|O_BINARY);   /* attempt to open the file */
@@ -360,23 +364,22 @@ int set_win32_attributes(void *jcr, char *fname, char *ofile, char *lname,
                         &atts.ftLastAccessTime,
                         &atts.ftLastWriteTime);
       if (stat != 1) {
-         win_error(jcr, "SetFileTime:", ofile);
+         win_error(jcr, "SetFileTime:", win32_ofile);
       }
       close(*ofd);
       *ofd = -1;
    }
 
-   /* Bash name to Windows format */
-   unix_name_to_win32(ofile);
    Dmsg1(100, "SetFileAtts %s\n", ofile);
-   stat = SetFileAttributes(ofile, atts.dwFileAttributes & SET_ATTRS);
+   stat = SetFileAttributes(win32_ofile, atts.dwFileAttributes & SET_ATTRS);
    if (stat != 1) {
-      win_error(jcr, "SetFileAttributes:", ofile);
+      win_error(jcr, "SetFileAttributes:", win32_ofile);
    }
+   free_pool_memory(win32_ofile);
    return 1;
 }
 
-void win_error(void *vjcr, char *prefix, char *ofile)
+void win_error(void *vjcr, char *prefix, POOLMEM *win32_ofile)
 {
    JCR *jcr = (JCR *)vjcr; 
    DWORD lerror = GetLastError();
@@ -389,19 +392,19 @@ void win_error(void *vjcr, char *prefix, char *ofile)
                 (LPTSTR)&msg,
                 0,
                 NULL);
-   Dmsg3(100, "Error in %s on file %s: ERR=%s\n", prefix, ofile, msg);
-   Jmsg3(jcr, M_INFO, 0, "Error in %s file %s: ERR=%s\n", prefix, ofile, msg);
+   Dmsg3(100, "Error in %s on file %s: ERR=%s\n", prefix, win32_ofile, msg);
+   Jmsg3(jcr, M_INFO, 0, _("Error in %s file %s: ERR=%s\n"), prefix, win32_ofile, msg);
    LocalFree(msg);
 }
 
-void unix_name_to_win32(char *name)
+/* Cygwin API definition */
+extern "C" void cygwin_conv_to_win32_path(const char *path, char *win32_path);
+
+void unix_name_to_win32(POOLMEM **win32_name, char *name)
 {
-   char *p;
-   for (p=name; *p; p++) {
-      if (*p == '/') {
-         *p = '\\';
-      }
-   }
+   /* One extra byte should suffice, but we take 10 */
+   *win32_name = check_pool_memory_size(*win32_name, strlen(name)+10);
+   cygwin_conv_to_win32_path(name, *win32_name);
 }
 
 #endif /* HAVE_CYGWIN */
index bbb5a1c3e375d0bec8df10845f2c43ab46ab5fad..64df91039f25f19869e6571e6287a219535f567a 100644 (file)
@@ -90,7 +90,7 @@ static int do_request_volume_info(JCR *jcr)
               &vol->VolCatCapacityBytes, vol->VolCatStatus,
               &vol->Slot, &vol->VolCatMaxJobs, &vol->VolCatMaxFiles) != 14) {
 
-       Dmsg1(000, "Bad response from Dir: %s\n", dir->msg);
+       Dmsg1(200, "Bad response from Dir: %s\n", dir->msg);
        Mmsg(&jcr->errmsg, _("Error scanning Dir response: %s\n"), dir->msg);
        return 0;
     }
index 027594ee14d8a79c8dc1afdbf6bc2f65991c9044..e930f3386c485b409652d179db6c810973db33ec 100644 (file)
@@ -1,3 +1,4 @@
 Makefile
 dbcheck
 smtp
+testfind
index e32067c6d71b636d846878d7ebdbf7baa885fa54..22408a62335da409241d19575c4acf7562e6f228 100644 (file)
@@ -36,7 +36,7 @@ EXTRAOBJS = @OBJLIST@
 .c.o:
        $(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $<
 #-------------------------------------------------------------------------
-all: Makefile smtp dbcheck
+all: Makefile smtp dbcheck testfind
        @echo "==== Make of tools is good ===="
        @echo " "
 
index 7182fdc22c59ccfcdc5cbbe7fb40e6925030499d..c185f7e9c9a74cffaebecb82f83bcfcea22fdcea 100644 (file)
@@ -24,6 +24,7 @@ static void usage()
    fprintf(stderr, _(
 "\n"
 "Usage: testfind [-d debug_level] [-] [pattern1 ...]\n"
+"       -a          print extended attributes (Win32 debug)\n"
 "       -dnn        set debug level to nn\n"
 "       -           read pattern(s) from stdin\n"
 "       -?          print this message.\n"
@@ -186,7 +187,7 @@ static int print_file(FF_PKT *ff, void *pkt)
       if (*attr != 0) {
          printf("AttrEx=%s\n", attr);
       }
-      set_attribsEx(NULL, ff->fname, NULL, NULL, ff->type, attr);
+//    set_attribsEx(NULL, ff->fname, NULL, NULL, ff->type, attr);
    }
    return 1;
 }
index b96fda4f3deaeb74b081723785015c58552f1b9f..c401accee0d337eda8046551d1d3ddcaa2613956 100644 (file)
@@ -1,8 +1,8 @@
 /* */
 #define VERSION "1.27"
 #define VSTRING "1"
-#define DATE    "24 November 2002"
-#define LSMDATE "24Nov02"
+#define DATE    "25 November 2002"
+#define LSMDATE "25Nov02"
 
 /* Debug flags */
 #define DEBUG 1