ftruncate64 cut its argument to 32 bits on systems with 32 bit long type

This commit is contained in:
Gerhard Rieger 2009-05-05 22:42:50 +02:00
parent 7c2039ada8
commit 4576b50e47
7 changed files with 54 additions and 12 deletions

View file

@ -1,4 +1,7 @@
corrections:
ftruncate64 cut its argument to 32 bits on systems with 32 bit long type
####################### V 1.7.1.0: ####################### V 1.7.1.0:
new features: new features:

View file

@ -1 +1 @@
"1.7.1.0" "1.7.1.0+ftruncate64"

View file

@ -263,7 +263,13 @@
/* might be checked in later versions */ /* might be checked in later versions */
#ifndef F_off #ifndef F_off
#define F_off "%ld" # if HAVE_BASIC_OFF_T==3
# define F_off "%d"
# elif HAVE_BASIC_OFF_T==5
# define F_off "%ld"
# else
#error "HAVE_BASIC_OFF_T is out of range:" HAVE_BASIC_OFF_T
# endif
#endif #endif
/* default: long long */ /* default: long long */

View file

@ -448,6 +448,7 @@
#undef HAVE_BASIC_UID_T #undef HAVE_BASIC_UID_T
#undef HAVE_BASIC_GID_T #undef HAVE_BASIC_GID_T
#undef HAVE_BASIC_TIME_T #undef HAVE_BASIC_TIME_T
#undef HAVE_BASIC_OFF_T
#undef HAVE_BASIC_OFF64_T #undef HAVE_BASIC_OFF64_T
#undef HAVE_BASIC_SOCKLEN_T #undef HAVE_BASIC_SOCKLEN_T

View file

