aboutsummaryrefslogtreecommitdiff
path: root/lib/libarchive/archive_write_open_filename.c
diff options
context:
space:
mode:
authorTim Kientzle <kientzle@FreeBSD.org>2004-04-05 21:12:29 +0000
committerTim Kientzle <kientzle@FreeBSD.org>2004-04-05 21:12:29 +0000
commit71b44796d9533309abbe22e7b26d3ee5bb3d0251 (patch)
tree65c99eaf5f048beaa6a7d9973eb8410048b1f15d /lib/libarchive/archive_write_open_filename.c
parent7f8a436ff29ebeb1ce2ae2434add4505d5e7e2ca (diff)
Overhauled ACL support. This makes us compatible
with 'star' ACL handling, though there's still a bit more work needed in this area. Added 'write_open_fd' and 'read_open_fd' to simplify, e.g., tar's u and r modes. Eliminated old 'write_open_file_position' as a bad idea. (It required closing/reopening files to do updates, which led to unpleasant implications.) Various other minor fixes, API tweaks, etc.
Notes
Notes: svn path=/head/; revision=127912
Diffstat (limited to 'lib/libarchive/archive_write_open_filename.c')
-rw-r--r--lib/libarchive/archive_write_open_filename.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/lib/libarchive/archive_write_open_filename.c b/lib/libarchive/archive_write_open_filename.c
index 92fa9d8a9ce3..19fdebaff2bb 100644
--- a/lib/libarchive/archive_write_open_filename.c
+++ b/lib/libarchive/archive_write_open_filename.c
@@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$");
#include "archive_private.h"
struct write_file_data {
- off_t offset;
int fd;
char filename[1];
};
@@ -53,23 +52,23 @@ static ssize_t file_write(struct archive *, void *, void *buff, size_t);
int
archive_write_open_file(struct archive *a, const char *filename)
{
- return (archive_write_open_file_position(a, filename, 0));
-}
-
-int
-archive_write_open_file_position(struct archive *a, const char *filename,
- int64_t offset)
-{
struct write_file_data *mine;
if (filename == NULL) {
mine = malloc(sizeof(*mine));
+ if (mine == NULL) {
+ archive_set_error(a, ENOMEM, "No memory");
+ return (ARCHIVE_FATAL);
+ }
mine->filename[0] = 0;
} else {
mine = malloc(sizeof(*mine) + strlen(filename));
+ if (mine == NULL) {
+ archive_set_error(a, ENOMEM, "No memory");
+ return (ARCHIVE_FATAL);
+ }
strcpy(mine->filename, filename);
}
- mine->offset = offset;
mine->fd = -1;
return (archive_write_open(a, mine,
file_open, file_write, file_close));
@@ -83,10 +82,7 @@ file_open(struct archive *a, void *client_data)
struct stat st;
mine = client_data;
- if (mine->offset == 0)
- flags = O_WRONLY | O_CREAT | O_TRUNC;
- else
- flags = O_WRONLY;
+ flags = O_WRONLY | O_CREAT | O_TRUNC;
if (*mine->filename != 0) {
mine->fd = open(mine->filename, flags, 0666);
@@ -115,12 +111,7 @@ file_open(struct archive *a, void *client_data)
if (mine->fd < 0) {
archive_set_error(a, errno, "Failed to open");
- return -1;
- }
-
- if (mine->offset > 0) {
- lseek(mine->fd, mine->offset, SEEK_SET);
- ftruncate(mine->fd, mine->offset);
+ return (ARCHIVE_FATAL);
}
return (ARCHIVE_OK);