From owner-svn-src-vendor@FreeBSD.ORG Tue Sep 25 10:41:31 2012 Return-Path: Delivered-To: svn-src-vendor@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 02435106566B; Tue, 25 Sep 2012 10:41:31 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DE3A48FC08; Tue, 25 Sep 2012 10:41:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q8PAfUJn014979; Tue, 25 Sep 2012 10:41:30 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q8PAfUW6014969; Tue, 25 Sep 2012 10:41:30 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201209251041.q8PAfUW6014969@svn.freebsd.org> From: Ed Schouten Date: Tue, 25 Sep 2012 10:41:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r240915 - in vendor/NetBSD/libedit/dist: . TEST readline X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Sep 2012 10:41:31 -0000 Author: ed Date: Tue Sep 25 10:41:30 2012 New Revision: 240915 URL: http://svn.freebsd.org/changeset/base/240915 Log: Vendor import NetBSD's libedit of "2012/09/25 10:41:11 UTC". Obtained from: NetBSD Added: vendor/NetBSD/libedit/dist/TEST/rl1.c vendor/NetBSD/libedit/dist/keymacro.c vendor/NetBSD/libedit/dist/keymacro.h vendor/NetBSD/libedit/dist/terminal.c vendor/NetBSD/libedit/dist/terminal.h Deleted: vendor/NetBSD/libedit/dist/key.c vendor/NetBSD/libedit/dist/key.h vendor/NetBSD/libedit/dist/term.c vendor/NetBSD/libedit/dist/term.h Modified: vendor/NetBSD/libedit/dist/Makefile vendor/NetBSD/libedit/dist/TEST/wtc1.c vendor/NetBSD/libedit/dist/chared.c vendor/NetBSD/libedit/dist/chared.h vendor/NetBSD/libedit/dist/chartype.c vendor/NetBSD/libedit/dist/chartype.h vendor/NetBSD/libedit/dist/common.c vendor/NetBSD/libedit/dist/config.h vendor/NetBSD/libedit/dist/editline.3 vendor/NetBSD/libedit/dist/editrc.5 vendor/NetBSD/libedit/dist/el.c vendor/NetBSD/libedit/dist/el.h vendor/NetBSD/libedit/dist/eln.c vendor/NetBSD/libedit/dist/emacs.c vendor/NetBSD/libedit/dist/filecomplete.c vendor/NetBSD/libedit/dist/hist.c vendor/NetBSD/libedit/dist/hist.h vendor/NetBSD/libedit/dist/histedit.h vendor/NetBSD/libedit/dist/history.c vendor/NetBSD/libedit/dist/makelist vendor/NetBSD/libedit/dist/map.c vendor/NetBSD/libedit/dist/parse.c vendor/NetBSD/libedit/dist/prompt.c vendor/NetBSD/libedit/dist/read.c vendor/NetBSD/libedit/dist/readline.c vendor/NetBSD/libedit/dist/readline/readline.h vendor/NetBSD/libedit/dist/refresh.c vendor/NetBSD/libedit/dist/search.c vendor/NetBSD/libedit/dist/sig.c vendor/NetBSD/libedit/dist/sys.h vendor/NetBSD/libedit/dist/tokenizer.c vendor/NetBSD/libedit/dist/tty.c vendor/NetBSD/libedit/dist/tty.h vendor/NetBSD/libedit/dist/vi.c Modified: vendor/NetBSD/libedit/dist/Makefile ============================================================================== --- vendor/NetBSD/libedit/dist/Makefile Tue Sep 25 05:56:59 2012 (r240914) +++ vendor/NetBSD/libedit/dist/Makefile Tue Sep 25 10:41:30 2012 (r240915) @@ -1,17 +1,22 @@ -# $NetBSD: Makefile,v 1.41 2010/02/03 15:34:43 roy Exp $ +# $NetBSD: Makefile,v 1.51 2012/08/10 12:20:10 joerg Exp $ # @(#)Makefile 8.1 (Berkeley) 6/4/93 USE_SHLIBDIR= yes WIDECHAR ?= yes -WARNS= 4 +WARNS?= 5 LIB= edit LIBDPLIBS+= terminfo ${.CURDIR}/../libterminfo +.include "bsd.own.mk" + +COPTS+= -Wunused-parameter +CWARNFLAGS.gcc+= -Wconversion + OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \ - hist.c key.c map.c chartype.c \ - parse.c prompt.c read.c refresh.c search.c sig.c term.c tty.c vi.c + hist.c keymacro.c map.c chartype.c \ + parse.c prompt.c read.c refresh.c search.c sig.c terminal.c tty.c vi.c MAN= editline.3 editrc.5 @@ -113,10 +118,17 @@ historyn.c: makelist Makefile mv ${.TARGET}.tmp ${.TARGET} tc1.o: ${LIBEDITDIR}/TEST/tc1.c - + tc1: libedit.a tc1.o ${_MKTARGET_LINK} ${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermlib .include .include + +# XXX +.if defined(HAVE_GCC) && ${HAVE_GCC} >= 45 +COPTS.editline.c+= -Wno-cast-qual +COPTS.tokenizer.c+= -Wno-cast-qual +COPTS.tokenizern.c+= -Wno-cast-qual +.endif Added: vendor/NetBSD/libedit/dist/TEST/rl1.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/NetBSD/libedit/dist/TEST/rl1.c Tue Sep 25 10:41:30 2012 (r240915) @@ -0,0 +1,59 @@ +/* $NetBSD: rl1.c,v 1.1 2010/09/16 20:08:51 christos Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#if !defined(lint) +__RCSID("$NetBSD: rl1.c,v 1.1 2010/09/16 20:08:51 christos Exp $"); +#endif /* not lint */ + +/* + * test.c: A little test program + */ +#include +#include + +int +main(int argc, char *argv[]) +{ + char *p; + while ((p = readline("hi$")) != NULL) { + add_history(p); + printf("%d %s\n", history_length, p); + } + return 0; +} Modified: vendor/NetBSD/libedit/dist/TEST/wtc1.c ============================================================================== --- vendor/NetBSD/libedit/dist/TEST/wtc1.c Tue Sep 25 05:56:59 2012 (r240914) +++ vendor/NetBSD/libedit/dist/TEST/wtc1.c Tue Sep 25 10:41:30 2012 (r240915) @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -14,6 +15,7 @@ static int continuation; volatile sig_atomic_t gotsig; +static const char hfile[] = ".whistory"; static wchar_t * prompt(EditLine *el) @@ -60,7 +62,8 @@ complete(EditLine *el, int ch) char *buf, *bptr; const LineInfoW *lf = el_wline(el); int len, mblen, i; - unsigned char res; + unsigned char res = 0; + wchar_t dir[1024]; /* Find the last word */ for (ptr = lf->cursor -1; !iswspace(*ptr) && ptr > lf->buffer; --ptr) @@ -70,7 +73,9 @@ complete(EditLine *el, int ch) /* Convert last word to multibyte encoding, so we can compare to it */ wctomb(NULL, 0); /* Reset shift state */ mblen = MB_LEN_MAX * len + 1; - buf = bptr =(char *)malloc(mblen); + buf = bptr = malloc(mblen); + if (buf == NULL) + err(1, "malloc"); for (i = 0; i < len; ++i) { /* Note: really should test for -1 return from wctomb */ bptr += wctomb(bptr, ptr[i]); @@ -83,7 +88,9 @@ complete(EditLine *el, int ch) if (mblen > strlen(dp->d_name)) continue; if (strncmp(dp->d_name, buf, mblen) == 0) { - if (el_insertstr(el, &dp->d_name[mblen]) == -1) + mbstowcs(dir, &dp->d_name[mblen], + sizeof(dir) / sizeof(*dir)); + if (el_winsertstr(el, dir) == -1) res = CC_ERROR; else res = CC_REFRESH; @@ -119,6 +126,7 @@ main(int argc, char *argv[]) hist = history_winit(); /* Init built-in history */ history_w(hist, &ev, H_SETSIZE, 100); /* Remember 100 events */ + history_w(hist, &ev, H_LOAD, hfile); tok = tok_winit(NULL); /* Init the tokenizer */ @@ -260,6 +268,7 @@ main(int argc, char *argv[]) el_end(el); tok_wend(tok); + history_w(hist, &ev, H_SAVE, hfile); history_wend(hist); fprintf(stdout, "\n"); Modified: vendor/NetBSD/libedit/dist/chared.c ============================================================================== --- vendor/NetBSD/libedit/dist/chared.c Tue Sep 25 05:56:59 2012 (r240914) +++ vendor/NetBSD/libedit/dist/chared.c Tue Sep 25 10:41:30 2012 (r240915) @@ -1,4 +1,4 @@ -/* $NetBSD: chared.c,v 1.28 2009/12/30 22:37:40 christos Exp $ */ +/* $NetBSD: chared.c,v 1.37 2012/07/18 17:12:39 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: chared.c,v 1.28 2009/12/30 22:37:40 christos Exp $"); +__RCSID("$NetBSD: chared.c,v 1.37 2012/07/18 17:12:39 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -63,8 +63,8 @@ cv_undo(EditLine *el) size_t size; /* Save entire line for undo */ - size = el->el_line.lastchar - el->el_line.buffer; - vu->len = size; + size = (size_t)(el->el_line.lastchar - el->el_line.buffer); + vu->len = (ssize_t)size; vu->cursor = (int)(el->el_line.cursor - el->el_line.buffer); (void)memcpy(vu->buf, el->el_line.buffer, size * sizeof(*vu->buf)); @@ -84,7 +84,7 @@ cv_yank(EditLine *el, const Char *ptr, i { c_kill_t *k = &el->el_chared.c_kill; - (void)memcpy(k->buf, ptr, size * sizeof(*k->buf)); + (void)memcpy(k->buf, ptr, (size_t)size * sizeof(*k->buf)); k->last = k->buf + size; } @@ -201,7 +201,7 @@ c_delbefore1(EditLine *el) protected int ce__isword(Int p) { - return (Isalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL); + return Isalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL; } @@ -225,7 +225,7 @@ cv__isword(Int p) protected int cv__isWord(Int p) { - return (!Isspace(p)); + return !Isspace(p); } @@ -249,7 +249,7 @@ c__prev_word(Char *p, Char *low, int n, if (p < low) p = low; /* cp now points where we want it */ - return (p); + return p; } @@ -268,7 +268,7 @@ c__next_word(Char *p, Char *high, int n, if (p > high) p = high; /* p now points where we want it */ - return (p); + return p; } /* cv_next_word(): @@ -294,9 +294,9 @@ cv_next_word(EditLine *el, Char *p, Char /* p now points where we want it */ if (p > high) - return (high); + return high; else - return (p); + return p; } @@ -320,47 +320,12 @@ cv_prev_word(Char *p, Char *low, int n, /* p now points where we want it */ if (p < low) - return (low); + return low; else - return (p); + return p; } -#ifdef notdef -/* c__number(): - * Ignore character p points to, return number appearing after that. - * A '$' by itself means a big number; "$-" is for negative; '^' means 1. - * Return p pointing to last char used. - */ -protected Char * -c__number( - Char *p, /* character position */ - int *num, /* Return value */ - int dval) /* dval is the number to subtract from like $-3 */ -{ - int i; - int sign = 1; - - if (*++p == '^') { - *num = 1; - return (p); - } - if (*p == '$') { - if (*++p != '-') { - *num = 0x7fffffff; /* Handle $ */ - return (--p); - } - sign = -1; /* Handle $- */ - ++p; - } - /* XXX: this assumes ASCII compatible digits */ - for (i = 0; Isdigit(*p); i = 10 * i + *p++ - '0') - continue; - *num = (sign < 0 ? dval - i : i); - return (--p); -} -#endif - /* cv_delfini(): * Finish vi delete action */ @@ -399,28 +364,6 @@ cv_delfini(EditLine *el) } -#ifdef notdef -/* ce__endword(): - * Go to the end of this word according to emacs - */ -protected Char * -ce__endword(Char *p, Char *high, int n) -{ - p++; - - while (n--) { - while ((p < high) && Isspace(*p)) - p++; - while ((p < high) && !Isspace(*p)) - p++; - } - - p--; - return (p); -} -#endif - - /* cv__endword(): * Go to the end of this word according to vi */ @@ -440,7 +383,7 @@ cv__endword(Char *p, Char *high, int n, p++; } p--; - return (p); + return p; } /* ch_init(): @@ -454,7 +397,7 @@ ch_init(EditLine *el) el->el_line.buffer = el_malloc(EL_BUFSIZ * sizeof(*el->el_line.buffer)); if (el->el_line.buffer == NULL) - return (-1); + return -1; (void) memset(el->el_line.buffer, 0, EL_BUFSIZ * sizeof(*el->el_line.buffer)); @@ -465,7 +408,7 @@ ch_init(EditLine *el) el->el_chared.c_undo.buf = el_malloc(EL_BUFSIZ * sizeof(*el->el_chared.c_undo.buf)); if (el->el_chared.c_undo.buf == NULL) - return (-1); + return -1; (void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ * sizeof(*el->el_chared.c_undo.buf)); el->el_chared.c_undo.len = -1; @@ -473,7 +416,7 @@ ch_init(EditLine *el) el->el_chared.c_redo.buf = el_malloc(EL_BUFSIZ * sizeof(*el->el_chared.c_redo.buf)); if (el->el_chared.c_redo.buf == NULL) - return (-1); + return -1; el->el_chared.c_redo.pos = el->el_chared.c_redo.buf; el->el_chared.c_redo.lim = el->el_chared.c_redo.buf + EL_BUFSIZ; el->el_chared.c_redo.cmd = ED_UNASSIGNED; @@ -484,11 +427,13 @@ ch_init(EditLine *el) el->el_chared.c_kill.buf = el_malloc(EL_BUFSIZ * sizeof(*el->el_chared.c_kill.buf)); if (el->el_chared.c_kill.buf == NULL) - return (-1); + return -1; (void) memset(el->el_chared.c_kill.buf, 0, EL_BUFSIZ * sizeof(*el->el_chared.c_kill.buf)); el->el_chared.c_kill.mark = el->el_line.buffer; el->el_chared.c_kill.last = el->el_chared.c_kill.buf; + el->el_chared.c_resizefun = NULL; + el->el_chared.c_resizearg = NULL; el->el_map.current = el->el_map.key; @@ -502,8 +447,8 @@ ch_init(EditLine *el) ma->offset = 0; ma->macro = el_malloc(EL_MAXMACRO * sizeof(*ma->macro)); if (ma->macro == NULL) - return (-1); - return (0); + return -1; + return 0; } /* ch_reset(): @@ -542,7 +487,7 @@ ch__clearmacro(EditLine *el) { c_macro_t *ma = &el->el_chared.c_macro; while (ma->level >= 0) - el_free((ptr_t)ma->macro[ma->level--]); + el_free(ma->macro[ma->level--]); } /* ch_enlargebufs(): @@ -555,7 +500,7 @@ ch_enlargebufs(EditLine *el, size_t addl size_t sz, newsz; Char *newbuffer, *oldbuf, *oldkbuf; - sz = el->el_line.limit - el->el_line.buffer + EL_LEAVE; + sz = (size_t)(el->el_line.limit - el->el_line.buffer + EL_LEAVE); newsz = sz * 2; /* * If newly required length is longer than current buffer, we need @@ -587,7 +532,8 @@ ch_enlargebufs(EditLine *el, size_t addl /* * Reallocate kill buffer. */ - newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz * sizeof(*newbuffer)); + newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz * + sizeof(*newbuffer)); if (!newbuffer) return 0; @@ -629,6 +575,8 @@ ch_enlargebufs(EditLine *el, size_t addl /* Safe to set enlarged buffer size */ el->el_line.limit = &el->el_line.buffer[newsz - EL_LEAVE]; + if (el->el_chared.c_resizefun) + (*el->el_chared.c_resizefun)(el, el->el_chared.c_resizearg); return 1; } @@ -638,20 +586,20 @@ ch_enlargebufs(EditLine *el, size_t addl protected void ch_end(EditLine *el) { - el_free((ptr_t) el->el_line.buffer); + el_free(el->el_line.buffer); el->el_line.buffer = NULL; el->el_line.limit = NULL; - el_free((ptr_t) el->el_chared.c_undo.buf); + el_free(el->el_chared.c_undo.buf); el->el_chared.c_undo.buf = NULL; - el_free((ptr_t) el->el_chared.c_redo.buf); + el_free(el->el_chared.c_redo.buf); el->el_chared.c_redo.buf = NULL; el->el_chared.c_redo.pos = NULL; el->el_chared.c_redo.lim = NULL; el->el_chared.c_redo.cmd = ED_UNASSIGNED; - el_free((ptr_t) el->el_chared.c_kill.buf); + el_free(el->el_chared.c_kill.buf); el->el_chared.c_kill.buf = NULL; ch_reset(el, 1); - el_free((ptr_t) el->el_chared.c_macro.macro); + el_free(el->el_chared.c_macro.macro); el->el_chared.c_macro.macro = NULL; } @@ -664,17 +612,17 @@ FUN(el,insertstr)(EditLine *el, const Ch { size_t len; - if ((len = Strlen(s)) == 0) - return (-1); + if (s == NULL || (len = Strlen(s)) == 0) + return -1; if (el->el_line.lastchar + len >= el->el_line.limit) { if (!ch_enlargebufs(el, len)) - return (-1); + return -1; } c_insert(el, (int)len); while (*s) *el->el_line.cursor++ = *s++; - return (0); + return 0; } @@ -707,8 +655,8 @@ c_gets(EditLine *el, Char *buf, const Ch Char *cp = el->el_line.buffer; if (prompt) { - len = Strlen(prompt); - (void)memcpy(cp, prompt, len * sizeof(*cp)); + len = (ssize_t)Strlen(prompt); + (void)memcpy(cp, prompt, (size_t)len * sizeof(*cp)); cp += len; } len = 0; @@ -743,8 +691,8 @@ c_gets(EditLine *el, Char *buf, const Ch break; default: - if (len >= EL_BUFSIZ - 16) - term_beep(el); + if (len >= (ssize_t)(EL_BUFSIZ - 16)) + terminal_beep(el); else { buf[len++] = ch; *cp++ = ch; @@ -773,7 +721,7 @@ c_hpos(EditLine *el) * Find how many characters till the beginning of this line. */ if (el->el_line.cursor == el->el_line.buffer) - return (0); + return 0; else { for (ptr = el->el_line.cursor - 1; ptr >= el->el_line.buffer && *ptr != '\n'; @@ -782,3 +730,11 @@ c_hpos(EditLine *el) return (int)(el->el_line.cursor - ptr - 1); } } + +protected int +ch_resizefun(EditLine *el, el_zfunc_t f, void *a) +{ + el->el_chared.c_resizefun = f; + el->el_chared.c_resizearg = a; + return 0; +} Modified: vendor/NetBSD/libedit/dist/chared.h ============================================================================== --- vendor/NetBSD/libedit/dist/chared.h Tue Sep 25 05:56:59 2012 (r240914) +++ vendor/NetBSD/libedit/dist/chared.h Tue Sep 25 10:41:30 2012 (r240915) @@ -1,4 +1,4 @@ -/* $NetBSD: chared.h,v 1.20 2010/04/15 00:57:33 christos Exp $ */ +/* $NetBSD: chared.h,v 1.21 2010/08/28 15:44:59 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -103,6 +103,8 @@ typedef struct c_kill_t { Char *mark; } c_kill_t; +typedef void (*el_zfunc_t)(EditLine *, void *); + /* * Note that we use both data structures because the user can bind * commands from both editors! @@ -113,6 +115,8 @@ typedef struct el_chared_t { c_redo_t c_redo; c_vcmd_t c_vcmd; c_macro_t c_macro; + el_zfunc_t c_resizefun; + void * c_resizearg; } el_chared_t; @@ -160,6 +164,7 @@ protected int c_hpos(EditLine *); protected int ch_init(EditLine *); protected void ch_reset(EditLine *, int); +protected int ch_resizefun(EditLine *, el_zfunc_t, void *); protected int ch_enlargebufs(EditLine *, size_t); protected void ch_end(EditLine *); Modified: vendor/NetBSD/libedit/dist/chartype.c ============================================================================== --- vendor/NetBSD/libedit/dist/chartype.c Tue Sep 25 05:56:59 2012 (r240914) +++ vendor/NetBSD/libedit/dist/chartype.c Tue Sep 25 10:41:30 2012 (r240915) @@ -1,4 +1,4 @@ -/* $NetBSD: chartype.c,v 1.4 2010/04/15 00:55:57 christos Exp $ */ +/* $NetBSD: chartype.c,v 1.10 2011/08/16 16:25:15 christos Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -38,12 +38,12 @@ */ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: chartype.c,v 1.4 2010/04/15 00:55:57 christos Exp $"); +__RCSID("$NetBSD: chartype.c,v 1.10 2011/08/16 16:25:15 christos Exp $"); #endif /* not lint && not SCCSID */ #include "el.h" #include -#define CT_BUFSIZ 1024 +#define CT_BUFSIZ ((size_t)1024) #ifdef WIDECHAR protected void @@ -52,7 +52,7 @@ ct_conv_buff_resize(ct_buffer_t *conv, s void *p; if (mincsize > conv->csize) { conv->csize = mincsize; - p = el_realloc(conv->cbuff, conv->csize); + p = el_realloc(conv->cbuff, conv->csize * sizeof(*conv->cbuff)); if (p == NULL) { conv->csize = 0; el_free(conv->cbuff); @@ -63,7 +63,7 @@ ct_conv_buff_resize(ct_buffer_t *conv, s if (minwsize > conv->wsize) { conv->wsize = minwsize; - p = el_realloc(conv->wbuff, conv->wsize); + p = el_realloc(conv->wbuff, conv->wsize * sizeof(*conv->wbuff)); if (p == NULL) { conv->wsize = 0; el_free(conv->wbuff); @@ -83,33 +83,27 @@ ct_encode_string(const Char *s, ct_buffe if (!s) return NULL; if (!conv->cbuff) - ct_conv_buff_resize(conv, CT_BUFSIZ, 0); + ct_conv_buff_resize(conv, CT_BUFSIZ, (size_t)0); if (!conv->cbuff) return NULL; dst = conv->cbuff; while (*s) { - used = ct_encode_char(dst, (int)(conv->csize - - (dst - conv->cbuff)), *s); - if (used == -1) { /* failed to encode, need more buffer space */ + used = (ssize_t)(conv->csize - (size_t)(dst - conv->cbuff)); + if (used < 5) { used = dst - conv->cbuff; - ct_conv_buff_resize(conv, conv->csize + CT_BUFSIZ, 0); + ct_conv_buff_resize(conv, conv->csize + CT_BUFSIZ, + (size_t)0); if (!conv->cbuff) return NULL; dst = conv->cbuff + used; - /* don't increment s here - we want to retry it! */ } - else - ++s; + used = ct_encode_char(dst, (size_t)5, *s); + if (used == -1) /* failed to encode, need more buffer space */ + abort(); + ++s; dst += used; } - if (dst >= (conv->cbuff + conv->csize)) { - used = dst - conv->cbuff; - ct_conv_buff_resize(conv, conv->csize + 1, 0); - if (!conv->cbuff) - return NULL; - dst = conv->cbuff + used; - } *dst = '\0'; return conv->cbuff; } @@ -122,13 +116,15 @@ ct_decode_string(const char *s, ct_buffe if (!s) return NULL; if (!conv->wbuff) - ct_conv_buff_resize(conv, 0, CT_BUFSIZ); + ct_conv_buff_resize(conv, (size_t)0, CT_BUFSIZ); if (!conv->wbuff) return NULL; - len = ct_mbstowcs(0, s, 0); + len = ct_mbstowcs(NULL, s, (size_t)0); + if (len == (size_t)-1) + return NULL; if (len > conv->wsize) - ct_conv_buff_resize(conv, 0, len + 1); + ct_conv_buff_resize(conv, (size_t)0, len + 1); if (!conv->wbuff) return NULL; ct_mbstowcs(conv->wbuff, s, conv->wsize); @@ -149,11 +145,11 @@ ct_decode_argv(int argc, const char *arg * the argv strings. */ for (i = 0, bufspace = 0; i < argc; ++i) bufspace += argv[i] ? strlen(argv[i]) + 1 : 0; - ct_conv_buff_resize(conv, 0, bufspace); + ct_conv_buff_resize(conv, (size_t)0, bufspace); if (!conv->wsize) return NULL; - wargv = el_malloc(argc * sizeof(*wargv)); + wargv = el_malloc((size_t)argc * sizeof(*wargv)); for (i = 0, p = conv->wbuff; i < argc; ++i) { if (!argv[i]) { /* don't pass null pointers to mbstowcs */ @@ -161,14 +157,14 @@ ct_decode_argv(int argc, const char *arg continue; } else { wargv[i] = p; - bytes = mbstowcs(p, argv[i], bufspace); + bytes = (ssize_t)mbstowcs(p, argv[i], bufspace); } if (bytes == -1) { el_free(wargv); return NULL; } else bytes++; /* include '\0' in the count */ - bufspace -= bytes; + bufspace -= (size_t)bytes; p += bytes; } @@ -225,7 +221,7 @@ ct_visual_string(const Char *s) } dst = buff; while (*s) { - used = ct_visual_char(dst, buffsize - (dst - buff), *s); + used = ct_visual_char(dst, buffsize - (size_t)(dst - buff), *s); if (used == -1) { /* failed to encode, need more buffer space */ used = dst - buff; buffsize += CT_BUFSIZ; @@ -326,7 +322,7 @@ ct_visual_char(Char *dst, size_t len, Ch *dst++ = tohexdigit(((unsigned int) c >> 8) & 0xf); *dst++ = tohexdigit(((unsigned int) c >> 4) & 0xf); *dst = tohexdigit(((unsigned int) c ) & 0xf); - return (c > 0xffff) ? 8 : 7; + return c > 0xffff ? 8 : 7; #else *dst++ = '\\'; #define tooctaldigit(v) ((v) + '0') Modified: vendor/NetBSD/libedit/dist/chartype.h ============================================================================== --- vendor/NetBSD/libedit/dist/chartype.h Tue Sep 25 05:56:59 2012 (r240914) +++ vendor/NetBSD/libedit/dist/chartype.h Tue Sep 25 10:41:30 2012 (r240915) @@ -1,4 +1,4 @@ -/* $NetBSD: chartype.h,v 1.6 2010/04/20 02:01:13 christos Exp $ */ +/* $NetBSD: chartype.h,v 1.10 2011/11/16 01:45:10 christos Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ #endif #define ct_mbtowc mbtowc -#define ct_mbtowc_reset mbtowc(0,0,0) +#define ct_mbtowc_reset mbtowc(0,0,(size_t)0) #define ct_wctomb wctomb #define ct_wctomb_reset wctomb(0,0) #define ct_wcstombs wcstombs @@ -105,7 +105,12 @@ #define Strtol(p,e,b) wcstol(p,e,b) -#define Width(c) wcwidth(c) +static inline int +Width(wchar_t c) +{ + int w = wcwidth(c); + return w < 0 ? 0 : w; +} #else /* NARROW */ @@ -172,11 +177,11 @@ typedef struct ct_buffer_t { } ct_buffer_t; #define ct_encode_string __ct_encode_string -/* Encode a wide character string and return the UTF-8 encoded result. */ +/* Encode a wide-character string and return the UTF-8 encoded result. */ public char *ct_encode_string(const Char *, ct_buffer_t *); #define ct_decode_string __ct_decode_string -/* Decode a (multi)?byte string and return the wide character string result. */ +/* Decode a (multi)?byte string and return the wide-character string result. */ public Char *ct_decode_string(const char *, ct_buffer_t *); /* Decode a (multi)?byte argv string array. @@ -206,7 +211,7 @@ protected size_t ct_enc_width(Char); /* The maximum buffer size to hold the most unwieldly visual representation, * in this case \U+nnnnn. */ -#define VISUAL_WIDTH_MAX 8 +#define VISUAL_WIDTH_MAX ((size_t)8) /* The terminal is thought of in terms of X columns by Y lines. In the cases * where a wide character takes up more than one column, the adjacent Modified: vendor/NetBSD/libedit/dist/common.c ============================================================================== --- vendor/NetBSD/libedit/dist/common.c Tue Sep 25 05:56:59 2012 (r240914) +++ vendor/NetBSD/libedit/dist/common.c Tue Sep 25 10:41:30 2012 (r240915) @@ -1,4 +1,4 @@ -/* $NetBSD: common.c,v 1.24 2009/12/30 22:37:40 christos Exp $ */ +/* $NetBSD: common.c,v 1.29 2012/03/24 20:08:43 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: common.c,v 1.24 2009/12/30 22:37:40 christos Exp $"); +__RCSID("$NetBSD: common.c,v 1.29 2012/03/24 20:08:43 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -57,7 +57,7 @@ ed_end_of_file(EditLine *el, Int c __att re_goto_bottom(el); *el->el_line.lastchar = '\0'; - return (CC_EOF); + return CC_EOF; } @@ -71,7 +71,7 @@ ed_insert(EditLine *el, Int c) int count = el->el_state.argument; if (c == '\0') - return (CC_ERROR); + return CC_ERROR; if (el->el_line.lastchar + el->el_state.argument >= el->el_line.limit) { @@ -99,7 +99,7 @@ ed_insert(EditLine *el, Int c) if (el->el_state.inputmode == MODE_REPLACE_1) return vi_command_mode(el, 0); - return (CC_NORM); + return CC_NORM; } @@ -114,7 +114,7 @@ ed_delete_prev_word(EditLine *el, Int c Char *cp, *p, *kp; if (el->el_line.cursor == el->el_line.buffer) - return (CC_ERROR); + return CC_ERROR; cp = c__prev_word(el->el_line.cursor, el->el_line.buffer, el->el_state.argument, ce__isword); @@ -127,7 +127,7 @@ ed_delete_prev_word(EditLine *el, Int c el->el_line.cursor = cp; if (el->el_line.cursor < el->el_line.buffer) el->el_line.cursor = el->el_line.buffer; /* bounds check */ - return (CC_REFRESH); + return CC_REFRESH; } @@ -137,9 +137,9 @@ ed_delete_prev_word(EditLine *el, Int c */ protected el_action_t /*ARGSUSED*/ -ed_delete_next_char(EditLine *el, Int c) +ed_delete_next_char(EditLine *el, Int c __attribute__((__unused__))) { -#ifdef notdef /* XXX */ +#ifdef DEBUG_EDIT #define EL el->el_line (void) fprintf(el->el_errlfile, "\nD(b: %x(%s) c: %x(%s) last: %x(%s) limit: %x(%s)\n", @@ -152,32 +152,29 @@ ed_delete_next_char(EditLine *el, Int c) if (el->el_line.cursor == el->el_line.buffer) { /* if I'm also at the beginning */ #ifdef KSHVI - return (CC_ERROR); + return CC_ERROR; #else /* then do an EOF */ - term_writec(el, c); - return (CC_EOF); + terminal_writec(el, c); + return CC_EOF; #endif } else { #ifdef KSHVI el->el_line.cursor--; #else - return (CC_ERROR); + return CC_ERROR; #endif } - } else { - if (el->el_line.cursor != el->el_line.buffer) - el->el_line.cursor--; - else - return (CC_ERROR); - } + } else + return CC_ERROR; } c_delafter(el, el->el_state.argument); /* delete after dot */ - if (el->el_line.cursor >= el->el_line.lastchar && + if (el->el_map.type == MAP_VI && + el->el_line.cursor >= el->el_line.lastchar && el->el_line.cursor > el->el_line.buffer) /* bounds check */ el->el_line.cursor = el->el_line.lastchar - 1; - return (CC_REFRESH); + return CC_REFRESH; } @@ -198,7 +195,7 @@ ed_kill_line(EditLine *el, Int c __attri el->el_chared.c_kill.last = kp; /* zap! -- delete to end */ el->el_line.lastchar = el->el_line.cursor; - return (CC_REFRESH); + return CC_REFRESH; } @@ -215,13 +212,13 @@ ed_move_to_end(EditLine *el, Int c __att if (el->el_map.type == MAP_VI) { if (el->el_chared.c_vcmd.action != NOP) { cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } #ifdef VI_MOVE el->el_line.cursor--; #endif } - return (CC_CURSOR); + return CC_CURSOR; } @@ -242,10 +239,10 @@ ed_move_to_beg(EditLine *el, Int c __att el->el_line.cursor++; if (el->el_chared.c_vcmd.action != NOP) { cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } } - return (CC_CURSOR); + return CC_CURSOR; } @@ -259,7 +256,7 @@ ed_transpose_chars(EditLine *el, Int c) if (el->el_line.cursor < el->el_line.lastchar) { if (el->el_line.lastchar <= &el->el_line.buffer[1]) - return (CC_ERROR); + return CC_ERROR; else el->el_line.cursor++; } @@ -268,9 +265,9 @@ ed_transpose_chars(EditLine *el, Int c) c = el->el_line.cursor[-2]; el->el_line.cursor[-2] = el->el_line.cursor[-1]; el->el_line.cursor[-1] = c; - return (CC_REFRESH); + return CC_REFRESH; } else - return (CC_ERROR); + return CC_ERROR; } @@ -288,7 +285,7 @@ ed_next_char(EditLine *el, Int c __attri (el->el_line.cursor == lim - 1 && el->el_map.type == MAP_VI && el->el_chared.c_vcmd.action == NOP)) - return (CC_ERROR); + return CC_ERROR; el->el_line.cursor += el->el_state.argument; if (el->el_line.cursor > lim) @@ -297,9 +294,9 @@ ed_next_char(EditLine *el, Int c __attri if (el->el_map.type == MAP_VI) if (el->el_chared.c_vcmd.action != NOP) { cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } - return (CC_CURSOR); + return CC_CURSOR; } @@ -313,7 +310,7 @@ ed_prev_word(EditLine *el, Int c __attri { if (el->el_line.cursor == el->el_line.buffer) - return (CC_ERROR); + return CC_ERROR; el->el_line.cursor = c__prev_word(el->el_line.cursor, el->el_line.buffer, @@ -323,9 +320,9 @@ ed_prev_word(EditLine *el, Int c __attri if (el->el_map.type == MAP_VI) if (el->el_chared.c_vcmd.action != NOP) { cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } - return (CC_CURSOR); + return CC_CURSOR; } @@ -346,11 +343,11 @@ ed_prev_char(EditLine *el, Int c __attri if (el->el_map.type == MAP_VI) if (el->el_chared.c_vcmd.action != NOP) { cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } - return (CC_CURSOR); + return CC_CURSOR; } else - return (CC_ERROR); + return CC_ERROR; } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-vendor@FreeBSD.ORG Tue Sep 25 10:42:14 2012 Return-Path: Delivered-To: svn-src-vendor@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 385B31065673; Tue, 25 Sep 2012 10:42:14 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0B0408FC16; Tue, 25 Sep 2012 10:42:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q8PAgD9N015097; Tue, 25 Sep 2012 10:42:13 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q8PAgDdB015096; Tue, 25 Sep 2012 10:42:13 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201209251042.q8PAgDdB015096@svn.freebsd.org> From: Ed Schouten Date: Tue, 25 Sep 2012 10:42:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r240916 - vendor/NetBSD/libedit/2012-09-25 X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Sep 2012 10:42:14 -0000 Author: ed Date: Tue Sep 25 10:42:13 2012 New Revision: 240916 URL: http://svn.freebsd.org/changeset/base/240916 Log: "Tag" the "2012/09/25 10:41:11 UTC" import. Added: vendor/NetBSD/libedit/2012-09-25/ - copied from r240915, vendor/NetBSD/libedit/dist/ From owner-svn-src-vendor@FreeBSD.ORG Wed Sep 26 08:57:13 2012 Return-Path: Delivered-To: svn-src-vendor@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A8F90106564A; Wed, 26 Sep 2012 08:57:13 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 91A2B8FC14; Wed, 26 Sep 2012 08:57:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q8Q8vDuP094859; Wed, 26 Sep 2012 08:57:13 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q8Q8vDUj094854; Wed, 26 Sep 2012 08:57:13 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201209260857.q8Q8vDUj094854@svn.freebsd.org> From: Martin Matuska Date: Wed, 26 Sep 2012 08:57:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor-sys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r240949 - vendor-sys/illumos/dist/uts/common/fs/zfs vendor-sys/illumos/dist/uts/common/fs/zfs/sys vendor/illumos/dist/cmd/zfs vendor/illumos/dist/man/man1m X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Sep 2012 08:57:13 -0000 Author: mm Date: Wed Sep 26 08:57:12 2012 New Revision: 240949 URL: http://svn.freebsd.org/changeset/base/240949 Log: Update vendor/illumos/dist and vendor-sys/illumos/dist to illumos-gate 13836:37bf491c434c (illumos ZFS issues #2678, #2811, #3139, #3189, #3208) Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_tx.c vendor-sys/illumos/dist/uts/common/fs/zfs/sys/sa_impl.h vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_vfsops.c vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_znode.c Changes in other areas also in this revision: Modified: vendor/illumos/dist/cmd/zfs/zfs_main.c vendor/illumos/dist/man/man1m/zfs.1m Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_tx.c ============================================================================== --- vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_tx.c Wed Sep 26 07:09:15 2012 (r240948) +++ vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_tx.c Wed Sep 26 08:57:12 2012 (r240949) @@ -572,7 +572,7 @@ dmu_tx_count_free(dmu_tx_hold_t *txh, ui (dn->dn_indblkshift - SPA_BLKPTRSHIFT); while (level++ < maxlevel) { - txh->txh_memory_tohold += MIN(blkcnt, (nl1blks >> epbs)) + txh->txh_memory_tohold += MAX(MIN(blkcnt, nl1blks), 1) << dn->dn_indblkshift; blkcnt = 1 + (blkcnt >> epbs); } Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/sys/sa_impl.h ============================================================================== --- vendor-sys/illumos/dist/uts/common/fs/zfs/sys/sa_impl.h Wed Sep 26 07:09:15 2012 (r240948) +++ vendor-sys/illumos/dist/uts/common/fs/zfs/sys/sa_impl.h Wed Sep 26 08:57:12 2012 (r240949) @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. */ #ifndef _SYS_SA_IMPL_H @@ -181,7 +182,7 @@ typedef struct sa_hdr_phys { */ #define SA_HDR_LAYOUT_NUM(hdr) BF32_GET(hdr->sa_layout_info, 0, 10) -#define SA_HDR_SIZE(hdr) BF32_GET_SB(hdr->sa_layout_info, 10, 16, 3, 0) +#define SA_HDR_SIZE(hdr) BF32_GET_SB(hdr->sa_layout_info, 10, 6, 3, 0) #define SA_HDR_LAYOUT_INFO_ENCODE(x, num, size) \ { \ BF32_SET_SB(x, 10, 6, 3, 0, size); \ Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_vfsops.c ============================================================================== --- vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_vfsops.c Wed Sep 26 07:09:15 2012 (r240948) +++ vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_vfsops.c Wed Sep 26 08:57:12 2012 (r240949) @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -63,7 +64,6 @@ #include #include #include -#include #include "zfs_comutil.h" int zfsfstype; @@ -577,7 +577,6 @@ static int zfs_space_delta_cb(dmu_object_type_t bonustype, void *data, uint64_t *userp, uint64_t *groupp) { - znode_phys_t *znp = data; int error = 0; /* @@ -596,20 +595,18 @@ zfs_space_delta_cb(dmu_object_type_t bon return (EEXIST); if (bonustype == DMU_OT_ZNODE) { + znode_phys_t *znp = data; *userp = znp->zp_uid; *groupp = znp->zp_gid; } else { int hdrsize; + sa_hdr_phys_t *sap = data; + sa_hdr_phys_t sa = *sap; + boolean_t swap = B_FALSE; ASSERT(bonustype == DMU_OT_SA); - hdrsize = sa_hdrsize(data); - if (hdrsize != 0) { - *userp = *((uint64_t *)((uintptr_t)data + hdrsize + - SA_UID_OFFSET)); - *groupp = *((uint64_t *)((uintptr_t)data + hdrsize + - SA_GID_OFFSET)); - } else { + if (sa.sa_magic == 0) { /* * This should only happen for newly created * files that haven't had the znode data filled @@ -617,6 +614,25 @@ zfs_space_delta_cb(dmu_object_type_t bon */ *userp = 0; *groupp = 0; + return (0); + } + if (sa.sa_magic == BSWAP_32(SA_MAGIC)) { + sa.sa_magic = SA_MAGIC; + sa.sa_layout_info = BSWAP_16(sa.sa_layout_info); + swap = B_TRUE; + } else { + VERIFY3U(sa.sa_magic, ==, SA_MAGIC); + } + + hdrsize = sa_hdrsize(&sa); + VERIFY3U(hdrsize, >=, sizeof (sa_hdr_phys_t)); + *userp = *((uint64_t *)((uintptr_t)data + hdrsize + + SA_UID_OFFSET)); + *groupp = *((uint64_t *)((uintptr_t)data + hdrsize + + SA_GID_OFFSET)); + if (swap) { + *userp = BSWAP_64(*userp); + *groupp = BSWAP_64(*groupp); } } return (error); Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_znode.c ============================================================================== --- vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_znode.c Wed Sep 26 07:09:15 2012 (r240948) +++ vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_znode.c Wed Sep 26 08:57:12 2012 (r240949) @@ -1947,13 +1947,16 @@ zfs_release_sa_handle(sa_handle_t *hdl, * or not the object is an extended attribute directory. */ static int -zfs_obj_to_pobj(sa_handle_t *hdl, sa_attr_type_t *sa_table, uint64_t *pobjp, - int *is_xattrdir) +zfs_obj_to_pobj(objset_t *osp, sa_handle_t *hdl, sa_attr_type_t *sa_table, + uint64_t *pobjp, int *is_xattrdir) { uint64_t parent; uint64_t pflags; uint64_t mode; + uint64_t parent_mode; sa_bulk_attr_t bulk[3]; + sa_handle_t *sa_hdl; + dmu_buf_t *sa_db; int count = 0; int error; @@ -1967,9 +1970,32 @@ zfs_obj_to_pobj(sa_handle_t *hdl, sa_att if ((error = sa_bulk_lookup(hdl, bulk, count)) != 0) return (error); - *pobjp = parent; + /* + * When a link is removed its parent pointer is not changed and will + * be invalid. There are two cases where a link is removed but the + * file stays around, when it goes to the delete queue and when there + * are additional links. + */ + error = zfs_grab_sa_handle(osp, parent, &sa_hdl, &sa_db, FTAG); + if (error != 0) + return (error); + + error = sa_lookup(sa_hdl, ZPL_MODE, &parent_mode, sizeof (parent_mode)); + zfs_release_sa_handle(sa_hdl, sa_db, FTAG); + if (error != 0) + return (error); + *is_xattrdir = ((pflags & ZFS_XATTR) != 0) && S_ISDIR(mode); + /* + * Extended attributes can be applied to files, directories, etc. + * Otherwise the parent must be a directory. + */ + if (!*is_xattrdir && !S_ISDIR(parent_mode)) + return (EINVAL); + + *pobjp = parent; + return (0); } @@ -2018,7 +2044,7 @@ zfs_obj_to_path_impl(objset_t *osp, uint if (prevdb) zfs_release_sa_handle(prevhdl, prevdb, FTAG); - if ((error = zfs_obj_to_pobj(sa_hdl, sa_table, &pobj, + if ((error = zfs_obj_to_pobj(osp, sa_hdl, sa_table, &pobj, &is_xattrdir)) != 0) break; From owner-svn-src-vendor@FreeBSD.ORG Wed Sep 26 08:57:14 2012 Return-Path: Delivered-To: svn-src-vendor@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E763B106566B; Wed, 26 Sep 2012 08:57:13 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C92A48FC15; Wed, 26 Sep 2012 08:57:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q8Q8vDmx094866; Wed, 26 Sep 2012 08:57:13 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q8Q8vDUW094863; Wed, 26 Sep 2012 08:57:13 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201209260857.q8Q8vDUW094863@svn.freebsd.org> From: Martin Matuska Date: Wed, 26 Sep 2012 08:57:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r240949 - vendor-sys/illumos/dist/uts/common/fs/zfs vendor-sys/illumos/dist/uts/common/fs/zfs/sys vendor/illumos/dist/cmd/zfs vendor/illumos/dist/man/man1m X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Sep 2012 08:57:14 -0000 Author: mm Date: Wed Sep 26 08:57:12 2012 New Revision: 240949 URL: http://svn.freebsd.org/changeset/base/240949 Log: Update vendor/illumos/dist and vendor-sys/illumos/dist to illumos-gate 13836:37bf491c434c (illumos ZFS issues #2678, #2811, #3139, #3189, #3208) Modified: vendor/illumos/dist/cmd/zfs/zfs_main.c vendor/illumos/dist/man/man1m/zfs.1m Changes in other areas also in this revision: Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_tx.c vendor-sys/illumos/dist/uts/common/fs/zfs/sys/sa_impl.h vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_vfsops.c vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_znode.c Modified: vendor/illumos/dist/cmd/zfs/zfs_main.c ============================================================================== --- vendor/illumos/dist/cmd/zfs/zfs_main.c Wed Sep 26 07:09:15 2012 (r240948) +++ vendor/illumos/dist/cmd/zfs/zfs_main.c Wed Sep 26 08:57:12 2012 (r240949) @@ -252,7 +252,7 @@ get_usage(zfs_help_t idx) case HELP_ROLLBACK: return (gettext("\trollback [-rRf] \n")); case HELP_SEND: - return (gettext("\tsend [-DnPpRrv] [-[iI] snapshot] " + return (gettext("\tsend [-DnPpRv] [-[iI] snapshot] " "\n")); case HELP_SET: return (gettext("\tset " Modified: vendor/illumos/dist/man/man1m/zfs.1m ============================================================================== --- vendor/illumos/dist/man/man1m/zfs.1m Wed Sep 26 07:09:15 2012 (r240948) +++ vendor/illumos/dist/man/man1m/zfs.1m Wed Sep 26 08:57:12 2012 (r240949) @@ -26,7 +26,7 @@ .\" Copyright (c) 2012, Joyent, Inc. All rights reserved. .\" Copyright 2012 Nexenta Systems, Inc. All Rights Reserved. .\" -.TH ZFS 1M "Aug 16, 2012" +.TH ZFS 1M "Sep 16, 2012" .SH NAME zfs \- configures ZFS file systems .SH SYNOPSIS @@ -886,14 +886,14 @@ This property is not inherited. .sp .ne 2 .na -\fB\fBchecksum\fR=\fBon\fR | \fBoff\fR | \fBfletcher2,\fR| \fBfletcher4\fR | +\fB\fBchecksum\fR=\fBon\fR | \fBoff\fR | \fBfletcher2\fR | \fBfletcher4\fR | \fBsha256\fR\fR .ad .sp .6 .RS 4n Controls the checksum used to verify data integrity. The default value is \fBon\fR, which automatically selects an appropriate algorithm (currently, -\fBfletcher2\fR, but this may change in future releases). The value \fBoff\fR +\fBfletcher4\fR, but this may change in future releases). The value \fBoff\fR disables integrity checking on user data. Disabling checksums is \fBNOT\fR a recommended practice. .sp @@ -2733,7 +2733,7 @@ Unshare the specified filesystem. The co .sp .ne 2 .na -\fBzfs send\fR [\fB-DnPpRrv\fR] [\fB-\fR[\fBiI\fR] \fIsnapshot\fR] \fIsnapshot\fR +\fBzfs send\fR [\fB-DnPpRv\fR] [\fB-\fR[\fBiI\fR] \fIsnapshot\fR] \fIsnapshot\fR .ad .sp .6 .RS 4n @@ -2809,18 +2809,6 @@ will be much better if the filesystem us .sp .ne 2 .na -\fB\fB-r\fR\fR -.ad -.sp .6 -.RS 4n -Recursively send all descendant snapshots. This is similar to the \fB-R\fR -flag, but information about deleted and renamed datasets is not included, and -property information is only included if the \fB-p\fR flag is specified. -.RE - -.sp -.ne 2 -.na \fB\fB-p\fR\fR .ad .sp .6