Date: Sat, 22 Apr 2017 11:30:08 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r317281 - in projects/clang500-import: cddl/contrib/opensolaris/cmd/zfs cddl/contrib/opensolaris/lib/libzfs/common contrib/bmake contrib/bmake/mk contrib/bmake/unit-tests gnu/usr.bin li... Message-ID: <201704221130.v3MBU8tm051791@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Sat Apr 22 11:30:07 2017 New Revision: 317281 URL: https://svnweb.freebsd.org/changeset/base/317281 Log: Merge ^/head r317216 through r317280. Added: projects/clang500-import/tools/build/options/WITHOUT_BSD_GREP_FASTMATCH - copied unchanged from r317280, head/tools/build/options/WITHOUT_BSD_GREP_FASTMATCH projects/clang500-import/tools/build/options/WITH_GNU_GREP_COMPAT - copied unchanged from r317280, head/tools/build/options/WITH_GNU_GREP_COMPAT Modified: projects/clang500-import/cddl/contrib/opensolaris/cmd/zfs/zfs.8 projects/clang500-import/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c projects/clang500-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c projects/clang500-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c projects/clang500-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c projects/clang500-import/contrib/bmake/ChangeLog projects/clang500-import/contrib/bmake/Makefile projects/clang500-import/contrib/bmake/arch.c projects/clang500-import/contrib/bmake/cond.c projects/clang500-import/contrib/bmake/dir.c projects/clang500-import/contrib/bmake/for.c projects/clang500-import/contrib/bmake/job.c projects/clang500-import/contrib/bmake/main.c projects/clang500-import/contrib/bmake/make_malloc.c projects/clang500-import/contrib/bmake/mk/ChangeLog projects/clang500-import/contrib/bmake/mk/auto.obj.mk projects/clang500-import/contrib/bmake/mk/install-mk projects/clang500-import/contrib/bmake/parse.c projects/clang500-import/contrib/bmake/str.c projects/clang500-import/contrib/bmake/suff.c projects/clang500-import/contrib/bmake/targ.c projects/clang500-import/contrib/bmake/unit-tests/modmatch.exp projects/clang500-import/contrib/bmake/unit-tests/modmatch.mk projects/clang500-import/contrib/bmake/var.c projects/clang500-import/gnu/usr.bin/Makefile projects/clang500-import/lib/libgssapi/gss_buffer_set.c projects/clang500-import/lib/libiconv_modules/ISO2022/citrus_iso2022.c projects/clang500-import/lib/libthread_db/libpthread_db.c projects/clang500-import/lib/libutil/gr_util.c projects/clang500-import/lib/libutil/login_cap.c projects/clang500-import/lib/libutil/pw_util.c projects/clang500-import/sbin/geom/class/eli/geom_eli.c projects/clang500-import/share/man/man5/src.conf.5 projects/clang500-import/share/mk/src.opts.mk projects/clang500-import/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.c projects/clang500-import/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.h projects/clang500-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c projects/clang500-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c projects/clang500-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c projects/clang500-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_objset.h projects/clang500-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c projects/clang500-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c projects/clang500-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_checksum.c projects/clang500-import/sys/crypto/chacha20/chacha20.c projects/clang500-import/sys/dev/syscons/scvgarndr.c projects/clang500-import/sys/fs/fuse/fuse_node.c projects/clang500-import/sys/fs/nfs/nfs_commonkrpc.c projects/clang500-import/sys/fs/nfs/nfs_commonsubs.c projects/clang500-import/sys/fs/nfsclient/nfs_clcomsubs.c projects/clang500-import/sys/fs/nfsserver/nfs_nfsdport.c projects/clang500-import/sys/geom/eli/g_eli.h projects/clang500-import/sys/geom/eli/g_eli_ctl.c projects/clang500-import/sys/net/if_lagg.c projects/clang500-import/sys/net80211/ieee80211_proto.c projects/clang500-import/sys/net80211/ieee80211_proto.h projects/clang500-import/sys/netinet/tcp_syncache.c projects/clang500-import/sys/sys/conf.h projects/clang500-import/usr.bin/bmake/Makefile projects/clang500-import/usr.bin/grep/Makefile projects/clang500-import/usr.bin/grep/grep.c projects/clang500-import/usr.bin/grep/grep.h projects/clang500-import/usr.bin/grep/util.c projects/clang500-import/usr.bin/systat/vmstat.c projects/clang500-import/usr.bin/tip/tip/cu.1 projects/clang500-import/usr.bin/vmstat/vmstat.c projects/clang500-import/usr.sbin/nfsuserd/nfsuserd.8 Directory Properties: projects/clang500-import/ (props changed) projects/clang500-import/cddl/ (props changed) projects/clang500-import/cddl/contrib/opensolaris/ (props changed) projects/clang500-import/cddl/contrib/opensolaris/cmd/zfs/ (props changed) projects/clang500-import/cddl/contrib/opensolaris/lib/libzfs/ (props changed) projects/clang500-import/contrib/bmake/ (props changed) projects/clang500-import/sys/cddl/contrib/opensolaris/ (props changed) Modified: projects/clang500-import/cddl/contrib/opensolaris/cmd/zfs/zfs.8 ============================================================================== --- projects/clang500-import/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Sat Apr 22 09:38:43 2017 (r317280) +++ projects/clang500-import/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Sat Apr 22 11:30:07 2017 (r317281) @@ -25,13 +25,13 @@ .\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved. .\" Copyright (c) 2014, Joyent, Inc. All rights reserved. .\" Copyright (c) 2013, Steven Hartland <smh@FreeBSD.org> -.\" Copyright (c) 2014 Nexenta Systems, Inc. All Rights Reserved. +.\" Copyright (c) 2016 Nexenta Systems, Inc. All Rights Reserved. .\" Copyright (c) 2014, Xin LI <delphij@FreeBSD.org> .\" Copyright (c) 2014-2015, The FreeBSD Foundation, All Rights Reserved. .\" .\" $FreeBSD$ .\" -.Dd May 31, 2016 +.Dd September 16, 2016 .Dt ZFS 8 .Os .Sh NAME @@ -114,7 +114,7 @@ .Op Fl t Ar type Ns Oo , Ns type Ns Oc Ns ... .Oo Fl s Ar property Oc Ns ... .Oo Fl S Ar property Oc Ns ... -.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot +.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot | Ns Ar bookmark Ns ... .Nm .Cm set .Ar property Ns = Ns Ar value Oo Ar property Ns = Ns Ar value Oc Ns ... @@ -2156,7 +2156,7 @@ section. .Op Fl t Ar type Ns Oo , Ns Ar type Oc Ns ... .Op Fl s Ar source Ns Oo , Ns Ar source Oc Ns ... .Ar all | property Ns Oo , Ns Ar property Oc Ns ... -.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot Ns ... +.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot Ns | Ns Ar bookmark Ns ... .Xc .Pp Displays properties for the given datasets. If no datasets are specified, then Modified: projects/clang500-import/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c ============================================================================== --- projects/clang500-import/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Sat Apr 22 09:38:43 2017 (r317280) +++ projects/clang500-import/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Sat Apr 22 11:30:07 2017 (r317281) @@ -243,7 +243,7 @@ get_usage(zfs_help_t idx) "[-o \"all\" | field[,...]]\n" "\t [-t type[,...]] [-s source[,...]]\n" "\t <\"all\" | property[,...]> " - "[filesystem|volume|snapshot] ...\n")); + "[filesystem|volume|snapshot|bookmark] ...\n")); case HELP_INHERIT: return (gettext("\tinherit [-rS] <property> " "<filesystem|volume|snapshot> ...\n")); @@ -1622,7 +1622,7 @@ zfs_do_get(int argc, char **argv) { zprop_get_cbdata_t cb = { 0 }; int i, c, flags = ZFS_ITER_ARGS_CAN_BE_PATHS; - int types = ZFS_TYPE_DATASET; + int types = ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK; char *value, *fields; int ret = 0; int limit = 0; Modified: projects/clang500-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c ============================================================================== --- projects/clang500-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Sat Apr 22 09:38:43 2017 (r317280) +++ projects/clang500-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Sat Apr 22 11:30:07 2017 (r317281) @@ -103,7 +103,7 @@ zfs_validate_name(libzfs_handle_t *hdl, char what; (void) zfs_prop_get_table(); - if (dataset_namecheck(path, &why, &what) != 0) { + if (entity_namecheck(path, &why, &what) != 0) { if (hdl != NULL) { switch (why) { case NAME_ERR_TOOLONG: @@ -132,9 +132,10 @@ zfs_validate_name(libzfs_handle_t *hdl, "'%c' in name"), what); break; - case NAME_ERR_MULTIPLE_AT: + case NAME_ERR_MULTIPLE_DELIMITERS: zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "multiple '@' delimiters in name")); + "multiple '@' and/or '#' delimiters in " + "name")); break; case NAME_ERR_NOLETTER: @@ -165,7 +166,7 @@ zfs_validate_name(libzfs_handle_t *hdl, if (!(type & ZFS_TYPE_SNAPSHOT) && strchr(path, '@') != NULL) { if (hdl != NULL) zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "snapshot delimiter '@' in filesystem name")); + "snapshot delimiter '@' is not expected here")); return (0); } @@ -176,6 +177,20 @@ zfs_validate_name(libzfs_handle_t *hdl, return (0); } + if (!(type & ZFS_TYPE_BOOKMARK) && strchr(path, '#') != NULL) { + if (hdl != NULL) + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "bookmark delimiter '#' is not expected here")); + return (0); + } + + if (type == ZFS_TYPE_BOOKMARK && strchr(path, '#') == NULL) { + if (hdl != NULL) + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "missing '#' delimiter in bookmark name")); + return (0); + } + if (modifying && strchr(path, '%') != NULL) { if (hdl != NULL) zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, @@ -613,8 +628,36 @@ make_bookmark_handle(zfs_handle_t *paren return (zhp); } +struct zfs_open_bookmarks_cb_data { + const char *path; + zfs_handle_t *zhp; +}; + +static int +zfs_open_bookmarks_cb(zfs_handle_t *zhp, void *data) +{ + struct zfs_open_bookmarks_cb_data *dp = data; + + /* + * Is it the one we are looking for? + */ + if (strcmp(dp->path, zfs_get_name(zhp)) == 0) { + /* + * We found it. Save it and let the caller know we are done. + */ + dp->zhp = zhp; + return (EEXIST); + } + + /* + * Not found. Close the handle and ask for another one. + */ + zfs_close(zhp); + return (0); +} + /* - * Opens the given snapshot, filesystem, or volume. The 'types' + * Opens the given snapshot, bookmark, filesystem, or volume. The 'types' * argument is a mask of acceptable types. The function will print an * appropriate error message and return NULL if it can't be opened. */ @@ -623,6 +666,7 @@ zfs_open(libzfs_handle_t *hdl, const cha { zfs_handle_t *zhp; char errbuf[1024]; + char *bookp; (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, "cannot open '%s'"), path); @@ -630,20 +674,68 @@ zfs_open(libzfs_handle_t *hdl, const cha /* * Validate the name before we even try to open it. */ - if (!zfs_validate_name(hdl, path, ZFS_TYPE_DATASET, B_FALSE)) { - zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "invalid dataset name")); + if (!zfs_validate_name(hdl, path, types, B_FALSE)) { (void) zfs_error(hdl, EZFS_INVALIDNAME, errbuf); return (NULL); } /* - * Try to get stats for the dataset, which will tell us if it exists. + * Bookmarks needs to be handled separately. */ - errno = 0; - if ((zhp = make_dataset_handle(hdl, path)) == NULL) { - (void) zfs_standard_error(hdl, errno, errbuf); - return (NULL); + bookp = strchr(path, '#'); + if (bookp == NULL) { + /* + * Try to get stats for the dataset, which will tell us if it + * exists. + */ + errno = 0; + if ((zhp = make_dataset_handle(hdl, path)) == NULL) { + (void) zfs_standard_error(hdl, errno, errbuf); + return (NULL); + } + } else { + char dsname[ZFS_MAX_DATASET_NAME_LEN]; + zfs_handle_t *pzhp; + struct zfs_open_bookmarks_cb_data cb_data = {path, NULL}; + + /* + * We need to cut out '#' and everything after '#' + * to get the parent dataset name only. + */ + assert(bookp - path < sizeof (dsname)); + (void) strncpy(dsname, path, bookp - path); + dsname[bookp - path] = '\0'; + + /* + * Create handle for the parent dataset. + */ + errno = 0; + if ((pzhp = make_dataset_handle(hdl, dsname)) == NULL) { + (void) zfs_standard_error(hdl, errno, errbuf); + return (NULL); + } + + /* + * Iterate bookmarks to find the right one. + */ + errno = 0; + if ((zfs_iter_bookmarks(pzhp, zfs_open_bookmarks_cb, + &cb_data) == 0) && (cb_data.zhp == NULL)) { + (void) zfs_error(hdl, EZFS_NOENT, errbuf); + zfs_close(pzhp); + return (NULL); + } + if (cb_data.zhp == NULL) { + (void) zfs_standard_error(hdl, errno, errbuf); + zfs_close(pzhp); + return (NULL); + } + zhp = cb_data.zhp; + + /* + * Cleanup. + */ + zfs_close(pzhp); } if (zhp == NULL) { Modified: projects/clang500-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c ============================================================================== --- projects/clang500-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Sat Apr 22 09:38:43 2017 (r317280) +++ projects/clang500-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Sat Apr 22 11:30:07 2017 (r317281) @@ -947,9 +947,10 @@ zpool_name_valid(libzfs_handle_t *hdl, b "trailing slash in name")); break; - case NAME_ERR_MULTIPLE_AT: + case NAME_ERR_MULTIPLE_DELIMITERS: zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "multiple '@' delimiters in name")); + "multiple '@' and/or '#' delimiters in " + "name")); break; default: Modified: projects/clang500-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c ============================================================================== --- projects/clang500-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Sat Apr 22 09:38:43 2017 (r317280) +++ projects/clang500-import/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Sat Apr 22 11:30:07 2017 (r317281) @@ -718,7 +718,7 @@ zfs_get_pool_handle(const zfs_handle_t * * Given a name, determine whether or not it's a valid path * (starts with '/' or "./"). If so, walk the mnttab trying * to match the device number. If not, treat the path as an - * fs/vol/snap name. + * fs/vol/snap/bkmark name. */ zfs_handle_t * zfs_path_to_zhandle(libzfs_handle_t *hdl, char *path, zfs_type_t argtype) Modified: projects/clang500-import/contrib/bmake/ChangeLog ============================================================================== --- projects/clang500-import/contrib/bmake/ChangeLog Sat Apr 22 09:38:43 2017 (r317280) +++ projects/clang500-import/contrib/bmake/ChangeLog Sat Apr 22 11:30:07 2017 (r317281) @@ -1,3 +1,29 @@ +2017-04-20 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170420 + Merge with NetBSD make, pick up + o main.c: only use -C arg "as is" if it contains no + relative component. + +2017-04-18 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170418 + Merge with NetBSD make, pick up + o main.c: fix Main_SetObjdir() for relative paths (eg obj). + +2017-04-17 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170417 + Merge with NetBSD make, pick up + o fixes a number of coverity complaints + - check return value of fseek, fcntl + - plug memory leak in Dir_FindFile, Var_LoopExpand, + JobPrintCommand, ParseTraditionalInclude + - use bmake_malloc() where NULL is not tollerated + - use MAKE_ATTR_UNUSED rather that kludges like + return(unused ? 0 : 0) + - use purge_cached_realpaths() rather than abuse cached_realpath() + 2017-04-13 Simon J. Gerraty <sjg@bad.crufty.net> * Makefile (_MAKE_VERSION): 20170413 Modified: projects/clang500-import/contrib/bmake/Makefile ============================================================================== --- projects/clang500-import/contrib/bmake/Makefile Sat Apr 22 09:38:43 2017 (r317280) +++ projects/clang500-import/contrib/bmake/Makefile Sat Apr 22 11:30:07 2017 (r317281) @@ -1,7 +1,7 @@ -# $Id: Makefile,v 1.85 2017/04/13 16:29:40 sjg Exp $ +# $Id: Makefile,v 1.88 2017/04/20 14:51:14 sjg Exp $ # Base version on src date -_MAKE_VERSION= 20170413 +_MAKE_VERSION= 20170420 PROG= bmake Modified: projects/clang500-import/contrib/bmake/arch.c ============================================================================== --- projects/clang500-import/contrib/bmake/arch.c Sat Apr 22 09:38:43 2017 (r317280) +++ projects/clang500-import/contrib/bmake/arch.c Sat Apr 22 11:30:07 2017 (r317281) @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.69 2016/04/06 09:57:00 gson Exp $ */ +/* $NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: arch.c,v 1.69 2016/04/06 09:57:00 gson Exp $"; +static char rcsid[] = "$NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: arch.c,v 1.69 2016/04/06 09:57:00 gson Exp $"); +__RCSID("$NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $"); #endif #endif /* not lint */ #endif @@ -726,7 +726,8 @@ ArchStatMember(char *archive, char *memb if (fread(memName, elen, 1, arch) != 1) goto badarch; memName[elen] = '\0'; - fseek(arch, -elen, SEEK_CUR); + if (fseek(arch, -elen, SEEK_CUR) != 0) + goto badarch; if (DEBUG(ARCH) || DEBUG(MAKE)) { fprintf(debug_file, "ArchStat: Extended format entry for %s\n", memName); } @@ -737,7 +738,8 @@ ArchStatMember(char *archive, char *memb Hash_SetValue(he, bmake_malloc(sizeof(struct ar_hdr))); memcpy(Hash_GetValue(he), &arh, sizeof(struct ar_hdr)); } - fseek(arch, (size + 1) & ~1, SEEK_CUR); + if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0) + goto badarch; } fclose(arch); @@ -956,7 +958,10 @@ ArchFindMember(char *archive, char *memb * the file at the actual member, rather than its header, but * not here... */ - fseek(arch, -sizeof(struct ar_hdr), SEEK_CUR); + if (fseek(arch, -sizeof(struct ar_hdr), SEEK_CUR) != 0) { + fclose(arch); + return NULL; + } return (arch); } } else @@ -986,10 +991,17 @@ ArchFindMember(char *archive, char *memb } if (strncmp(ename, member, len) == 0) { /* Found as extended name */ - fseek(arch, -sizeof(struct ar_hdr) - elen, SEEK_CUR); + if (fseek(arch, -sizeof(struct ar_hdr) - elen, + SEEK_CUR) != 0) { + fclose(arch); + return NULL; + } return (arch); } - fseek(arch, -elen, SEEK_CUR); + if (fseek(arch, -elen, SEEK_CUR) != 0) { + fclose(arch); + return NULL; + } goto skip; } else #endif @@ -1002,9 +1014,12 @@ skip: * extract the size of the file from the 'size' field of the * header and round it up during the seek. */ - arhPtr->ar_size[sizeof(arhPtr->AR_SIZE)-1] = '\0'; + arhPtr->AR_SIZE[sizeof(arhPtr->AR_SIZE)-1] = '\0'; size = (int)strtol(arhPtr->AR_SIZE, NULL, 10); - fseek(arch, (size + 1) & ~1, SEEK_CUR); + if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0) { + fclose(arch); + return NULL; + } } } Modified: projects/clang500-import/contrib/bmake/cond.c ============================================================================== --- projects/clang500-import/contrib/bmake/cond.c Sat Apr 22 09:38:43 2017 (r317280) +++ projects/clang500-import/contrib/bmake/cond.c Sat Apr 22 11:30:07 2017 (r317281) @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $ */ +/* $NetBSD: cond.c,v 1.75 2017/04/16 20:59:04 riastradh Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.75 2017/04/16 20:59:04 riastradh Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $"); +__RCSID("$NetBSD: cond.c,v 1.75 2017/04/16 20:59:04 riastradh Exp $"); #endif #endif /* not lint */ #endif @@ -91,6 +91,7 @@ __RCSID("$NetBSD: cond.c,v 1.74 2016/02/ * */ +#include <assert.h> #include <ctype.h> #include <errno.h> /* For strtoul() error checking */ @@ -1174,8 +1175,9 @@ Cond_EvalExpression(const struct If *inf break; dflt_info = info; } + assert(info != NULL); - if_info = info != NULL ? info : ifs + 4; + if_info = info; condExpr = line; condPushBack = TOK_NONE; Modified: projects/clang500-import/contrib/bmake/dir.c ============================================================================== --- projects/clang500-import/contrib/bmake/dir.c Sat Apr 22 09:38:43 2017 (r317280) +++ projects/clang500-import/contrib/bmake/dir.c Sat Apr 22 11:30:07 2017 (r317281) @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.69 2017/01/31 06:54:23 sjg Exp $ */ +/* $NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: dir.c,v 1.69 2017/01/31 06:54:23 sjg Exp $"; +static char rcsid[] = "$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: dir.c,v 1.69 2017/01/31 06:54:23 sjg Exp $"); +__RCSID("$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $"); #endif #endif /* not lint */ #endif @@ -803,11 +803,11 @@ DirExpandInt(const char *word, Lst path, *----------------------------------------------------------------------- */ static int -DirPrintWord(void *word, void *dummy) +DirPrintWord(void *word, void *dummy MAKE_ATTR_UNUSED) { fprintf(debug_file, "%s ", (char *)word); - return(dummy ? 0 : 0); + return 0; } /*- @@ -1315,8 +1315,14 @@ Dir_FindFile(const char *name, Lst path) fprintf(debug_file, " Trying exact path matches...\n"); } - if (!hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL) - return *file?file:NULL; + if (!hasLastDot && cur && ((file = DirLookupAbs(cur, name, cp)) + != NULL)) { + if (file[0] == '\0') { + free(file); + return NULL; + } + return file; + } (void)Lst_Open(path); while ((ln = Lst_Next(path)) != NULL) { @@ -1325,13 +1331,23 @@ Dir_FindFile(const char *name, Lst path) continue; if ((file = DirLookupAbs(p, name, cp)) != NULL) { Lst_Close(path); - return *file?file:NULL; + if (file[0] == '\0') { + free(file); + return NULL; + } + return file; } } Lst_Close(path); - if (hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL) - return *file?file:NULL; + if (hasLastDot && cur && ((file = DirLookupAbs(cur, name, cp)) + != NULL)) { + if (file[0] == '\0') { + free(file); + return NULL; + } + return file; + } } /* @@ -1851,10 +1867,10 @@ Dir_PrintDirectories(void) } static int -DirPrintDir(void *p, void *dummy) +DirPrintDir(void *p, void *dummy MAKE_ATTR_UNUSED) { fprintf(debug_file, "%s ", ((Path *)p)->name); - return (dummy ? 0 : 0); + return 0; } void Modified: projects/clang500-import/contrib/bmake/for.c ============================================================================== --- projects/clang500-import/contrib/bmake/for.c Sat Apr 22 09:38:43 2017 (r317280) +++ projects/clang500-import/contrib/bmake/for.c Sat Apr 22 11:30:07 2017 (r317281) @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $ */ +/* $NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -30,14 +30,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $"; +static char rcsid[] = "$NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $"); +__RCSID("$NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $"); #endif #endif /* not lint */ #endif @@ -427,7 +427,7 @@ For_Iterate(void *v_arg, size_t *ret_len for (cp = cmd_cp; (cp = strchr(cp, '$')) != NULL;) { char ech; ch = *++cp; - if ((ch == '(' && (ech = ')')) || (ch == '{' && (ech = '}'))) { + if ((ch == '(' && (ech = ')', 1)) || (ch == '{' && (ech = '}', 1))) { cp++; /* Check variable name against the .for loop variables */ STRLIST_FOREACH(var, &arg->vars, i) { Modified: projects/clang500-import/contrib/bmake/job.c ============================================================================== --- projects/clang500-import/contrib/bmake/job.c Sat Apr 22 09:38:43 2017 (r317280) +++ projects/clang500-import/contrib/bmake/job.c Sat Apr 22 11:30:07 2017 (r317281) @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.188 2016/08/26 23:28:39 dholland Exp $ */ +/* $NetBSD: job.c,v 1.190 2017/04/16 21:23:43 riastradh Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: job.c,v 1.188 2016/08/26 23:28:39 dholland Exp $"; +static char rcsid[] = "$NetBSD: job.c,v 1.190 2017/04/16 21:23:43 riastradh Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: job.c,v 1.188 2016/08/26 23:28:39 dholland Exp $"); +__RCSID("$NetBSD: job.c,v 1.190 2017/04/16 21:23:43 riastradh Exp $"); #endif #endif /* not lint */ #endif @@ -443,7 +443,7 @@ static void JobSigUnlock(sigset_t *omask static void JobCreatePipe(Job *job, int minfd) { - int i, fd; + int i, fd, flags; if (pipe(job->jobPipe) == -1) Punt("Cannot create pipe: %s", strerror(errno)); @@ -458,8 +458,10 @@ JobCreatePipe(Job *job, int minfd) } /* Set close-on-exec flag for both */ - (void)fcntl(job->jobPipe[0], F_SETFD, FD_CLOEXEC); - (void)fcntl(job->jobPipe[1], F_SETFD, FD_CLOEXEC); + if (fcntl(job->jobPipe[0], F_SETFD, FD_CLOEXEC) == -1) + Punt("Cannot set close-on-exec: %s", strerror(errno)); + if (fcntl(job->jobPipe[1], F_SETFD, FD_CLOEXEC) == -1) + Punt("Cannot set close-on-exec: %s", strerror(errno)); /* * We mark the input side of the pipe non-blocking; we poll(2) the @@ -467,8 +469,12 @@ JobCreatePipe(Job *job, int minfd) * race for the token when a new one becomes available, so the read * from the pipe should not block. */ - fcntl(job->jobPipe[0], F_SETFL, - fcntl(job->jobPipe[0], F_GETFL, 0) | O_NONBLOCK); + flags = fcntl(job->jobPipe[0], F_GETFL, 0); + if (flags == -1) + Punt("Cannot get flags: %s", strerror(errno)); + flags |= O_NONBLOCK; + if (fcntl(job->jobPipe[0], F_SETFL, flags) == -1) + Punt("Cannot set flags: %s", strerror(errno)); } /*- @@ -770,6 +776,7 @@ JobPrintCommand(void *cmdp, void *jobp) * but this one needs to be - use compat mode just for it. */ CompatRunCommand(cmdp, job->node); + free(cmdStart); return 0; } break; @@ -1398,16 +1405,28 @@ JobExec(Job *job, char **argv) execError("dup2", "job->cmdFILE"); _exit(1); } - (void)fcntl(0, F_SETFD, 0); - (void)lseek(0, (off_t)0, SEEK_SET); + if (fcntl(0, F_SETFD, 0) == -1) { + execError("fcntl clear close-on-exec", "stdin"); + _exit(1); + } + if (lseek(0, (off_t)0, SEEK_SET) == -1) { + execError("lseek to 0", "stdin"); + _exit(1); + } if (Always_pass_job_queue || (job->node->type & (OP_MAKE | OP_SUBMAKE))) { /* * Pass job token pipe to submakes. */ - fcntl(tokenWaitJob.inPipe, F_SETFD, 0); - fcntl(tokenWaitJob.outPipe, F_SETFD, 0); + if (fcntl(tokenWaitJob.inPipe, F_SETFD, 0) == -1) { + execError("clear close-on-exec", "tokenWaitJob.inPipe"); + _exit(1); + } + if (fcntl(tokenWaitJob.outPipe, F_SETFD, 0) == -1) { + execError("clear close-on-exec", "tokenWaitJob.outPipe"); + _exit(1); + } } /* @@ -1424,7 +1443,10 @@ JobExec(Job *job, char **argv) * it before routing the shell's error output to the same place as * its standard output. */ - (void)fcntl(1, F_SETFD, 0); + if (fcntl(1, F_SETFD, 0) == -1) { + execError("clear close-on-exec", "stdout"); + _exit(1); + } if (dup2(1, 2) == -1) { execError("dup2", "1, 2"); _exit(1); Modified: projects/clang500-import/contrib/bmake/main.c ============================================================================== --- projects/clang500-import/contrib/bmake/main.c Sat Apr 22 09:38:43 2017 (r317280) +++ projects/clang500-import/contrib/bmake/main.c Sat Apr 22 11:30:07 2017 (r317281) @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.260 2017/04/13 13:55:23 christos Exp $ */ +/* $NetBSD: main.c,v 1.264 2017/04/20 03:57:27 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,7 +69,7 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: main.c,v 1.260 2017/04/13 13:55:23 christos Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.264 2017/04/20 03:57:27 sjg Exp $"; #else #include <sys/cdefs.h> #ifndef lint @@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19 #if 0 static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: main.c,v 1.260 2017/04/13 13:55:23 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.264 2017/04/20 03:57:27 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -187,6 +187,7 @@ static const char * tracefile; static void MainParseArgs(int, char **); static int ReadMakefile(const void *, const void *); static void usage(void) MAKE_ATTR_DEAD; +static void purge_cached_realpaths(void); static Boolean ignorePWD; /* if we use -C, PWD is meaningless */ static char objdir[MAXPATHLEN + 1]; /* where we chdir'ed to */ @@ -336,7 +337,7 @@ parse_debug_options(const char *argvalue goto debug_setbuf; } len = strlen(modules); - fname = malloc(len + 20); + fname = bmake_malloc(len + 20); memcpy(fname, modules, len + 1); /* Let the filename be modified by the pid */ if (strcmp(fname + len - 3, ".%d") == 0) @@ -367,6 +368,32 @@ debug_setbuf: } } +/* + * does path contain any relative components + */ +static int +is_relpath(const char *path) +{ + const char *cp; + + if (path[0] != '/') + return TRUE; + cp = path; + do { + cp = strstr(cp, "/."); + if (!cp) + break; + cp += 2; + if (cp[0] == '/' || cp[0] == '\0') + return TRUE; + else if (cp[0] == '.') { + if (cp[1] == '/' || cp[1] == '\0') + return TRUE; + } + } while (cp); + return FALSE; +} + /*- * MainParseArgs -- * Parse a given argument vector. Called from main() and from @@ -458,7 +485,7 @@ rearg: (void)fprintf(stderr, "%s: %s.\n", progname, strerror(errno)); exit(2); } - if (argvalue[0] == '/' && + if (!is_relpath(argvalue) && stat(argvalue, &sa) != -1 && stat(curdir, &sb) != -1 && sa.st_ino == sb.st_ino && @@ -732,8 +759,10 @@ Main_SetObjdir(const char *fmt, ...) va_end(ap); if (path[0] != '/') { - snprintf(buf, MAXPATHLEN, "%s/%s", curdir, path); - path = buf; + char buf2[MAXPATHLEN + 1]; + + snprintf(buf2, MAXPATHLEN, "%s/%s", curdir, path); + path = buf2; } /* look for the directory and try to chdir there */ @@ -746,7 +775,7 @@ Main_SetObjdir(const char *fmt, ...) Var_Set(".OBJDIR", objdir, VAR_GLOBAL, 0); setenv("PWD", objdir, 1); Dir_InitDot(); - cached_realpath(".OBJDIR", NULL); /* purge */ + purge_cached_realpaths(); rc = TRUE; if (enterFlag && strcmp(objdir, curdir) != 0) enterFlagObj = TRUE; @@ -1907,42 +1936,56 @@ usage(void) exit(2); } - /* * realpath(3) can get expensive, cache results... */ +static GNode *cached_realpaths = NULL; + +static GNode * +get_cached_realpaths(void) +{ + + if (!cached_realpaths) { + cached_realpaths = Targ_NewGN("Realpath"); +#ifndef DEBUG_REALPATH_CACHE + cached_realpaths->flags = INTERNAL; +#endif + } + + return cached_realpaths; +} + +/* purge any relative paths */ +static void +purge_cached_realpaths(void) +{ + GNode *cache = get_cached_realpaths(); + Hash_Entry *he, *nhe; + Hash_Search hs; + + he = Hash_EnumFirst(&cache->context, &hs); + while (he) { + nhe = Hash_EnumNext(&hs); + if (he->name[0] != '/') { + if (DEBUG(DIR)) + fprintf(stderr, "cached_realpath: purging %s\n", he->name); + Hash_DeleteEntry(&cache->context, he); + } + he = nhe; + } +} + char * cached_realpath(const char *pathname, char *resolved) { - static GNode *cache; + GNode *cache; char *rp, *cp; if (!pathname || !pathname[0]) return NULL; - if (!cache) { - cache = Targ_NewGN("Realpath"); -#ifndef DEBUG_REALPATH_CACHE - cache->flags = INTERNAL; -#endif - } - if (resolved == NULL && strcmp(pathname, ".OBJDIR") == 0) { - /* purge any relative paths */ - Hash_Entry *he, *nhe; - Hash_Search hs; - - he = Hash_EnumFirst(&cache->context, &hs); - while (he) { - nhe = Hash_EnumNext(&hs); - if (he->name[0] != '/') { - if (DEBUG(DIR)) - fprintf(stderr, "cached_realpath: purging %s\n", he->name); - Hash_DeleteEntry(&cache->context, he); - } - he = nhe; - } - return NULL; - } + cache = get_cached_realpaths(); + if ((rp = Var_Value(pathname, cache, &cp)) != NULL) { /* a hit */ strlcpy(resolved, rp, MAXPATHLEN); Modified: projects/clang500-import/contrib/bmake/make_malloc.c ============================================================================== --- projects/clang500-import/contrib/bmake/make_malloc.c Sat Apr 22 09:38:43 2017 (r317280) +++ projects/clang500-import/contrib/bmake/make_malloc.c Sat Apr 22 11:30:07 2017 (r317281) @@ -1,4 +1,4 @@ -/* $NetBSD: make_malloc.c,v 1.10 2012/06/20 17:46:28 sjg Exp $ */ +/* $NetBSD: make_malloc.c,v 1.11 2017/04/16 20:20:24 dholland Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ #ifdef MAKE_NATIVE #include <sys/cdefs.h> -__RCSID("$NetBSD: make_malloc.c,v 1.10 2012/06/20 17:46:28 sjg Exp $"); +__RCSID("$NetBSD: make_malloc.c,v 1.11 2017/04/16 20:20:24 dholland Exp $"); #endif #include <stdio.h> @@ -39,13 +39,13 @@ __RCSID("$NetBSD: make_malloc.c,v 1.10 2 #include "make.h" #ifndef USE_EMALLOC -static void enomem(void) MAKE_ATTR_DEAD; +static MAKE_ATTR_DEAD void enomem(void); /* * enomem -- * die when out of memory. */ -static void +static MAKE_ATTR_DEAD void enomem(void) { (void)fprintf(stderr, "%s: %s.\n", progname, strerror(ENOMEM)); Modified: projects/clang500-import/contrib/bmake/mk/ChangeLog ============================================================================== --- projects/clang500-import/contrib/bmake/mk/ChangeLog Sat Apr 22 09:38:43 2017 (r317280) +++ projects/clang500-import/contrib/bmake/mk/ChangeLog Sat Apr 22 11:30:07 2017 (r317281) @@ -1,3 +1,10 @@ +2017-04-18 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20170418 + + * auto.obj.mk: if using MAKEOBJDIRPREFIX check if it is a + prefix match for .CURDIR - in which case .CURDIR *is* __objdir. + 2017-04-01 Simon J. Gerraty <sjg@bad.crufty.net> * install-mk (MK_VERSION): 20170401 Modified: projects/clang500-import/contrib/bmake/mk/auto.obj.mk ============================================================================== --- projects/clang500-import/contrib/bmake/mk/auto.obj.mk Sat Apr 22 09:38:43 2017 (r317280) +++ projects/clang500-import/contrib/bmake/mk/auto.obj.mk Sat Apr 22 11:30:07 2017 (r317281) @@ -1,4 +1,4 @@ -# $Id: auto.obj.mk,v 1.13 2017/03/24 20:53:22 sjg Exp $ +# $Id: auto.obj.mk,v 1.14 2017/04/18 23:53:18 sjg Exp $ # # @(#) Copyright (c) 2004, Simon J. Gerraty # @@ -41,6 +41,10 @@ MKOBJDIRS= auto # Use __objdir here so it is easier to tweak without impacting # the logic. .if !empty(MAKEOBJDIRPREFIX) +.if ${.CURDIR:M${MAKEOBJDIRPREFIX}/*} != "" +# we are already in obj tree! +__objdir?= ${.CURDIR} +.endif __objdir?= ${MAKEOBJDIRPREFIX}${.CURDIR} .endif __objdir?= ${MAKEOBJDIR:Uobj} Modified: projects/clang500-import/contrib/bmake/mk/install-mk ============================================================================== --- projects/clang500-import/contrib/bmake/mk/install-mk Sat Apr 22 09:38:43 2017 (r317280) +++ projects/clang500-import/contrib/bmake/mk/install-mk Sat Apr 22 11:30:07 2017 (r317281) @@ -55,7 +55,7 @@ # Simon J. Gerraty <sjg@crufty.net> # RCSid: -# $Id: install-mk,v 1.140 2017/04/03 21:04:09 sjg Exp $ +# $Id: install-mk,v 1.141 2017/04/18 23:53:18 sjg Exp $ # # @(#) Copyright (c) 1994 Simon J. Gerraty # @@ -70,7 +70,7 @@ # sjg@crufty.net # -MK_VERSION=20170401 +MK_VERSION=20170418 OWNER= GROUP= MODE=444 Modified: projects/clang500-import/contrib/bmake/parse.c ============================================================================== --- projects/clang500-import/contrib/bmake/parse.c Sat Apr 22 09:38:43 2017 (r317280) +++ projects/clang500-import/contrib/bmake/parse.c Sat Apr 22 11:30:07 2017 (r317281) @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.218 2017/03/01 16:39:49 sjg Exp $ */ +/* $NetBSD: parse.c,v 1.225 2017/04/17 13:29:07 maya Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: parse.c,v 1.218 2017/03/01 16:39:49 sjg Exp $"; +static char rcsid[] = "$NetBSD: parse.c,v 1.225 2017/04/17 13:29:07 maya Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: parse.c,v 1.218 2017/03/01 16:39:49 sjg Exp $"); +__RCSID("$NetBSD: parse.c,v 1.225 2017/04/17 13:29:07 maya Exp $"); #endif #endif /* not lint */ #endif @@ -130,6 +130,7 @@ __RCSID("$NetBSD: parse.c,v 1.218 2017/0 #include <errno.h> #include <stdarg.h> #include <stdio.h> +#include <stdint.h> #include "make.h" #include "hash.h" @@ -539,7 +540,7 @@ loadfile(const char *path, int fd) if (lf->buf != MAP_FAILED) { /* succeeded */ if (lf->len == lf->maplen && lf->buf[lf->len - 1] != '\n') { - char *b = malloc(lf->len + 1); + char *b = bmake_malloc(lf->len + 1); b[lf->len] = '\n'; memcpy(b, lf->buf, lf->len++); munmap(lf->buf, lf->maplen); *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704221130.v3MBU8tm051791>