From: phk Date: Fri, 25 Jul 2008 12:02:11 +0000 (+0000) Subject: Figure out if we need O_LARGEFILE to be compatible with 1990 or later X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d8d6a74b91769e0f6b6770e1b2b15f059da2db5;p=varnish Figure out if we need O_LARGEFILE to be compatible with 1990 or later size disks. Submitted by: wichert Fixes ticket 283 git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3021 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/storage_file.c b/varnish-cache/bin/varnishd/storage_file.c index a675f617..f244156d 100644 --- a/varnish-cache/bin/varnishd/storage_file.c +++ b/varnish-cache/bin/varnishd/storage_file.c @@ -194,7 +194,7 @@ smf_calcsize(struct smf_sc *sc, const char *size, int newfile) " to %ju due to system limitations\n", l); if (l < st.st_size) { - AZ(ftruncate(sc->fd, l)); + AZ(ftruncate(sc->fd, (off_t)l)); } else if (l - st.st_size > fssize) { l = fssize * 80 / 100; fprintf(stderr, "WARNING: storage file size reduced" @@ -228,7 +228,7 @@ smf_initfile(struct smf_sc *sc, const char *size, int newfile) { smf_calcsize(sc, size, newfile); - AZ(ftruncate(sc->fd, sc->filesize)); + AZ(ftruncate(sc->fd, (off_t)sc->filesize)); /* XXX: force block allocation here or in open ? */ } @@ -279,7 +279,11 @@ smf_init(struct stevedore *parent, int ac, char * const *av) parent->priv = sc; /* try to create a new file of this name */ +#ifdef O_LARGEFILE + sc->fd = open(fn, O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE, 0600); +#else sc->fd = open(fn, O_RDWR | O_CREAT | O_EXCL, 0600); +#endif if (sc->fd >= 0) { sc->filename = fn; mgt_child_inherit(sc->fd, "storage_file"); diff --git a/varnish-cache/bin/varnishlog/varnishlog.c b/varnish-cache/bin/varnishlog/varnishlog.c index 1f4a818d..ed41ef53 100644 --- a/varnish-cache/bin/varnishlog/varnishlog.c +++ b/varnish-cache/bin/varnishlog/varnishlog.c @@ -259,6 +259,9 @@ open_log(const char *w_arg, int a_flag) int fd, flags; flags = (a_flag ? O_APPEND : O_TRUNC) | O_WRONLY | O_CREAT; +#ifdef O_LARGEFILE + flags |= O_LARGEFILE; +#endif if (!strcmp(w_arg, "-")) fd = STDOUT_FILENO; else diff --git a/varnish-cache/configure.ac b/varnish-cache/configure.ac index 3e369596..63ca4c00 100644 --- a/varnish-cache/configure.ac +++ b/varnish-cache/configure.ac @@ -142,6 +142,7 @@ AC_CHECK_FUNCS([strlcat strlcpy]) AC_CHECK_FUNCS([strndup]) AC_CHECK_FUNCS([vis strvis strvisx]) AC_CHECK_FUNCS([daemon]) +AC_SYS_LARGEFILE save_LIBS="${LIBS}" LIBS="${LIBS} ${RT_LIBS}"