Esempio n. 1
0
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Mtools.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "stream.h"
#include "fs.h"
#include "llong.h"
#include "mtools.h"

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

const off_t max_off_t_32 = MAX_OFF_T_B(32); /* Directory */
const off_t max_off_t_seek = MAX_OFF_T_B(SEEK_BITS); /* SCSI */

static int fileTooBig(off_t off)
{
	return (off & ~max_off_t_32) != 0;
}

off_t truncBytes32(off_t off)
{
	if (fileTooBig(off))
	{
		fprintf(stderr, "Internal error, offset too big\n");
		return off; // TODO: this used to be an exit(1)...
	}
Esempio n. 2
0
#include "fsP.h"
#include "llong.h"
#include "mtools.h"

/* Warnings about integer overflow in expression can be ignored.  These are
 * due to the way that maximal values for those integers are computed: 
 * intentional overflow from smallest negative number (1000...) to highest 
 * positive number (0111...) by substraction of 1 */
#ifdef __GNUC__
/*
#warning "The following warnings about integer overflow in expression can be safely ignored"
*/
#endif

#if 1
const mt_off_t max_off_t_31 = MAX_OFF_T_B(31); /* Floppyd */
const mt_off_t max_off_t_41 = MAX_OFF_T_B(41); /* SCSI */
const mt_off_t max_off_t_seek = MAX_OFF_T_B(SEEK_BITS); /* SCSI */
#else
const mt_off_t max_off_t_31 = MAX_OFF_T_B(10); /* Floppyd */
const mt_off_t max_off_t_41 = MAX_OFF_T_B(10); /* SCSI */
const mt_off_t max_off_t_seek = MAX_OFF_T_B(10); /* SCSI */
#endif

off_t truncBytes32(mt_off_t off)
{
	if (off & ~max_off_t_31) {
		fprintf(stderr, "Internal error, offset too big\n");
		exit(1);
	}
	return (off_t) off;