/* Choose the right backend */
void DEVICE::init_backend()
{
- if (is_vtape()) {
- d_open = vtape_open;
- d_write = vtape_write;
- d_close = vtape_close;
- d_ioctl = vtape_ioctl;
- d_read = vtape_read;
#ifdef HAVE_WIN32
- } else if (is_tape()) {
+ if (is_tape()) {
d_open = win32_tape_open;
d_write = win32_tape_write;
d_close = win32_tape_close;
d_ioctl = win32_tape_ioctl;
d_read = win32_tape_read;
-#endif
} else {
+ d_open = ::open;
+ d_close = ::close;
+ d_ioctl = win32_ioctl; /* dummy function */
+ d_write = win32_write; /* win32 read/write are not POSIX */
+ d_read = win32_read;
+ }
+
+#else /* POSIX / UNIX Interface */
+
+ if (is_vtape()) { /* test backend */
+ d_open = vtape_open; /* vtape isn't available for WIN32 */
+ d_write = vtape_write;
+ d_close = vtape_close;
+ d_ioctl = vtape_ioctl;
+ d_read = vtape_read;
+
+ } else { /* tape and file are using normal io */
d_open = ::open;
d_write = ::write;
d_close = ::close;
d_ioctl = ::ioctl;
d_read = ::read;
}
+#endif
}
/*
/* low level operations */
void init_backend();
int (*d_open)(const char *pathname, int flags, ...);
- int (*d_read)(int fd, void *buffer, unsigned int count);
- int (*d_write)(int fd, const void *buffer, unsigned int count);
int (*d_close)(int fd);
int (*d_ioctl)(int fd, unsigned long int request, ...);
+ ssize_t (*d_read)(int fd, void *buffer, size_t count);
+ ssize_t (*d_write)(int fd, const void *buffer, size_t count);
/*
* Locking and blocking calls
return fd;
}
-int vtape_read(int fd, void *buffer, unsigned int count)
+ssize_t vtape_read(int fd, void *buffer, size_t count)
{
vtape *tape = get_tape(fd);
ASSERT(tape != NULL);
return tape->read(buffer, count);
}
-int vtape_write(int fd, const void *buffer, unsigned int count)
+ssize_t vtape_write(int fd, const void *buffer, size_t count)
{
vtape *tape = get_tape(fd);
ASSERT(tape != NULL);
* vtape_header = sizeof(data)
* if vtape_header == 0, this is a EOF
*/
-int vtape::write(const void *buffer, unsigned int count)
+ssize_t vtape::write(const void *buffer, size_t count)
{
ASSERT(online);
ASSERT(current_file >= 0);
ASSERT(count > 0);
ASSERT(buffer);
- unsigned int nb;
+ ssize_t nb;
Dmsg3(dbglevel*2, "write len=%i %i:%i\n",
count, current_file,current_block);
::write(fd, &size, sizeof(uint32_t));
nb = ::write(fd, buffer, count);
- if (nb != count) {
+ if (nb != (ssize_t)count) {
atEOT = true;
Dmsg2(dbglevel,
"Not enough space writing only %i of %i requested\n",
* by returning zero bytes for two consecutive read calls. The third read
* returns an error.
*/
-int vtape::read(void *buffer, unsigned int count)
+ssize_t vtape::read(void *buffer, size_t count)
{
ASSERT(online);
ASSERT(current_file >= 0);
- unsigned int nb;
+ ssize_t nb;
uint32_t s;
Dmsg2(dbglevel*2, "read %i:%i\n", current_file, current_block);
/* reading data itself */
nb = ::read(fd, buffer, s);
- if (s != nb) { /* read error */
+ if (nb != (ssize_t)s) { /* read error */
errno=EIO;
atEOT=true;
current_block = -1;
* Theses functions will replace open/read/write
*/
int vtape_open(const char *pathname, int flags, ...);
-int vtape_read(int fd, void *buffer, unsigned int count);
-int vtape_write(int fd, const void *buffer, unsigned int count);
int vtape_close(int fd);
int vtape_ioctl(int fd, unsigned long int request, ...);
void vtape_debug(int level);
+ssize_t vtape_read(int fd, void *buffer, size_t count);
+ssize_t vtape_write(int fd, const void *buffer, size_t count);
typedef enum {
VT_READ_EOF, /* Need to read the entire EOF struct */
int get_fd();
void dump();
int open(const char *pathname, int flags);
- int read(void *buffer, unsigned int count);
- int write(const void *buffer, unsigned int count);
+ ssize_t read(void *buffer, size_t count);
+ ssize_t write(const void *buffer, size_t count);
int close();
int tape_op(struct mtop *mt_com);
General:
+14Jun08
+ebl Fix vtape on win32 and debian.
+ebl Fix autoselect patch (cause segfault).
13Jun08
ebl Fix autoselect option broken for a while. Fix #1089. Need some
work with StorageId to be able to use a particular drive in a