@ -1371,6 +1371,9 @@ AC_BASIC_TYPE([#include <sys/types.h>
#include <unistd.h>], socklen_t, HAVE_BASIC_SOCKLEN_T, #include <unistd.h>], socklen_t, HAVE_BASIC_SOCKLEN_T,
sc_cv_type_socklent_basic) sc_cv_type_socklent_basic)
AC_BASIC_TYPE([#include <sys/types.h>
#include <unistd.h>], off_t, HAVE_BASIC_OFF_T, sc_cv_type_off_basic)
AC_BASIC_TYPE([#include <sys/types.h> AC_BASIC_TYPE([#include <sys/types.h>
#include <unistd.h>], off64_t, HAVE_BASIC_OFF64_T, sc_cv_type_off64_basic) #include <unistd.h>], off64_t, HAVE_BASIC_OFF64_T, sc_cv_type_off64_basic)

8
xio.h
View file

@ -349,6 +349,14 @@ union integral {
/* some aliases */ /* some aliases */
#define u_off u_long /* please report when this causes problems */ #define u_off u_long /* please report when this causes problems */
#if HAVE_BASIC_OFF_T==3
# define u_off u_int
#elif HAVE_BASIC_OFF_T==5
# define u_off u_long
#else
# error "unexpected size of off_t, please report this as bug"
#endif
#if defined(HAVE_BASIC_OFF64_T) && HAVE_BASIC_OFF64_T #if defined(HAVE_BASIC_OFF64_T) && HAVE_BASIC_OFF64_T
# if HAVE_BASIC_OFF64_T==5 # if HAVE_BASIC_OFF64_T==5
# define u_off64 u_long # define u_off64 u_long

View file

@ -1877,6 +1877,9 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
Info2("setting option \"%s\" to %d", ent->desc->defname, Info2("setting option \"%s\" to %d", ent->desc->defname,
(*opts)[i].value.u_byte); (*opts)[i].value.u_byte);
break; break;
#if HAVE_BASIC_OFF_T==3
case TYPE_OFF32:
#endif
case TYPE_INT: case TYPE_INT:
if (assign) { if (assign) {
char *rest; char *rest;
@ -1939,7 +1942,9 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
(*opts)[i].value.u_ushort); (*opts)[i].value.u_ushort);
break; break;
#if HAVE_BASIC_OFF_T==5
case TYPE_OFF32: case TYPE_OFF32:
#endif
#if HAVE_STAT64 && defined(HAVE_BASIC_OFF64_T) && HAVE_BASIC_OFF64_T==5 #if HAVE_STAT64 && defined(HAVE_BASIC_OFF64_T) && HAVE_BASIC_OFF64_T==5
case TYPE_OFF64: case TYPE_OFF64:
#endif #endif
@ -1991,6 +1996,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
(*opts)[i].value.u_longlong); (*opts)[i].value.u_longlong);
break; break;
#endif /* HAVE_TYPE_LONGLONG */ #endif /* HAVE_TYPE_LONGLONG */
case TYPE_UIDT: case TYPE_UIDT:
if (!assign) { if (!assign) {
Error1("option \"%s\": value required", a0); Error1("option \"%s\": value required", a0);
@ -2010,6 +2016,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
Info2("setting option \"%s\" to %u", ent->desc->defname, Info2("setting option \"%s\" to %u", ent->desc->defname,
(*opts)[i].value.u_uidt); (*opts)[i].value.u_uidt);
break; break;
case TYPE_GIDT: case TYPE_GIDT:
if (!assign) { Error1("option \"%s\": value required", a0); if (!assign) { Error1("option \"%s\": value required", a0);
continue; } continue; }
@ -2028,6 +2035,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
Info2("setting option \"%s\" to %u", ent->desc->defname, Info2("setting option \"%s\" to %u", ent->desc->defname,
(*opts)[i].value.u_gidt); (*opts)[i].value.u_gidt);
break; break;
case TYPE_MODET: case TYPE_MODET:
if (!assign) { Error1("option \"%s\": value required", a0); if (!assign) { Error1("option \"%s\": value required", a0);
continue; continue;
@ -2039,6 +2047,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
Info2("setting option \"%s\" to %u", ent->desc->defname, Info2("setting option \"%s\" to %u", ent->desc->defname,
(*opts)[i].value.u_modet); (*opts)[i].value.u_modet);
break; break;
case TYPE_STRING: case TYPE_STRING:
if (!assign) { if (!assign) {
Error1("option \"%s\": value required", a0); Error1("option \"%s\": value required", a0);
@ -2050,6 +2059,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
Info2("setting option \"%s\" to \"%s\"", ent->desc->defname, Info2("setting option \"%s\" to \"%s\"", ent->desc->defname,
(*opts)[i].value.u_string); (*opts)[i].value.u_string);
break; break;
case TYPE_STRING_NULL: case TYPE_STRING_NULL:
if (!assign) { if (!assign) {
(*opts)[i].value.u_string = NULL; (*opts)[i].value.u_string = NULL;
@ -2060,11 +2070,13 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
(*opts)[i].value.u_string); (*opts)[i].value.u_string);
} }
break; break;
#if LATER #if LATER
case TYPE_INT3: case TYPE_INT3:
break; break;
#endif #endif
case TYPE_TIMEVAL: case TYPE_TIMEVAL:
if (!assign) { if (!assign) {
Error1("option \"%s\": value required", a0); Error1("option \"%s\": value required", a0);
@ -2082,6 +2094,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
(val-(*opts)[i].value.u_timeval.tv_sec) * 1000000; (val-(*opts)[i].value.u_timeval.tv_sec) * 1000000;
} }
break; break;
#if HAVE_STRUCT_TIMESPEC #if HAVE_STRUCT_TIMESPEC
case TYPE_TIMESPEC: case TYPE_TIMESPEC:
if (!assign) { if (!assign) {
@ -2101,6 +2114,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
} }
break; break;
#endif /* HAVE_STRUCT_TIMESPEC */ #endif /* HAVE_STRUCT_TIMESPEC */
#if HAVE_STRUCT_LINGER #if HAVE_STRUCT_LINGER
case TYPE_LINGER: case TYPE_LINGER:
if (!assign) { if (!assign) {
@ -2117,6 +2131,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
(*opts)[i].value.u_linger.l_linger); (*opts)[i].value.u_linger.l_linger);
break; break;
#endif /* HAVE_STRUCT_LINGER */ #endif /* HAVE_STRUCT_LINGER */
case TYPE_INT_INT: case TYPE_INT_INT:
if (!assign) { if (!assign) {
Error1("option \"%s\": values required", a0); Error1("option \"%s\": values required", a0);
@ -2135,6 +2150,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
Info3("setting option \"%s\" to %d:%d", ent->desc->defname, Info3("setting option \"%s\" to %d:%d", ent->desc->defname,
(*opts)[i].value.u_int, (*opts)[i].value2.u_int); (*opts)[i].value.u_int, (*opts)[i].value2.u_int);
break; break;
case TYPE_INT_BIN: case TYPE_INT_BIN:
if (!assign) { if (!assign) {
Error1("option \"%s\": values required", a0); Error1("option \"%s\": values required", a0);
@ -2162,6 +2178,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
Info2("setting option \"%s\" to %d:..."/*!!!*/, ent->desc->defname, Info2("setting option \"%s\" to %d:..."/*!!!*/, ent->desc->defname,
(*opts)[i].value.u_int); (*opts)[i].value.u_int);
break; break;
case TYPE_INT_STRING: case TYPE_INT_STRING:
if (!assign) { if (!assign) {
Error1("option \"%s\": values required", a0); Error1("option \"%s\": values required", a0);
@ -2182,6 +2199,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
Info3("setting option \"%s\" to %d:\"%s\"", ent->desc->defname, Info3("setting option \"%s\" to %d:\"%s\"", ent->desc->defname,
(*opts)[i].value.u_int, (*opts)[i].value2.u_string); (*opts)[i].value.u_int, (*opts)[i].value2.u_string);
break; break;
case TYPE_INT_INT_INT: case TYPE_INT_INT_INT:
if (!assign) { if (!assign) {
Error1("option \"%s\": values required", a0); Error1("option \"%s\": values required", a0);
@ -2206,6 +2224,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
Info4("setting option \"%s\" to %d:%d:%d", ent->desc->defname, Info4("setting option \"%s\" to %d:%d:%d", ent->desc->defname,
(*opts)[i].value.u_int, (*opts)[i].value2.u_int, (*opts)[i].value3.u_int); (*opts)[i].value.u_int, (*opts)[i].value2.u_int, (*opts)[i].value3.u_int);
break; break;
case TYPE_INT_INT_BIN: case TYPE_INT_INT_BIN:
if (!assign) { if (!assign) {
Error1("option \"%s\": values required", a0); Error1("option \"%s\": values required", a0);
@ -2239,6 +2258,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
Info3("setting option \"%s\" to %d:%d:..."/*!!!*/, ent->desc->defname, Info3("setting option \"%s\" to %d:%d:..."/*!!!*/, ent->desc->defname,
(*opts)[i].value.u_int, (*opts)[i].value2.u_int); (*opts)[i].value.u_int, (*opts)[i].value2.u_int);
break; break;
case TYPE_INT_INT_STRING: case TYPE_INT_INT_STRING:
if (!assign) { if (!assign) {
Error1("option \"%s\": values required", a0); Error1("option \"%s\": values required", a0);
@ -2267,6 +2287,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
(*opts)[i].value3.u_string); (*opts)[i].value3.u_string);
break; break;
#if defined(HAVE_STRUCT_IP_MREQ) || defined (HAVE_STRUCT_IP_MREQN) #if defined(HAVE_STRUCT_IP_MREQ) || defined (HAVE_STRUCT_IP_MREQN)
case TYPE_IP_MREQN: case TYPE_IP_MREQN:
{ {
/* we do not resolve the addresses here because we do not yet know /* we do not resolve the addresses here because we do not yet know
@ -2866,16 +2887,16 @@ int applyopts(int fd, struct opt *opts, enum e_phase phase) {
++opt; continue; } ++opt; continue; }
if (opt->desc->func == OFUNC_SEEK32) { if (opt->desc->func == OFUNC_SEEK32) {
if (Lseek(fd, opt->value.u_long, opt->desc->major) < 0) { if (Lseek(fd, opt->value.u_off, opt->desc->major) < 0) {
Error4("lseek(%d, %ld, %d): %s", Error4("lseek(%d, "F_off", %d): %s",
fd, opt->value.u_long, opt->desc->major, strerror(errno)); fd, opt->value.u_off, opt->desc->major, strerror(errno));
} }
#if HAVE_LSEEK64 #if HAVE_LSEEK64
} else if (opt->desc->func == OFUNC_SEEK64) { } else if (opt->desc->func == OFUNC_SEEK64) {
/*! this depends on off64_t atomic type */ /*! this depends on off64_t atomic type */
if (Lseek64(fd, opt->value.u_off64, opt->desc->major) < 0) { if (Lseek64(fd, opt->value.u_off64, opt->desc->major) < 0) {
Error4("lseek64(%d, %Ld, %d): %s", Error4("lseek64(%d, "F_off64", %d): %s",
fd, opt->value.u_off64, opt->desc->major, strerror(errno)); fd, opt->value.u_off64, opt->desc->major, strerror(errno));
} }
#endif /* HAVE_LSEEK64 */ #endif /* HAVE_LSEEK64 */
@ -3217,17 +3238,17 @@ int applyopts(int fd, struct opt *opts, enum e_phase phase) {
} }
break; break;
case OPT_FTRUNCATE32: case OPT_FTRUNCATE32:
if (Ftruncate(fd, opt->value.u_long) < 0) { if (Ftruncate(fd, opt->value.u_off) < 0) {
Error3("ftruncate(%d, %ld): %s", Error3("ftruncate(%d, "F_off"): %s",
fd, opt->value.u_long, strerror(errno)); fd, opt->value.u_off, strerror(errno));
opt->desc = ODESC_ERROR; ++opt; continue; opt->desc = ODESC_ERROR; ++opt; continue;
} }
break; break;
#if HAVE_FTRUNCATE64 #if HAVE_FTRUNCATE64
case OPT_FTRUNCATE64: case OPT_FTRUNCATE64:
if (Ftruncate64(fd, opt->value.u_long) < 0) { if (Ftruncate64(fd, opt->value.u_off64) < 0) {
Error3("ftruncate64(%d, %ld): %s", Error3("ftruncate64(%d, "F_off64"): %s",
fd, opt->value.u_long, strerror(errno)); fd, opt->value.u_off64, strerror(errno));
opt->desc = ODESC_ERROR; ++opt; continue; opt->desc = ODESC_ERROR; ++opt; continue;
} }
#endif /* HAVE_FTRUNCATE64 */ #endif /* HAVE_FTRUNCATE64 */