Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/usermode struct stat also has time_t in it, so we c...



details:   https://anonhg.NetBSD.org/src/rev/b7021d30498b
branches:  trunk
changeset: 768649:b7021d30498b
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Tue Aug 23 17:12:32 2011 +0000

description:
struct stat also has time_t in it, so we can't use that in the thunk api either

diffstat:

 sys/arch/usermode/dev/ld_thunkbus.c |  14 +++++++-------
 sys/arch/usermode/include/thunk.h   |   4 ++--
 sys/arch/usermode/usermode/thunk.c  |  20 ++++++++++++++++----
 3 files changed, 25 insertions(+), 13 deletions(-)

diffs (117 lines):

diff -r 01e90ec97352 -r b7021d30498b sys/arch/usermode/dev/ld_thunkbus.c
--- a/sys/arch/usermode/dev/ld_thunkbus.c       Tue Aug 23 17:09:11 2011 +0000
+++ b/sys/arch/usermode/dev/ld_thunkbus.c       Tue Aug 23 17:12:32 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ld_thunkbus.c,v 1.4 2011/08/23 15:56:12 jmcneill Exp $ */
+/* $NetBSD: ld_thunkbus.c,v 1.5 2011/08/23 17:12:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld_thunkbus.c,v 1.4 2011/08/23 15:56:12 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_thunkbus.c,v 1.5 2011/08/23 17:12:32 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -64,7 +64,6 @@
        struct ld_softc sc_ld;
 
        int             sc_fd;
-       struct stat     sc_st;
        void            *sc_ih;
 
        struct ld_thunkbus_transfer sc_tt;
@@ -94,6 +93,7 @@
        struct thunkbus_attach_args *taa = opaque;
        const char *path = taa->u.diskimage.path;
        struct sigaction sa;
+       ssize_t size, blksize;
 
        ld->sc_dv = self;
 
@@ -102,18 +102,18 @@
                aprint_error(": couldn't open %s: %d\n", path, errno);
                return;
        }
-       if (thunk_fstat(sc->sc_fd, &sc->sc_st) == -1) {
+       if (thunk_fstat_getsize(sc->sc_fd, &size, &blksize) == -1) {
                aprint_error(": couldn't stat %s: %d\n", path, errno);
                return;
        }
 
        aprint_naive("\n");
-       aprint_normal(": %s (%lld)\n", path, (long long)sc->sc_st.st_size);
+       aprint_normal(": %s (%lld)\n", path, (long long)size);
 
        ld->sc_flags = LDF_ENABLED;
-       ld->sc_maxxfer = sc->sc_st.st_blksize;
+       ld->sc_maxxfer = blksize;
        ld->sc_secsize = 512;
-       ld->sc_secperunit = sc->sc_st.st_size / 512;
+       ld->sc_secperunit = size / ld->sc_secsize;
        ld->sc_maxqueuecnt = 1;
        ld->sc_start = ld_thunkbus_ldstart;
        ld->sc_dump = ld_thunkbus_lddump;
diff -r 01e90ec97352 -r b7021d30498b sys/arch/usermode/include/thunk.h
--- a/sys/arch/usermode/include/thunk.h Tue Aug 23 17:09:11 2011 +0000
+++ b/sys/arch/usermode/include/thunk.h Tue Aug 23 17:12:32 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.13 2011/08/23 17:00:36 jmcneill Exp $ */
+/* $NetBSD: thunk.h,v 1.14 2011/08/23 17:12:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -68,7 +68,7 @@
 int    thunk_execv(const char *, char * const []);
 
 int    thunk_open(const char *, int, mode_t);
-int    thunk_fstat(int, struct stat *);
+int    thunk_fstat_getsize(int, ssize_t *, ssize_t *);
 ssize_t        thunk_pread(int, void *, size_t, off_t);
 ssize_t        thunk_pwrite(int, const void *, size_t, off_t);
 int    thunk_fsync(int);
diff -r 01e90ec97352 -r b7021d30498b sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c        Tue Aug 23 17:09:11 2011 +0000
+++ b/sys/arch/usermode/usermode/thunk.c        Tue Aug 23 17:12:32 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.14 2011/08/23 17:00:36 jmcneill Exp $ */
+/* $NetBSD: thunk.c,v 1.15 2011/08/23 17:12:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: thunk.c,v 1.14 2011/08/23 17:00:36 jmcneill Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.15 2011/08/23 17:12:32 jmcneill Exp $");
 
 #include <sys/types.h>
 #include <sys/ansi.h>
@@ -205,9 +205,21 @@
 }
 
 int
-thunk_fstat(int fd, struct stat *sb)
+thunk_fstat_getsize(int fd, ssize_t *size, ssize_t *blksize)
 {
-       return fstat(fd, sb);
+       struct stat st;
+       int error;
+
+       error = fstat(fd, &st);
+       if (error)
+               return -1;
+
+       if (size)
+               *size = st.st_size;
+       if (blksize)
+               *blksize = st.st_blksize;
+
+       return 0;
 }
 
 ssize_t



Home | Main Index | Thread Index | Old Index