Browse Source

Equipped all non-system-dependent open(2) calls with O_BINARY

1.4.0
Thomas Schmitt 7 years ago
parent
commit
0b110821f6
  1. 2
      cdrskin/cdrskin_timestamp.h
  2. 11
      libburn/ddlpa.c
  3. 12
      libburn/drive.c
  4. 13
      libburn/file.c
  5. 6
      libburn/libdax_audioxtr.c
  6. 8
      libburn/mmc.c
  7. 10
      libburn/read.c
  8. 9
      libburn/sector.c
  9. 9
      libburn/sg-dummy.c
  10. 15
      libburn/sg-libcdio.c
  11. 9
      libburn/structure.c
  12. 10
      libburn/write.c

2
cdrskin/cdrskin_timestamp.h

@ -1 +1 @@
#define Cdrskin_timestamP "2014.11.23.190942"
#define Cdrskin_timestamP "2014.11.26.164119"

11
libburn/ddlpa.c

@ -50,7 +50,9 @@ static int ddlpa_debug_mode = 1;
#ifndef O_LARGEFILE
#define O_LARGEFILE 0
#endif
#ifndef O_BINARY
#define O_BINARY 0
#endif
/* ----------------------- private -------------------- */
@ -173,7 +175,7 @@ static int ddlpa_occupy(struct ddlpa_lock *o, char *path, int *fd,
int ret, o_flags, o_rw, l_type;
char *o_rwtext;
o_flags = o->o_flags | O_NDELAY;
o_flags = o->o_flags | O_NDELAY | O_BINARY;
if(!no_o_excl)
o_flags |= O_EXCL;
o_rw = (o_flags) & (O_RDONLY | O_WRONLY | O_RDWR);
@ -216,7 +218,7 @@ static int ddlpa_occupy(struct ddlpa_lock *o, char *path, int *fd,
static int ddlpa_obtain_scsi_adr(struct ddlpa_lock *o, char *path,
int *bus, int *host, int *channel, int *id, int *lun)
{
int fd, ret, open_mode = O_RDONLY | O_NDELAY;
int fd, ret, open_mode = O_RDONLY | O_NDELAY | O_BINARY;
struct my_scsi_idlun {
int x;
int host_unique_id;
@ -550,7 +552,8 @@ usage:;
} else {
/*
This substitutes for:
fd = open(my_path, O_RDWR | O_EXCL | O_LARGEFILE);
fd = open(my_path,
O_RDWR | O_EXCL | O_LARGEFILE | O_BINARY);
*/

12
libburn/drive.c

@ -26,6 +26,12 @@
#include <pthread.h>
#include <errno.h>
#include <fcntl.h>
/* ts B41126 : O_BINARY is needed for Cygwin but undefined elsewhere */
#ifndef O_BINARY
#define O_BINARY 0
#endif
#include "libburn.h"
#include "init.h"
#include "drive.h"
@ -1638,17 +1644,17 @@ static int burn_role_by_access(char *fname, int flag)
#endif
int fd;
fd = open(fname, O_RDWR | O_LARGEFILE);
fd = open(fname, O_RDWR | O_LARGEFILE | O_BINARY);
if (fd != -1) {
close(fd);
return 2;
}
fd = open(fname, O_RDONLY | O_LARGEFILE);
fd = open(fname, O_RDONLY | O_LARGEFILE | O_BINARY);
if (fd != -1) {
close(fd);
return 4;
}
fd = open(fname, O_WRONLY | O_LARGEFILE);
fd = open(fname, O_WRONLY | O_LARGEFILE | O_BINARY);
if (fd != -1) {
close(fd);
return 5;

13
libburn/file.c

@ -1,7 +1,7 @@
/* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */
/* Copyright (c) 2004 - 2006 Derek Foreman, Ben Jansens
Copyright (c) 2006 - 2010 Thomas Schmitt <scdbackup@gmx.net>
Copyright (c) 2006 - 2014 Thomas Schmitt <scdbackup@gmx.net>
Provided under GPL version 2 or later.
*/
@ -22,6 +22,11 @@
#include <time.h>
#include <pthread.h>
/* ts B41126 : O_BINARY is needed for Cygwin but undefined elsewhere */
#ifndef O_BINARY
#define O_BINARY 0
#endif
#include "source.h"
#include "libburn.h"
#include "file.h"
@ -121,11 +126,11 @@ struct burn_source *burn_file_source_new(const char *path, const char *subpath)
if (!path)
return NULL;
fd1 = open(path, O_RDONLY);
fd1 = open(path, O_RDONLY | O_BINARY);
if (fd1 == -1)
return NULL;
if (subpath != NULL) {
fd2 = open(subpath, O_RDONLY);
fd2 = open(subpath, O_RDONLY | O_BINARY);
if (fd2 == -1) {
close(fd1);
return NULL;
@ -945,7 +950,7 @@ int burn_drive_extract_audio(struct burn_drive *drive,
BURN_ALLOC_MEM(msg, char, 4096);
BURN_ALLOC_MEM(buf, char, 24 * 2352);
fd = open(target_path, O_WRONLY | O_CREAT,
fd = open(target_path, O_WRONLY | O_CREAT | O_BINARY,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (fd == -1) {
sprintf(msg, "Cannot open disk file for writing: %.4000s",

6
libburn/libdax_audioxtr.c

@ -17,6 +17,10 @@
#include <stdlib.h>
#include <errno.h>
/* ts B41126 : O_BINARY is needed for Cygwin but undefined elsewhere */
#ifndef O_BINARY
#define O_BINARY 0
#endif
#include "libdax_msgs.h"
extern struct libdax_msgs *libdax_messenger;
@ -90,7 +94,7 @@ static int libdax_audioxtr_open(struct libdax_audioxtr *o, int flag)
if(strcmp(o->path,"-")==0)
o->fd= 0;
else
o->fd= open(o->path, O_RDONLY);
o->fd= open(o->path, O_RDONLY | O_BINARY);
if(o->fd<0) {
sprintf(msg,"Cannot open audio source file : %s",o->path);
libdax_msgs_submit(libdax_messenger,-1,0x00020200,

8
libburn/mmc.c

@ -21,6 +21,11 @@
#include <pthread.h>
#include <ctype.h>
/* ts B41126 : O_BINARY is needed for Cygwin but undefined elsewhere */
#ifndef O_BINARY
#define O_BINARY 0
#endif
#include "error.h"
#include "sector.h"
#include "libburn.h"
@ -942,7 +947,8 @@ fprintf(stderr, "libburn_DEBUG: buffer sectors= %d bytes= %d\n",
static int tee_fd= -1;
if(tee_fd==-1)
tee_fd= open("/tmp/libburn_sg_written",
O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR);
O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
S_IRUSR | S_IWUSR);
#endif /* Libburn_log_in_and_out_streaM */
mmc_start_if_needed(d, 0);

10
libburn/read.c

@ -1,7 +1,7 @@
/* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */
/* Copyright (c) 2004 - 2006 Derek Foreman, Ben Jansens
Copyright (c) 2006 - 2012 Thomas Schmitt <scdbackup@gmx.net>
Copyright (c) 2006 - 2014 Thomas Schmitt <scdbackup@gmx.net>
Provided under GPL version 2 or later.
*/
@ -22,6 +22,11 @@
#include <fcntl.h>
#include <errno.h>
/* ts B41126 : O_BINARY is needed for Cygwin but undefined elsewhere */
#ifndef O_BINARY
#define O_BINARY 0
#endif
#include "sector.h"
#include "libburn.h"
#include "drive.h"
@ -521,7 +526,8 @@ int burn_read_data(struct burn_drive *d, off_t byte_address,
fd = d->stdio_fd;
if (fd < 0)
d->stdio_fd = fd =
open(d->devname, O_RDONLY | O_LARGEFILE);
open(d->devname,
O_RDONLY | O_LARGEFILE | O_BINARY);
if (fd == -1) {
if (errno == EACCES && (flag & 2)) {
if (!(flag & 8))

9
libburn/sector.c

@ -1,7 +1,7 @@
/* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */
/* Copyright (c) 2004 - 2006 Derek Foreman, Ben Jansens
Copyright (c) 2006 - 2011 Thomas Schmitt <scdbackup@gmx.net>
Copyright (c) 2006 - 2014 Thomas Schmitt <scdbackup@gmx.net>
Provided under GPL version 2 or later.
*/
@ -40,6 +40,10 @@ extern struct libdax_msgs *libdax_messenger;
#include <fcntl.h>
#endif /* Libburn_log_in_and_out_streaM */
/* ts B41126 : O_BINARY is needed for Cygwin but undefined elsewhere */
#ifndef O_BINARY
#define O_BINARY 0
#endif
/*static unsigned char isrc[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";*/
@ -109,7 +113,8 @@ static void get_bytes(struct burn_track *track, int count, unsigned char *data)
static int tee_fd= -1;
if(tee_fd==-1)
tee_fd= open("/tmp/libburn_sg_readin",
O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR);
O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
S_IRUSR | S_IWUSR);
#endif /* Libburn_log_in_and_out_streaM */

9
libburn/sg-dummy.c

@ -35,6 +35,11 @@ Present implementation: default dummy which enables libburn only to work
#include <sys/statvfs.h>
#endif /* Libburn_os_has_stavtfS */
/* ts B41126 : O_BINARY is needed for Cygwin but undefined elsewhere */
#ifndef O_BINARY
#define O_BINARY 0
#endif
#include "transport.h"
#include "drive.h"
#include "sg.h"
@ -277,7 +282,7 @@ int burn_os_stdio_capacity(char *path, off_t write_start, off_t *bytes)
long blocks;
blocks = *bytes / 512;
fd = open(path, open_mode);
fd = open(path, open_mode | O_BINARY);
if (fd == -1)
{ret = -2; goto ex;}
ret = ioctl(fd, BLKGETSIZE, &blocks);
@ -330,7 +335,7 @@ int burn_os_open_track_src(char *path, int open_flags, int flag)
{
int fd;
fd = open(path, open_flags);
fd = open(path, open_flags | O_BINARY);
return fd;
}

15
libburn/sg-libcdio.c

@ -1,7 +1,7 @@
/* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */
/*
Copyright (c) 2009 - 2013 Thomas Schmitt <scdbackup@gmx.net>
Copyright (c) 2009 - 2014 Thomas Schmitt <scdbackup@gmx.net>
Provided under GPL version 2 or later.
*/
@ -149,6 +149,11 @@ Send feedback to libburn-hackers@pykix.org .
#include <cdio/logging.h>
#include <cdio/mmc.h>
/* ts B41126 : O_BINARY is needed for Cygwin but undefined elsewhere */
#ifndef O_BINARY
#define O_BINARY 0
#endif
/* The waiting time before eventually retrying a failed SCSI command.
Before each retry wait Libburn_sg_linux_retry_incR longer than with
@ -895,7 +900,7 @@ int burn_os_stdio_capacity(char *path, off_t write_start, off_t *bytes)
/* GNU/Linux specific determination of block device size */
} else if(S_ISBLK(stbuf.st_mode)) {
int open_mode = O_RDONLY, fd;
int open_mode = O_RDONLY | O_BINARY, fd;
long blocks;
blocks = *bytes / 512;
@ -915,7 +920,7 @@ int burn_os_stdio_capacity(char *path, off_t write_start, off_t *bytes)
} else if(S_ISCHR(stbuf.st_mode)) {
int fd;
fd = open(path, O_RDONLY);
fd = open(path, O_RDONLY | O_BINARY);
if (fd == -1)
{ret = -2; goto ex;}
ret = ioctl(fd, DIOCGMEDIASIZE, &add_size);
@ -929,7 +934,7 @@ int burn_os_stdio_capacity(char *path, off_t write_start, off_t *bytes)
#ifdef Libburn_is_on_solariS
} else if(S_ISBLK(stbuf.st_mode)) {
int open_mode = O_RDONLY, fd;
int open_mode = O_RDONLY | O_BINARY, fd;
fd = open(path, open_mode);
if (fd == -1)
@ -985,7 +990,7 @@ int burn_os_open_track_src(char *path, int open_flags, int flag)
{
int fd;
fd = open(path, open_flags);
fd = open(path, open_flags | O_BINARY);
return fd;
}

9
libburn/structure.c

@ -1,6 +1,6 @@
/* Copyright (c) 2004 - 2006 Derek Foreman, Ben Jansens
Copyright (c) 2006 - 2012 Thomas Schmitt <scdbackup@gmx.net>
Copyright (c) 2006 - 2014 Thomas Schmitt <scdbackup@gmx.net>
Provided under GPL version 2 or later.
*/
@ -21,6 +21,11 @@
#include <unistd.h>
#include <errno.h>
/* ts B41126 : O_BINARY is needed for Cygwin but undefined elsewhere */
#ifndef O_BINARY
#define O_BINARY 0
#endif
#include "libburn.h"
#include "structure.h"
#include "write.h"
@ -1483,7 +1488,7 @@ static int cue_create_file_source(char *path, struct burn_cue_file_cursor *crs,
if (ret <= 0)
goto ex;
} else {
fd = open(path, O_RDONLY);
fd = open(path, O_RDONLY | O_BINARY);
if (fd == -1) {
sprintf(msg,
"In cue sheet: Cannot open FILE '%.4000s'",

10
libburn/write.c

@ -38,6 +38,11 @@
#include <sys/stat.h>
#include <sys/time.h>
/* ts B41126 : O_BINARY is needed for Cygwin but undefined elsewhere */
#ifndef O_BINARY
#define O_BINARY 0
#endif
#include "error.h"
#include "sector.h"
#include "libburn.h"
@ -1795,7 +1800,8 @@ static int transact_dvd_chunk(struct burn_write_opts *opts,
static int tee_fd= -1;
if(tee_fd==-1)
tee_fd= open("/tmp/libburn_sg_readin",
O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR);
O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
S_IRUSR | S_IWUSR);
#endif /* Libburn_log_in_and_out_streaM */
@ -2524,7 +2530,7 @@ int burn_stdio_open_write(struct burn_drive *d, off_t start_byte,
if (fd >= 0)
fd = dup(fd); /* check validity and make closeable */
else
fd = open(d->devname, mode,
fd = open(d->devname, mode | O_BINARY,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (fd == -1) {
libdax_msgs_submit(libdax_messenger, d->global_index,

Loading…
Cancel
Save