]> git.sur5r.net Git - bacula/bacula/commitdiff
take out 260char limit for win NT/XP, etc. paths can become 32K characters long now.
authorThorsten Engel <thorsten.engel@matrix-computer.com>
Tue, 28 Feb 2006 15:45:56 +0000 (15:45 +0000)
committerThorsten Engel <thorsten.engel@matrix-computer.com>
Tue, 28 Feb 2006 15:45:56 +0000 (15:45 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2822 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/filed/win32/winbacula.h
bacula/src/findlib/attribs.c
bacula/src/findlib/bfile.c
bacula/src/findlib/create_file.c
bacula/src/lib/winapi.h

index ea33d26a50c95ee498414fb1d2da99925158c757..f56b9ed92b4906c417fcbd57528fe37248f3b8db 100755 (executable)
@@ -56,7 +56,7 @@ extern HINSTANCE        hAppInstance;
 extern const char       *szAppName;
 extern DWORD            mainthreadId;
 
-// Main UPS server routine
+// Main Bacula server routine
 extern int BaculaAppMain();
 
 extern void LogErrorMsg(char *msg);
index 3e4f7cd64c1f3eb1cb1e47a8fca7b5c373943175..fecbddb67dd1686de55f9a2a1dba9cb8888f2a04 100755 (executable)
@@ -512,12 +512,12 @@ int encode_attribsEx(JCR *jcr, char *attribsEx, FF_PKT *ff_pkt)
 
    attribsEx[0] = 0;                  /* no extended attributes */
 
+   unix_name_to_win32(&ff_pkt->sys_fname, ff_pkt->fname);
+
    // try unicode version
    if (p_GetFileAttributesExW)  {
-      unix_name_to_win32(&ff_pkt->sys_fname, ff_pkt->fname);
-
       POOLMEM* pwszBuf = get_pool_memory (PM_FNAME);   
-      UTF8_2_wchar(&pwszBuf, ff_pkt->sys_fname);
+      make_win32_path_UTF8_2_wchar(&pwszBuf, ff_pkt->fname);
 
       BOOL b=p_GetFileAttributesExW((LPCWSTR) pwszBuf, GetFileExInfoStandard, (LPVOID)&atts);
       free_pool_memory(pwszBuf);
@@ -529,9 +529,7 @@ int encode_attribsEx(JCR *jcr, char *attribsEx, FF_PKT *ff_pkt)
    }
    else {
       if (!p_GetFileAttributesExA)
-         return STREAM_UNIX_ATTRIBUTES;
-
-      unix_name_to_win32(&ff_pkt->sys_fname, ff_pkt->fname);
+         return STREAM_UNIX_ATTRIBUTES;      
 
       if (!p_GetFileAttributesExA(ff_pkt->sys_fname, GetFileExInfoStandard,
                               (LPVOID)&atts)) {
@@ -632,8 +630,6 @@ static bool set_win32_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
    win32_ofile = get_pool_memory(PM_FNAME);
    unix_name_to_win32(&win32_ofile, attr->ofname);
 
-
-
    /* At this point, we have reconstructed the WIN32_FILE_ATTRIBUTE_DATA pkt */
 
    if (!is_bopen(ofd)) {
@@ -657,7 +653,7 @@ static bool set_win32_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
    {
       if (p_SetFileAttributesW) {
          POOLMEM* pwszBuf = get_pool_memory (PM_FNAME);   
-         UTF8_2_wchar(&pwszBuf, win32_ofile);
+         make_win32_path_UTF8_2_wchar(&pwszBuf, attr->ofname);
 
          BOOL b=p_SetFileAttributesW((LPCWSTR)pwszBuf, atts.dwFileAttributes & SET_ATTRS);
          free_pool_memory(pwszBuf);
index 85b3ffe9e3b0dec4c75aebc0840934171b9db9eb..8f1321727af881daff4739f10baeda382c3a8eec 100644 (file)
@@ -386,7 +386,7 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
       return 0;
 
    if (p_CreateFileW && p_MultiByteToWideChar)               
-      UTF8_2_wchar(&win32_fname_wchar, win32_fname);
+      make_win32_path_UTF8_2_wchar(&win32_fname_wchar, fname);
 
    if (flags & O_CREAT) {             /* Create */
       if (bfd->use_backup_api) {
index 8f65b909613316c57d6cfe4cc141ed1d9345f145..0cea7be666d01ff8195e4a1a2c3a227e0bec56b3 100644 (file)
@@ -176,23 +176,36 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
             Qmsg1(jcr, M_ERROR, 0, _("bpkt already open fid=%d\n"), bfd->fid);
             bclose(bfd);
          }
+      
+
+         if ((bopen(bfd, attr->ofname, mode, S_IRUSR | S_IWUSR)) < 0) {
+            berrno be;
+            be.set_errno(bfd->berrno);
+            Qmsg2(jcr, M_ERROR, 0, _("Could not create %s: ERR=%s\n"),
+                  attr->ofname, be.strerror());
+            return CF_ERROR;
+         }
+
+         /* this doesn't solve the Microsoft problem - Thorsten Engel 
+            so I reused the code of V 1.40
          /*
           * If the open fails, we attempt to cd into the directory
           *  and create the file with a relative path rather than
           *  the full absolute path.  This is for Win32 where
           *  path names may be too long to create.
           */
+         /*
          if ((bopen(bfd, attr->ofname, mode, S_IRUSR | S_IWUSR)) < 0) {
             berrno be;
             int stat;
             Dmsg2(000, "bopen failed errno=%d: ERR=%s\n", bfd->berrno,  
-               be.strerror(bfd->berrno));
-            if (strlen(attr->ofname) > 250) {   /* Microsoft limitation */
+               be.strerror(bfd->berrno));            
+            if (strlen(attr->ofname) > 250) {   // Microsoft limitation 
                char savechr;
                char *p, *e;
                struct saved_cwd cwd;
                savechr = attr->ofname[pnl];
-               attr->ofname[pnl] = 0;                 /* terminate path */
+               attr->ofname[pnl] = 0;                 // terminate path 
                Dmsg1(000, "Do chdir %s\n", attr->ofname);
                if (save_cwd(&cwd) != 0) {
                   Qmsg0(jcr, M_ERROR, 0, _("Could not save_dirn"));
@@ -239,8 +252,8 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
             }
             Qmsg2(jcr, M_ERROR, 0, _("Could not create %s: ERR=%s\n"),
                   attr->ofname, be.strerror(bfd->berrno));
-            return CF_ERROR;
-         }
+            return CF_ERROR; 
+         }*/
          return CF_EXTRACT;
 #ifndef HAVE_WIN32  // none of these exists on MS Windows
       case FT_RAW:                    /* Bacula raw device e.g. /dev/sda1 */
index a138f04f470c29197e468e6cf981ea5df1e25861..42db9f3fcba95f087a641ec9bb28794cd3cf9d38 100644 (file)
@@ -51,7 +51,7 @@ typedef char POOLMEM;
 
 int wchar_2_UTF8(char *pszUTF, const WCHAR *pszUCS, int cchChar = MAX_PATH_UTF8);
 int UTF8_2_wchar(POOLMEM **pszUCS, const char *pszUTF);
-
+int make_win32_path_UTF8_2_wchar(POOLMEM **pszUCS, const char *pszUTF, BOOL* pBIsRawPath = NULL);
 
 /* In ADVAPI32.DLL */