From a7058ec7c03017b89ba75fc0b9a58ca672aab9e9 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Tue, 20 May 2008 08:57:06 +1000 Subject: - (djm) [configure.ac mux.c sftp.c openbsd-compat/Makefile.in] [openbsd-compat/fmt_scaled.c openbsd-compat/openbsd-compat.h] Fix compilation on Linux, including pulling in fmt_scaled(3) implementation from OpenBSD's libutil. --- openbsd-compat/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'openbsd-compat/Makefile.in') diff --git a/openbsd-compat/Makefile.in b/openbsd-compat/Makefile.in index b44a7851e..d1ec47b6e 100644 --- a/openbsd-compat/Makefile.in +++ b/openbsd-compat/Makefile.in @@ -1,4 +1,4 @@ -# $Id: Makefile.in,v 1.41 2007/06/25 12:15:13 dtucker Exp $ +# $Id: Makefile.in,v 1.42 2008/05/19 22:57:08 djm Exp $ sysconfdir=@sysconfdir@ piddir=@piddir@ @@ -16,7 +16,7 @@ RANLIB=@RANLIB@ INSTALL=@INSTALL@ LDFLAGS=-L. @LDFLAGS@ -OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sha2.o sigact.o strlcat.o strlcpy.o strmode.o strsep.o strtonum.o strtoll.o strtoul.o vis.o +OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o fmt_scaled.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sha2.o sigact.o strlcat.o strlcpy.o strmode.o strsep.o strtonum.o strtoll.o strtoul.o vis.o COMPAT=bsd-arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-snprintf.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o -- cgit v1.2.3 From 598eaa6c0c36c3169963c7e6505d53b4073590f5 Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Mon, 9 Jun 2008 03:32:29 +1000 Subject: - (dtucker) [configure.ac defines.h sftp-client.c sftp-server.c sftp.c openbsd-compat/Makefile.in openbsd-compat/openbsd-compat.h openbsd-compat/bsd-statvfs.{c,h}] Add a null implementation of statvfs and fstatvfs and remove #defines around statvfs code. ok djm@ --- ChangeLog | 8 ++++- configure.ac | 17 +++++++++-- defines.h | 6 +--- openbsd-compat/Makefile.in | 4 +-- openbsd-compat/bsd-statvfs.c | 37 ++++++++++++++++++++++ openbsd-compat/bsd-statvfs.h | 68 +++++++++++++++++++++++++++++++++++++++++ openbsd-compat/openbsd-compat.h | 3 +- sftp-client.c | 4 --- sftp-server.c | 8 ----- sftp.c | 5 --- 10 files changed, 132 insertions(+), 28 deletions(-) create mode 100644 openbsd-compat/bsd-statvfs.c create mode 100644 openbsd-compat/bsd-statvfs.h (limited to 'openbsd-compat/Makefile.in') diff --git a/ChangeLog b/ChangeLog index be3e104ee..9b3e1d6d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +20080608 + - (dtucker) [configure.ac defines.h sftp-client.c sftp-server.c sftp.c + openbsd-compat/Makefile.in openbsd-compat/openbsd-compat.h + openbsd-compat/bsd-statvfs.{c,h}] Add a null implementation of statvfs and + fstatvfs and remove #defines around statvfs code. ok djm@ + 20080607 - (dtucker) [mux.c] Include paths.h inside ifdef HAVE_PATHS_H. - (dtucker) [configure.ac defines.h sftp-client.c sftp-server.c sftp.c] @@ -4054,4 +4060,4 @@ OpenServer 6 and add osr5bigcrypt support so when someone migrates passwords between UnixWare and OpenServer they will still work. OK dtucker@ -$Id: ChangeLog,v 1.4942 2008/06/08 02:55:32 dtucker Exp $ +$Id: ChangeLog,v 1.4943 2008/06/08 17:32:29 dtucker Exp $ diff --git a/configure.ac b/configure.ac index 3005e21b5..4f3ec2a20 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -# $Id: configure.ac,v 1.400 2008/06/07 23:25:28 dtucker Exp $ +# $Id: configure.ac,v 1.401 2008/06/08 17:32:29 dtucker Exp $ # # Copyright (c) 1999-2004 Damien Miller # @@ -15,7 +15,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org) -AC_REVISION($Revision: 1.400 $) +AC_REVISION($Revision: 1.401 $) AC_CONFIG_SRCDIR([ssh.c]) AC_CONFIG_HEADER(config.h) @@ -1305,6 +1305,7 @@ AC_CHECK_FUNCS( \ fchmod \ fchown \ freeaddrinfo \ + fstatvfs \ futimes \ getaddrinfo \ getcwd \ @@ -2651,6 +2652,18 @@ fi TYPE_SOCKLEN_T AC_CHECK_TYPES(sig_atomic_t,,,[#include ]) +AC_CHECK_TYPES([fsblkcnt_t, fsfilcnt_t],,,[ +#include +#ifdef HAVE_SYS_BITYPES_H +#include +#endif +#ifdef HAVE_SYS_STATFS_H +#include +#endif +#ifdef HAVE_SYS_STATVFS_H +#include +#endif +]) AC_CHECK_TYPES(in_addr_t,,, [#include diff --git a/defines.h b/defines.h index a2cc28d98..7bb3a55e8 100644 --- a/defines.h +++ b/defines.h @@ -25,7 +25,7 @@ #ifndef _DEFINES_H #define _DEFINES_H -/* $Id: defines.h,v 1.147 2008/06/07 23:25:28 dtucker Exp $ */ +/* $Id: defines.h,v 1.148 2008/06/08 17:32:29 dtucker Exp $ */ /* Constants */ @@ -567,10 +567,6 @@ struct winsize { # define CUSTOM_SSH_AUDIT_EVENTS #endif -#if defined(HAVE_STATVFS) -# define USE_STATVFS -#endif - #if !defined(HAVE___func__) && defined(HAVE___FUNCTION__) # define __func__ __FUNCTION__ #elif !defined(HAVE___func__) diff --git a/openbsd-compat/Makefile.in b/openbsd-compat/Makefile.in index d1ec47b6e..a60e5a68d 100644 --- a/openbsd-compat/Makefile.in +++ b/openbsd-compat/Makefile.in @@ -1,4 +1,4 @@ -# $Id: Makefile.in,v 1.42 2008/05/19 22:57:08 djm Exp $ +# $Id: Makefile.in,v 1.43 2008/06/08 17:32:29 dtucker Exp $ sysconfdir=@sysconfdir@ piddir=@piddir@ @@ -18,7 +18,7 @@ LDFLAGS=-L. @LDFLAGS@ OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o fmt_scaled.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sha2.o sigact.o strlcat.o strlcpy.o strmode.o strsep.o strtonum.o strtoll.o strtoul.o vis.o -COMPAT=bsd-arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-snprintf.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o +COMPAT=bsd-arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-snprintf.o bsd-statvfs.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o PORTS=port-aix.o port-irix.o port-linux.o port-solaris.o port-tun.o port-uw.o diff --git a/openbsd-compat/bsd-statvfs.c b/openbsd-compat/bsd-statvfs.c new file mode 100644 index 000000000..844d5b464 --- /dev/null +++ b/openbsd-compat/bsd-statvfs.c @@ -0,0 +1,37 @@ +/* $Id: bsd-statvfs.c,v 1.1 2008/06/08 17:32:29 dtucker Exp $ */ + +/* + * Copyright (c) 2008 Darren Tucker + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "includes.h" + +#include + +#ifndef HAVE_STATVFS +int statvfs(const char *path, struct statvfs *buf) +{ + errno = ENOSYS; + return -1; +} +#endif + +#ifndef HAVE_FSTATVFS +int fstatvfs(int fd, struct statvfs *buf) +{ + errno = ENOSYS; + return -1; +} +#endif diff --git a/openbsd-compat/bsd-statvfs.h b/openbsd-compat/bsd-statvfs.h new file mode 100644 index 000000000..da215ffc6 --- /dev/null +++ b/openbsd-compat/bsd-statvfs.h @@ -0,0 +1,68 @@ +/* $Id: bsd-statvfs.h,v 1.1 2008/06/08 17:32:29 dtucker Exp $ */ + +/* + * Copyright (c) 2008 Darren Tucker + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "includes.h" + +#include + +#ifdef HAVE_SYS_STATFS_H +#include +#endif + +#ifndef HAVE_STATVFS + +#ifndef HAVE_FSBLKCNT_T +typedef unsigned long fsblkcnt_t; +#endif +#ifndef HAVE_FSFILCNT_T +typedef unsigned long fsfilcnt_t; +#endif + +#ifndef ST_RDONLY +#define ST_RDONLY 1 +#endif +#ifndef ST_NOSUID +#define ST_NOSUID 2 +#endif + + /* as defined in IEEE Std 1003.1, 2004 Edition */ +struct statvfs { + unsigned long f_bsize; /* File system block size. */ + unsigned long f_frsize; /* Fundamental file system block size. */ + fsblkcnt_t f_blocks; /* Total number of blocks on file system in */ + /* units of f_frsize. */ + fsblkcnt_t f_bfree; /* Total number of free blocks. */ + fsblkcnt_t f_bavail; /* Number of free blocks available to */ + /* non-privileged process. */ + fsfilcnt_t f_files; /* Total number of file serial numbers. */ + fsfilcnt_t f_ffree; /* Total number of free file serial numbers. */ + fsfilcnt_t f_favail; /* Number of file serial numbers available to */ + /* non-privileged process. */ + unsigned long f_fsid; /* File system ID. */ + unsigned long f_flag; /* BBit mask of f_flag values. */ + unsigned long f_namemax;/* Maximum filename length. */ +}; +#endif + +#ifndef HAVE_STATVFS +int statvfs(const char *, struct statvfs *); +#endif + +#ifndef HAVE_FSTATVFS +int fstatvfs(int, struct statvfs *); +#endif diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h index 0b7d979e0..50c6d990b 100644 --- a/openbsd-compat/openbsd-compat.h +++ b/openbsd-compat/openbsd-compat.h @@ -1,4 +1,4 @@ -/* $Id: openbsd-compat.h,v 1.45 2008/05/19 22:57:08 djm Exp $ */ +/* $Id: openbsd-compat.h,v 1.46 2008/06/08 17:32:29 dtucker Exp $ */ /* * Copyright (c) 1999-2003 Damien Miller. All rights reserved. @@ -144,6 +144,7 @@ int writev(int, struct iovec *, int); /* Home grown routines */ #include "bsd-misc.h" +#include "bsd-statvfs.h" #include "bsd-waitpid.h" #include "bsd-poll.h" diff --git a/sftp-client.c b/sftp-client.c index 512a8ad4b..1fda576b4 100644 --- a/sftp-client.c +++ b/sftp-client.c @@ -243,7 +243,6 @@ get_decode_stat(int fd, u_int expected_id, int quiet) return(a); } -#ifdef USE_STATVFS static int get_decode_statvfs(int fd, struct statvfs *st, u_int expected_id, int quiet) { @@ -293,7 +292,6 @@ get_decode_statvfs(int fd, struct statvfs *st, u_int expected_id, int quiet) return 0; } -#endif struct sftp_conn * do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests) @@ -813,7 +811,6 @@ do_readlink(struct sftp_conn *conn, char *path) } #endif -#ifdef USE_STATVFS int do_statvfs(struct sftp_conn *conn, const char *path, struct statvfs *st, int quiet) @@ -839,7 +836,6 @@ do_statvfs(struct sftp_conn *conn, const char *path, struct statvfs *st, return get_decode_statvfs(conn->fd_in, st, id, quiet); } -#endif #ifdef notyet int diff --git a/sftp-server.c b/sftp-server.c index 2c25df9de..9c3128347 100644 --- a/sftp-server.c +++ b/sftp-server.c @@ -481,7 +481,6 @@ send_attrib(u_int32_t id, const Attrib *a) buffer_free(&msg); } -#ifdef USE_STATVFS static void send_statvfs(u_int32_t id, struct statvfs *st) { @@ -508,7 +507,6 @@ send_statvfs(u_int32_t id, struct statvfs *st) send_msg(&msg); buffer_free(&msg); } -#endif /* parse incoming */ @@ -525,14 +523,12 @@ process_init(void) /* POSIX rename extension */ buffer_put_cstring(&msg, "posix-rename@openssh.com"); buffer_put_cstring(&msg, "1"); /* version */ -#ifdef USEE_STATVFS /* statvfs extension */ buffer_put_cstring(&msg, "statvfs@openssh.com"); buffer_put_cstring(&msg, "2"); /* version */ /* fstatvfs extension */ buffer_put_cstring(&msg, "fstatvfs@openssh.com"); buffer_put_cstring(&msg, "2"); /* version */ -#endif send_msg(&msg); buffer_free(&msg); } @@ -1142,7 +1138,6 @@ process_extended_posix_rename(u_int32_t id) xfree(newpath); } -#ifdef USE_STATVFS static void process_extended_statvfs(u_int32_t id) { @@ -1178,7 +1173,6 @@ process_extended_fstatvfs(u_int32_t id) else send_statvfs(id, &st); } -#endif static void process_extended(void) @@ -1190,12 +1184,10 @@ process_extended(void) request = get_string(NULL); if (strcmp(request, "posix-rename@openssh.com") == 0) process_extended_posix_rename(id); -#ifdef USE_STATVFS else if (strcmp(request, "statvfs@openssh.com") == 0) process_extended_statvfs(id); else if (strcmp(request, "fstatvfs@openssh.com") == 0) process_extended_fstatvfs(id); -#endif else send_status(id, SSH2_FX_OP_UNSUPPORTED); /* MUST */ xfree(request); diff --git a/sftp.c b/sftp.c index c5c3b1443..50ac03798 100644 --- a/sftp.c +++ b/sftp.c @@ -842,7 +842,6 @@ do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path, static int do_df(struct sftp_conn *conn, char *path, int hflag, int iflag) { -#ifdef USE_STATVFS struct statvfs st; char s_used[FMT_SCALED_STRSIZE]; char s_avail[FMT_SCALED_STRSIZE]; @@ -888,10 +887,6 @@ do_df(struct sftp_conn *conn, char *path, int hflag, int iflag) st.f_blocks)); } return 0; -#else - error("client does not support statvfs extension"); - return -1; -#endif } /* -- cgit v1.2.3