Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/vax/boot/boot Close the file descriptor used for lo...



details:   https://anonhg.NetBSD.org/src/rev/66c27521a3e4
branches:  trunk
changeset: 338713:66c27521a3e4
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Jun 05 16:01:55 2015 +0000

description:
Close the file descriptor used for loading before jumping to the kernel.
Pointed out by Felix Deichmann on port-vax.

diffstat:

 sys/arch/vax/boot/boot/boot.c |  17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diffs (57 lines):

diff -r dd4f111f18f0 -r 66c27521a3e4 sys/arch/vax/boot/boot/boot.c
--- a/sys/arch/vax/boot/boot/boot.c     Fri Jun 05 15:41:59 2015 +0000
+++ b/sys/arch/vax/boot/boot/boot.c     Fri Jun 05 16:01:55 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot.c,v 1.32 2013/11/09 18:31:53 christos Exp $ */
+/*     $NetBSD: boot.c,v 1.33 2015/06/05 16:01:55 martin Exp $ */
 /*-
  * Copyright (c) 1982, 1986 The Regents of the University of California.
  * All rights reserved.
@@ -93,7 +93,7 @@
 void
 Xmain(void)
 {
-       int j, nu;
+       int j, nu, fd;
        u_long marks[MARK_MAX];
        extern const char bootprog_rev[];
 
@@ -133,14 +133,14 @@
                int fileindex;
                for (fileindex = 0; filelist[fileindex].name[0] != '\0';
                    fileindex++) {
-                       int err;
                        errno = 0;
                        if (!filelist[fileindex].quiet)
                                printf("> boot %s\n", filelist[fileindex].name);
                        marks[MARK_START] = 0;
-                       err = loadfile(filelist[fileindex].name, marks,
+                       fd = loadfile(filelist[fileindex].name, marks,
                            LOAD_KERNEL|COUNT_KERNEL);
-                       if (err == 0) {
+                       if (fd >= 0) {
+                               close(fd);
                                machdep_start((char *)marks[MARK_ENTRY],
                                                      marks[MARK_NSYM],
                                              (void *)marks[MARK_START],
@@ -197,7 +197,7 @@
 boot(char *arg)
 {
        char *fn = "netbsd";
-       int howto, fl, err;
+       int howto, fl, fd;
        u_long marks[MARK_MAX];
 
        if (arg) {
@@ -230,8 +230,9 @@
        }
 load:
        marks[MARK_START] = 0;
-       err = loadfile(fn, marks, LOAD_KERNEL|COUNT_KERNEL);
-       if (err == 0) {
+       fd = loadfile(fn, marks, LOAD_KERNEL|COUNT_KERNEL);
+       if (fd >= 0) {
+               close(fd);
                machdep_start((char *)marks[MARK_ENTRY],
                                      marks[MARK_NSYM],
                              (void *)marks[MARK_START],



Home | Main Index | Thread Index | Old Index