*
*/
/*
- Copyright (C) 2000-2003 Kern Sibbald and John Walker
+ Copyright (C) 2003-2004 Kern Sibbald and John Walker
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
#include "bacula.h"
#include "find.h"
+#ifdef HAVE_DARWIN_OS
+#include <sys/paths.h>
+#endif
+
/* ===============================================================
*
* U N I X AND W I N D O W S
return "Program data";
case STREAM_SHA1_SIGNATURE:
return "SHA1 signature";
+ case STREAM_MACOS_FORK_DATA:
+ return "HFS+ resource fork";
+ case STREAM_HFSPLUS_ATTRIBUTES:
+ return "HFS+ Finder Info";
default:
sprintf(buf, "%d", stream);
return (const char *)buf;
case STREAM_PROGRAM_NAMES:
case STREAM_PROGRAM_DATA:
case STREAM_SHA1_SIGNATURE:
+#ifdef HAVE_DARWIN_OS
+ case STREAM_MACOS_FORK_DATA:
+ case STREAM_HFSPLUS_ATTRIBUTES:
+#endif
case 0: /* compatibility with old tapes */
return 1;
}
int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode)
{
POOLMEM *win32_fname;
- DWORD dwaccess, dwflags;
+ DWORD dwaccess, dwflags, dwshare;
/* Convert to Windows path format */
win32_fname = get_pool_memory(PM_FNAME);
} else if (flags & O_WRONLY) { /* Open existing for write */
if (bfd->use_backup_api) {
-#ifdef HAVE_WIN32
- dwaccess = GENERIC_WRITE|/*FILE_ALL_ACCESS|*/WRITE_OWNER|WRITE_DAC/*|ACCESS_SYSTEM_SECURITY*/;
-#else
- dwaccess = GENERIC_WRITE|FILE_ALL_ACCESS|WRITE_OWNER|WRITE_DAC|ACCESS_SYSTEM_SECURITY;
-#endif
+ dwaccess = GENERIC_WRITE|WRITE_OWNER|WRITE_DAC;
dwflags = FILE_FLAG_BACKUP_SEMANTICS;
} else {
dwaccess = GENERIC_WRITE;
if (bfd->use_backup_api) {
dwaccess = GENERIC_READ|READ_CONTROL|ACCESS_SYSTEM_SECURITY;
dwflags = FILE_FLAG_BACKUP_SEMANTICS;
+ dwshare = FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE;
} else {
dwaccess = GENERIC_READ;
dwflags = 0;
+ dwshare = FILE_SHARE_READ|FILE_SHARE_WRITE;
}
bfd->fh = CreateFile(win32_fname,
dwaccess, /* Requested access */
- FILE_SHARE_READ, /* Shared mode */
+ dwshare, /* Share modes */
NULL, /* SecurityAttributes */
OPEN_EXISTING, /* CreationDisposition */
dwflags, /* Flags and attributes */
return stat;
}
-/*
- * Generate error message
- */
-/* DO NOT USE */
-char *xberror(BFILE *bfd)
-{
- LPTSTR msg;
-
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
- FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- bfd->lerror,
- 0,
- (LPTSTR)&msg,
- 0,
- NULL);
- strip_trailing_junk(msg);
- if (!bfd->errmsg) {
- bfd->errmsg = get_pool_memory(PM_FNAME);
- }
- pm_strcpy(bfd->errmsg, msg);
- LocalFree(msg);
- return bfd->errmsg;
-}
-
/* Returns: bytes read on success
* 0 on EOF
* -1 on error
case STREAM_PROGRAM_NAMES:
case STREAM_PROGRAM_DATA:
case STREAM_SHA1_SIGNATURE:
+#ifdef HAVE_DARWIN_OS
+ case STREAM_MACOS_FORK_DATA:
+ case STREAM_HFSPLUS_ATTRIBUTES:
+#endif
case 0: /* compatibility with old tapes */
return 1;
return bfd->fid;
}
+#ifdef HAVE_DARWIN_OS
+/* Open the resource fork of a file. */
+int bopen_rsrc(BFILE *bfd, const char *fname, int flags, mode_t mode)
+{
+ POOLMEM *rsrc_fname;
+ size_t fname_len;
+
+ fname_len = strlen(fname);
+ rsrc_fname = get_pool_memory(PM_FNAME);
+ bstrncpy(rsrc_fname, fname, fname_len + 1);
+ bstrncpy(rsrc_fname + fname_len, _PATH_RSRCFORKSPEC,
+ strlen(_PATH_RSRCFORKSPEC) + 1);
+ bopen(bfd, rsrc_fname, flags, mode);
+ free_pool_memory(rsrc_fname);
+ return bfd->fid;
+}
+#endif
+
int bclose(BFILE *bfd)
{
int stat;