From 42e913ca9d3d8c4016d9cb2b429fef089eb7852b Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 25 Nov 2002 11:01:38 +0000 Subject: [PATCH] Win32 tweaks -- kes25Nov02 git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@210 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/cats/bdb_find.c | 8 +++---- bacula/src/dird/catreq.c | 5 +++-- bacula/src/findlib/attribs.c | 41 +++++++++++++++++++----------------- bacula/src/stored/askdir.c | 2 +- bacula/src/tools/.cvsignore | 1 + bacula/src/tools/Makefile.in | 2 +- bacula/src/tools/testfind.c | 3 ++- bacula/src/version.h | 4 ++-- 8 files changed, 36 insertions(+), 30 deletions(-) diff --git a/bacula/src/cats/bdb_find.c b/bacula/src/cats/bdb_find.c index d9838b0adf..2c51a77094 100644 --- a/bacula/src/cats/bdb_find.c +++ b/bacula/src/cats/bdb_find.c @@ -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); diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index f8ef8ed748..bdb8542334 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -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); } diff --git a/bacula/src/findlib/attribs.c b/bacula/src/findlib/attribs.c index c35aaed4c4..5471759308 100755 --- a/bacula/src/findlib/attribs.c +++ b/bacula/src/findlib/attribs.c @@ -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 */ diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index bbb5a1c3e3..64df91039f 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -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; } diff --git a/bacula/src/tools/.cvsignore b/bacula/src/tools/.cvsignore index 027594ee14..e930f3386c 100644 --- a/bacula/src/tools/.cvsignore +++ b/bacula/src/tools/.cvsignore @@ -1,3 +1,4 @@ Makefile dbcheck smtp +testfind diff --git a/bacula/src/tools/Makefile.in b/bacula/src/tools/Makefile.in index e32067c6d7..22408a6233 100644 --- a/bacula/src/tools/Makefile.in +++ b/bacula/src/tools/Makefile.in @@ -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 " " diff --git a/bacula/src/tools/testfind.c b/bacula/src/tools/testfind.c index 7182fdc22c..c185f7e9c9 100644 --- a/bacula/src/tools/testfind.c +++ b/bacula/src/tools/testfind.c @@ -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; } diff --git a/bacula/src/version.h b/bacula/src/version.h index b96fda4f3d..c401accee0 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -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 -- 2.39.5