Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/usr.sbin/makefs/msdos/msdosfs_vnops.c,v rcsdiff: /ftp/cvs/cvsroot/src/usr.sbin/makefs/msdos/msdosfs_vnops.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.17 retrieving revision 1.17.4.1 diff -u -p -r1.17 -r1.17.4.1 --- src/usr.sbin/makefs/msdos/msdosfs_vnops.c 2016/01/30 09:59:27 1.17 +++ src/usr.sbin/makefs/msdos/msdosfs_vnops.c 2017/04/21 16:54:17 1.17.4.1 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vnops.c,v 1.17 2016/01/30 09:59:27 mlelstv Exp $ */ +/* $NetBSD: msdosfs_vnops.c,v 1.17.4.1 2017/04/21 16:54:17 bouyer Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -51,7 +51,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.17 2016/01/30 09:59:27 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.17.4.1 2017/04/21 16:54:17 bouyer Exp $"); #include #include @@ -98,12 +98,20 @@ static void msdosfs_times(struct msdosfsmount *pmp, struct denode *dep, const struct stat *st) { + struct timespec at; + struct timespec mt; + + if (stampst.st_ino) + st = &stampst; + #ifndef HAVE_NBTOOL_CONFIG_H - struct timespec at = st->st_atimespec; - struct timespec mt = st->st_mtimespec; + at = st->st_atimespec; + mt = st->st_mtimespec; #else - struct timespec at = { st->st_atime, 0 }; - struct timespec mt = { st->st_mtime, 0 }; + at.tv_sec = st->st_atime; + at.tv_nsec = 0; + mt.tv_sec = st->st_mtime; + mt.tv_nsec = 0; #endif unix2dostime(&at, pmp->pm_gmtoff, &dep->de_ADate, NULL, NULL); unix2dostime(&mt, pmp->pm_gmtoff, &dep->de_MDate, &dep->de_MTime, NULL); @@ -432,31 +440,29 @@ msdosfs_wfile(const char *path, struct d return 0; /* Don't bother to try to write files larger than the fs limit */ - if (st->st_size > MSDOSFS_FILESIZE_MAX) { - errno = EFBIG; - return -1; - } + if (st->st_size > MSDOSFS_FILESIZE_MAX) + return EFBIG; nsize = st->st_size; DPRINTF(("%s(nsize=%zu, osize=%zu)\n", __func__, nsize, osize)); if (nsize > osize) { - if ((error = deextend(dep, nsize, NULL)) != 0) { - errno = error; - return -1; - } - if ((error = msdosfs_updatede(dep)) != 0) { - errno = error; - return -1; - } + if ((error = deextend(dep, nsize, NULL)) != 0) + return error; + if ((error = msdosfs_updatede(dep)) != 0) + return error; } - if ((fd = open(path, O_RDONLY)) == -1) - err(1, "open %s", path); + if ((fd = open(path, O_RDONLY)) == -1) { + error = errno; + DPRINTF((1, "open %s: %s", path, strerror(error))); + return error; + } if ((dat = mmap(0, nsize, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0)) == MAP_FAILED) { - DPRINTF(("%s: mmap %s %s", __func__, node->name, - strerror(errno))); + error = errno; + DPRINTF(("%s: mmap %s: %s", __func__, node->name, + strerror(error))); close(fd); goto out; } @@ -470,6 +476,7 @@ msdosfs_wfile(const char *path, struct d cn = dep->de_StartCluster; if (cn == MSDOSFSROOT) { DPRINTF(("%s: bad lbn %lu", __func__, cn)); + error = EINVAL; goto out; } bn = cntobn(pmp, cn);