X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fstored%2Fdev.c;h=459a9caa94de46d1d2fe53ed145d6ed2fe11993b;hb=90e04dd4f4c1bcad214b4ac5dd4ffbc55bbe0763;hp=231f3c15666bb04996475c792d83ff7044505a36;hpb=860646a72694c425bb2314a8715dabf016f5c925;p=bacula%2Fbacula diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 231f3c1566..459a9caa94 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -29,19 +29,32 @@ * Version $Id$ */ /* - Copyright (C) 2000-2006 Kern Sibbald + Bacula® - The Network Backup Solution - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - version 2 as amended with additional clauses defined in the - file LICENSE in the main source directory. + Copyright (C) 2000-2006 Free Software Foundation Europe e.V. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - the file LICENSE for additional details. + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation plus additions + that are listed in the file LICENSE. - */ + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ /* * Handling I/O errors and end of tape conditions are a bit tricky. @@ -324,8 +337,10 @@ void DEVICE::open_tape_device(DCR *dcr, int omode) { file_size = 0; int timeout = max_open_wait; +#if !defined(HAVE_WIN32) struct mtop mt_com; utime_t start_time = time(NULL); +#endif Dmsg0(29, "Open dev: device is tape\n"); @@ -447,7 +462,7 @@ void DEVICE::open_file_device(DCR *dcr, int omode) return; } - if (archive_name.c_str()[strlen(archive_name.c_str())-1] != '/') { + if (!IsPathSeparator(archive_name.c_str()[strlen(archive_name.c_str())-1])) { pm_strcat(archive_name, "/"); } pm_strcat(archive_name, VolCatInfo.VolCatName); @@ -752,7 +767,7 @@ bool DEVICE::rewind(DCR *dcr) break; } } else if (is_file() || is_dvd()) { - if (lseek(dcr, (off_t)0, SEEK_SET) < 0) { + if (lseek(dcr, (boffset_t)0, SEEK_SET) < 0) { berrno be; dev_errno = errno; Mmsg2(errmsg, _("lseek error on %s. ERR=%s.\n"), @@ -835,7 +850,7 @@ bool DEVICE::eod(DCR *dcr) struct mtop mt_com; struct mtget mt_stat; bool ok = true; - off_t pos; + boffset_t pos; if (fd < 0) { dev_errno = EBADF; @@ -859,7 +874,7 @@ bool DEVICE::eod(DCR *dcr) return true; } if (!is_tape()) { - pos = lseek(dcr, (off_t)0, SEEK_END); + pos = lseek(dcr, (boffset_t)0, SEEK_END); // Dmsg1(100, "====== Seek to %lld\n", pos); if (pos >= 0) { update_pos(dcr); @@ -985,7 +1000,7 @@ bool DEVICE::eod(DCR *dcr) */ bool DEVICE::update_pos(DCR *dcr) { - off_t pos; + boffset_t pos; bool ok = true; if (!is_open()) { @@ -999,7 +1014,7 @@ bool DEVICE::update_pos(DCR *dcr) if (is_file() || is_dvd()) { file = 0; file_addr = 0; - pos = lseek(dcr, (off_t)0, SEEK_CUR); + pos = lseek(dcr, (boffset_t)0, SEEK_CUR); if (pos < 0) { berrno be; dev_errno = errno; @@ -1568,9 +1583,9 @@ bool DEVICE::reposition(DCR *dcr, uint32_t rfile, uint32_t rblock) } if (!is_tape()) { - off_t pos = (((off_t)rfile)<<32) + (off_t)rblock; + boffset_t pos = (((boffset_t)rfile)<<32) | rblock; Dmsg1(100, "===== lseek to %d\n", (int)pos); - if (lseek(dcr, pos, SEEK_SET) == (off_t)-1) { + if (lseek(dcr, pos, SEEK_SET) == (boffset_t)-1) { berrno be; dev_errno = errno; Mmsg2(errmsg, _("lseek error on %s. ERR=%s.\n"), @@ -1893,14 +1908,18 @@ void DEVICE::close_part(DCR *dcr) dcr->VolCatInfo = saveVolCatInfo; /* structure assignment */ } -off_t DEVICE::lseek(DCR *dcr, off_t offset, int whence) +boffset_t DEVICE::lseek(DCR *dcr, boffset_t offset, int whence) { switch (dev_type) { case B_DVD_DEV: return lseek_dvd(dcr, offset, whence); case B_FILE_DEV: - return ::lseek(fd, offset, whence); - } +#if defined(HAVE_WIN32) + return ::_lseeki64(fd, (__int64)offset, whence); +#else + return ::lseek(fd, (off_t)offset, whence); +#endif + } return -1; }