svn commit: r273893 - head/sys/kern

2014-10-31 Thread Mateusz Guzik
Author: mjg
Date: Fri Oct 31 09:15:59 2014
New Revision: 273893
URL: https://svnweb.freebsd.org/changeset/base/273893

Log:
  filedesc: tidy up fdfree
  
  Implement fdefree_last variant and get rid of 'last' parameter.
  
  No functional changes.

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cFri Oct 31 08:14:13 2014
(r273892)
+++ head/sys/kern/kern_descrip.cFri Oct 31 09:15:59 2014
(r273893)
@@ -291,18 +291,22 @@ fdunused(struct filedesc *fdp, int fd)
  * Avoid some work if fdp is about to be destroyed.
  */
 static inline void
-_fdfree(struct filedesc *fdp, int fd, int last)
+fdefree_last(struct filedescent *fde)
+{
+
+   filecaps_free(fde-fde_caps);
+}
+
+static inline void
+fdfree(struct filedesc *fdp, int fd)
 {
struct filedescent *fde;
 
fde = fdp-fd_ofiles[fd];
 #ifdef CAPABILITIES
-   if (!last)
-   seq_write_begin(fde-fde_seq);
+   seq_write_begin(fde-fde_seq);
 #endif
-   filecaps_free(fde-fde_caps);
-   if (last)
-   return;
+   fdefree_last(fde);
bzero(fde, fde_change_size);
fdunused(fdp, fd);
 #ifdef CAPABILITIES
@@ -310,20 +314,6 @@ _fdfree(struct filedesc *fdp, int fd, in
 #endif
 }
 
-static inline void
-fdfree(struct filedesc *fdp, int fd)
-{
-
-   _fdfree(fdp, fd, 0);
-}
-
-static inline void
-fdfree_last(struct filedesc *fdp, int fd)
-{
-
-   _fdfree(fdp, fd, 1);
-}
-
 /*
  * System calls on descriptors.
  */
@@ -1956,6 +1946,7 @@ fdescfree(struct thread *td)
struct filedesc *fdp;
int i;
struct filedesc_to_leader *fdtol;
+   struct filedescent *fde;
struct file *fp;
struct vnode *cdir, *jdir, *rdir, *vp;
struct flock lf;
@@ -2055,9 +2046,10 @@ fdescfree(struct thread *td)
FILEDESC_XUNLOCK(fdp);
 
for (i = 0; i = fdp-fd_lastfile; i++) {
-   fp = fdp-fd_ofiles[i].fde_file;
+   fde = fdp-fd_ofiles[i];
+   fp = fde-fde_file;
if (fp != NULL) {
-   fdfree_last(fdp, i);
+   fdefree_last(fde);
(void) closef(fp, td);
}
}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273894 - head/sys/kern

2014-10-31 Thread Mateusz Guzik
Author: mjg
Date: Fri Oct 31 09:19:46 2014
New Revision: 273894
URL: https://svnweb.freebsd.org/changeset/base/273894

Log:
  filedesc: iterate over fd table only once in fdcopy
  
  While here add 'fdused_init' which does not perform unnecessary work.
  
  Drop FILEDESC_LOCK_ASSERT from fdisused and rely on callers to hold
  it when appropriate. This function is only used with INVARIANTS.
  
  No functional changes intended.

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cFri Oct 31 09:15:59 2014
(r273893)
+++ head/sys/kern/kern_descrip.cFri Oct 31 09:19:46 2014
(r273894)
@@ -238,8 +238,6 @@ static int
 fdisused(struct filedesc *fdp, int fd)
 {
 
-   FILEDESC_LOCK_ASSERT(fdp);
-
KASSERT(fd = 0  fd  fdp-fd_nfiles,
(file descriptor %d out of range (0, %d), fd, fdp-fd_nfiles));
 
@@ -251,14 +249,21 @@ fdisused(struct filedesc *fdp, int fd)
  * Mark a file descriptor as used.
  */
 static void
-fdused(struct filedesc *fdp, int fd)
+fdused_init(struct filedesc *fdp, int fd)
 {
 
-   FILEDESC_XLOCK_ASSERT(fdp);
-
KASSERT(!fdisused(fdp, fd), (fd=%d is already used, fd));
 
fdp-fd_map[NDSLOT(fd)] |= NDBIT(fd);
+}
+
+static void
+fdused(struct filedesc *fdp, int fd)
+{
+
+   FILEDESC_XLOCK_ASSERT(fdp);
+
+   fdused_init(fdp, fd);
if (fd  fdp-fd_lastfile)
fdp-fd_lastfile = fd;
if (fd == fdp-fd_freefile)
@@ -1912,28 +1917,23 @@ fdcopy(struct filedesc *fdp)
newfdp-fd_freefile = -1;
for (i = 0; i = fdp-fd_lastfile; ++i) {
ofde = fdp-fd_ofiles[i];
-   if (ofde-fde_file != NULL 
-   ofde-fde_file-f_ops-fo_flags  DFLAG_PASSABLE) {
-   nfde = newfdp-fd_ofiles[i];
-   *nfde = *ofde;
-   filecaps_copy(ofde-fde_caps, nfde-fde_caps);
-   fhold(nfde-fde_file);
-   newfdp-fd_lastfile = i;
-   } else {
+   if (ofde-fde_file == NULL ||
+   (ofde-fde_file-f_ops-fo_flags  DFLAG_PASSABLE) == 0) {
if (newfdp-fd_freefile == -1)
newfdp-fd_freefile = i;
+   continue;
}
-   }
-   newfdp-fd_cmask = fdp-fd_cmask;
-   FILEDESC_SUNLOCK(fdp);
-   FILEDESC_XLOCK(newfdp);
-   for (i = 0; i = newfdp-fd_lastfile; ++i) {
-   if (newfdp-fd_ofiles[i].fde_file != NULL)
-   fdused(newfdp, i);
+   nfde = newfdp-fd_ofiles[i];
+   *nfde = *ofde;
+   filecaps_copy(ofde-fde_caps, nfde-fde_caps);
+   fhold(nfde-fde_file);
+   fdused_init(newfdp, i);
+   newfdp-fd_lastfile = i;
}
if (newfdp-fd_freefile == -1)
newfdp-fd_freefile = i;
-   FILEDESC_XUNLOCK(newfdp);
+   newfdp-fd_cmask = fdp-fd_cmask;
+   FILEDESC_SUNLOCK(fdp);
return (newfdp);
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273895 - head/sys/kern

2014-10-31 Thread Mateusz Guzik
Author: mjg
Date: Fri Oct 31 09:25:28 2014
New Revision: 273895
URL: https://svnweb.freebsd.org/changeset/base/273895

Log:
  filedesc: make fdinit return with source filedesc locked and new one sized
  appropriately
  
  Assert FILEDESC_XLOCK_ASSERT only for already used tables in fdgrowtable.
  We don't have to call it with the lock held if we are just creating new
  filedesc.
  
  As a side note, strictly speaking processes can have fdtables with
  fd_lastfile = -1, but then they cannot enter fdgrowtable. Very first file
  descriptor they get will be 0 and the only syscall allowing to choose fd 
number
  requires an active file descriptor. Should this ever change, we can add an 
'init'
  (or similar) parameter to fdgrowtable.

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cFri Oct 31 09:19:46 2014
(r273894)
+++ head/sys/kern/kern_descrip.cFri Oct 31 09:25:28 2014
(r273895)
@@ -1524,7 +1524,13 @@ fdgrowtable(struct filedesc *fdp, int nf
int nnfiles, onfiles;
NDSLOTTYPE *nmap, *omap;
 
-   FILEDESC_XLOCK_ASSERT(fdp);
+   /*
+* If lastfile is -1 this struct filedesc was just allocated and we are
+* growing it to accomodate for the one we are going to copy from. There
+* is no need to have a lock on this one as it's not visible to anyone.
+*/
+   if (fdp-fd_lastfile != -1)
+   FILEDESC_XLOCK_ASSERT(fdp);
 
KASSERT(fdp-fd_nfiles  0, (zero-length file table));
 
@@ -1791,37 +1797,52 @@ finstall(struct thread *td, struct file 
 /*
  * Build a new filedesc structure from another.
  * Copy the current, root, and jail root vnode references.
+ *
+ * If fdp is not NULL, return with it shared locked.
  */
 struct filedesc *
 fdinit(struct filedesc *fdp)
 {
-   struct filedesc0 *newfdp;
+   struct filedesc0 *newfdp0;
+   struct filedesc *newfdp;
 
-   newfdp = malloc(sizeof *newfdp, M_FILEDESC, M_WAITOK | M_ZERO);
-   FILEDESC_LOCK_INIT(newfdp-fd_fd);
-   if (fdp != NULL) {
-   FILEDESC_SLOCK(fdp);
-   newfdp-fd_fd.fd_cdir = fdp-fd_cdir;
-   if (newfdp-fd_fd.fd_cdir)
-   VREF(newfdp-fd_fd.fd_cdir);
-   newfdp-fd_fd.fd_rdir = fdp-fd_rdir;
-   if (newfdp-fd_fd.fd_rdir)
-   VREF(newfdp-fd_fd.fd_rdir);
-   newfdp-fd_fd.fd_jdir = fdp-fd_jdir;
-   if (newfdp-fd_fd.fd_jdir)
-   VREF(newfdp-fd_fd.fd_jdir);
+   newfdp0 = malloc(sizeof *newfdp0, M_FILEDESC, M_WAITOK | M_ZERO);
+   newfdp = newfdp0-fd_fd;
+
+   /* Create the file descriptor table. */
+   FILEDESC_LOCK_INIT(newfdp);
+   newfdp-fd_refcnt = 1;
+   newfdp-fd_holdcnt = 1;
+   newfdp-fd_cmask = CMASK;
+   newfdp-fd_map = newfdp0-fd_dmap;
+   newfdp-fd_lastfile = -1;
+   newfdp-fd_files = (struct fdescenttbl *)newfdp0-fd_dfiles;
+   newfdp-fd_files-fdt_nfiles = NDFILE;
+
+   if (fdp == NULL)
+   return (newfdp);
+
+   if (fdp-fd_lastfile = newfdp-fd_nfiles)
+   fdgrowtable(newfdp, fdp-fd_lastfile + 1);
+
+   FILEDESC_SLOCK(fdp);
+   newfdp-fd_cdir = fdp-fd_cdir;
+   if (newfdp-fd_cdir)
+   VREF(newfdp-fd_cdir);
+   newfdp-fd_rdir = fdp-fd_rdir;
+   if (newfdp-fd_rdir)
+   VREF(newfdp-fd_rdir);
+   newfdp-fd_jdir = fdp-fd_jdir;
+   if (newfdp-fd_jdir)
+   VREF(newfdp-fd_jdir);
+
+   while (fdp-fd_lastfile = newfdp-fd_nfiles) {
FILEDESC_SUNLOCK(fdp);
+   fdgrowtable(newfdp, fdp-fd_lastfile + 1);
+   FILEDESC_SLOCK(fdp);
}
 
-   /* Create the file descriptor table. */
-   newfdp-fd_fd.fd_refcnt = 1;
-   newfdp-fd_fd.fd_holdcnt = 1;
-   newfdp-fd_fd.fd_cmask = CMASK;
-   newfdp-fd_dfiles.fdt_nfiles = NDFILE;
-   newfdp-fd_fd.fd_files = (struct fdescenttbl *)newfdp-fd_dfiles;
-   newfdp-fd_fd.fd_map = newfdp-fd_dmap;
-   newfdp-fd_fd.fd_lastfile = -1;
-   return (newfdp-fd_fd);
+   return (newfdp);
 }
 
 static struct filedesc *
@@ -1905,14 +1926,6 @@ fdcopy(struct filedesc *fdp)
return (NULL);
 
newfdp = fdinit(fdp);
-   FILEDESC_SLOCK(fdp);
-   while (fdp-fd_lastfile = newfdp-fd_nfiles) {
-   FILEDESC_SUNLOCK(fdp);
-   FILEDESC_XLOCK(newfdp);
-   fdgrowtable(newfdp, fdp-fd_lastfile + 1);
-   FILEDESC_XUNLOCK(newfdp);
-   FILEDESC_SLOCK(fdp);
-   }
/* copy all passable descriptors (i.e. not kqueue) */
newfdp-fd_freefile = -1;
for (i = 0; i = fdp-fd_lastfile; ++i) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To 

svn commit: r273896 - head/sbin/mount_nfs

2014-10-31 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri Oct 31 09:51:54 2014
New Revision: 273896
URL: https://svnweb.freebsd.org/changeset/base/273896

Log:
  Build mount_nfs(8) with WARNS=6.
  
  Reviewed by:  rmacklem@
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sbin/mount_nfs/Makefile
  head/sbin/mount_nfs/mount_nfs.c

Modified: head/sbin/mount_nfs/Makefile
==
--- head/sbin/mount_nfs/MakefileFri Oct 31 09:25:28 2014
(r273895)
+++ head/sbin/mount_nfs/MakefileFri Oct 31 09:51:54 2014
(r273896)
@@ -10,7 +10,6 @@ MLINKS=   mount_nfs.8 mount_oldnfs.8
 MOUNT= ${.CURDIR}/../mount
 UMNTALL= ${.CURDIR}/../../usr.sbin/rpc.umntall
 CFLAGS+= -DNFS -I${MOUNT} -I${UMNTALL}
-WARNS?=3
 
 LINKS= ${BINDIR}/mount_nfs ${BINDIR}/mount_oldnfs
 

Modified: head/sbin/mount_nfs/mount_nfs.c
==
--- head/sbin/mount_nfs/mount_nfs.c Fri Oct 31 09:25:28 2014
(r273895)
+++ head/sbin/mount_nfs/mount_nfs.c Fri Oct 31 09:51:54 2014
(r273896)
@@ -79,7 +79,7 @@ __FBSDID($FreeBSD$);
 #include mounttab.h
 
 /* Table for af,sotype - netid conversions. */
-struct nc_protos {
+static struct nc_protos {
const char *netid;
int af;
int sotype;
@@ -102,20 +102,21 @@ struct nfhret {
 #defineISBGRND 2
 #defineOF_NOINET4  4
 #defineOF_NOINET6  8
-int retrycnt = -1;
-int opflags = 0;
-int nfsproto = IPPROTO_TCP;
-int mnttcp_ok = 1;
-int noconn = 0;
-char *portspec = NULL; /* Server nfs port; NULL means look up via rpcbind. */
-struct sockaddr *addr;
-int addrlen = 0;
-u_char *fh = NULL;
-int fhsize = 0;
-int secflavor = -1;
-int got_principal = 0;
+static int retrycnt = -1;
+static int opflags = 0;
+static int nfsproto = IPPROTO_TCP;
+static int mnttcp_ok = 1;
+static int noconn = 0;
+/* The 'portspec' is the server nfs port; NULL means look up via rpcbind. */
+static const char *portspec = NULL;
+static struct sockaddr *addr;
+static int addrlen = 0;
+static u_char *fh = NULL;
+static int fhsize = 0;
+static int secflavor = -1;
+static int got_principal = 0;
 
-enum mountmode {
+static enum mountmode {
ANY,
V2,
V3,
@@ -130,8 +131,8 @@ enum tryret {
TRYRET_LOCALERR /* Local failure. */
 };
 
-static int sec_name_to_num(char *sec);
-static char*sec_num_to_name(int num);
+static int sec_name_to_num(const char *sec);
+static const char  *sec_num_to_name(int num);
 static int getnfsargs(char *, struct iovec **iov, int *iovlen);
 /* voidset_rpc_maxgrouplist(int); */
 static struct netconfig *getnetconf_cached(const char *netid);
@@ -149,9 +150,10 @@ main(int argc, char *argv[])
int c;
struct iovec *iov;
int num, iovlen;
-   char *name, *p, *spec, *fstype;
+   char *mntname, *p, *spec, *tmp;
char mntpath[MAXPATHLEN], errmsg[255];
-   char hostname[MAXHOSTNAMELEN + 1], *gssname, gssn[MAXHOSTNAMELEN + 50];
+   char hostname[MAXHOSTNAMELEN + 1], gssn[MAXHOSTNAMELEN + 50];
+   const char *fstype, *gssname;
 
iov = NULL;
iovlen = 0;
@@ -226,7 +228,7 @@ main(int argc, char *argv[])
while (opt) {
char *pval = NULL;
char *pnextopt = NULL;
-   char *val = ;
+   const char *val = ;
pass_flag_to_nmount = 1;
pnextopt = strchr(opt, ',');
if (pnextopt != NULL) {
@@ -276,10 +278,10 @@ main(int argc, char *argv[])
portspec = 2049;
} else if (strcmp(opt, port) == 0) {
pass_flag_to_nmount=0;
-   asprintf(portspec, %d,
-   atoi(val));
-   if (portspec == NULL)
+   asprintf(tmp, %d, atoi(val));
+   if (tmp == NULL)
err(1, asprintf);
+   portspec = tmp;
} else if (strcmp(opt, principal) == 0) {
got_principal = 1;
} else if (strcmp(opt, proto) == 0) {
@@ -364,9 +366,11 @@ main(int argc, char *argv[])
}
pass_flag_to_nmount=0;
}
-   if (pass_flag_to_nmount)
-   build_iovec(iov, iovlen, opt, val,
+   if (pass_flag_to_nmount) {
+   

Re: svn commit: r273861 - head/sbin/mount_nfs

2014-10-31 Thread Edward Tomasz Napierala
On 1030T1847, Sergey Kandaurov wrote:
 On 30 October 2014 17:05, Edward Tomasz Napierala tr...@freebsd.org wrote:
  Author: trasz
  Date: Thu Oct 30 14:05:48 2014
  New Revision: 273861
  URL: https://svnweb.freebsd.org/changeset/base/273861
 
  Log:
Remove two functions unused after r273848.  Would be nice if clang
or at least scan-build yelled about it.
 
 It does but with WARNS=3, -Wunused-function is disabled.

Ah, right.  Fixed :-)

___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273897 - head/sys/kern

2014-10-31 Thread Mateusz Guzik
Author: mjg
Date: Fri Oct 31 09:56:00 2014
New Revision: 273897
URL: https://svnweb.freebsd.org/changeset/base/273897

Log:
  filedesc: fix missed comments about fdsetugidsafety
  
  While here just note that both fdsetugidsafety and fdcheckstd take sleepable
  locks.

Modified:
  head/sys/kern/kern_descrip.c
  head/sys/kern/kern_exec.c

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cFri Oct 31 09:51:54 2014
(r273896)
+++ head/sys/kern/kern_descrip.cFri Oct 31 09:56:00 2014
(r273897)
@@ -2088,7 +2088,7 @@ fdescfree(struct thread *td)
  * otherwise be off-limits to the process.  We check for filesystems where
  * the vnode can change out from under us after execve (like [lin]procfs).
  *
- * Since setugidsafety calls this only for fd 0, 1 and 2, this check is
+ * Since fdsetugidsafety calls this only for fd 0, 1 and 2, this check is
  * sufficient.  We also don't check for setugidness since we know we are.
  */
 static bool

Modified: head/sys/kern/kern_exec.c
==
--- head/sys/kern/kern_exec.c   Fri Oct 31 09:51:54 2014(r273896)
+++ head/sys/kern/kern_exec.c   Fri Oct 31 09:56:00 2014(r273897)
@@ -688,10 +688,8 @@ interpret:
 * Close any file descriptors 0..2 that reference procfs,
 * then make sure file descriptors 0..2 are in use.
 *
-* setugidsafety() may call closef() and then pfind()
-* which may grab the process lock.
-* fdcheckstd() may call falloc() which may block to
-* allocate memory, so temporarily drop the process lock.
+* Both fdsetugidsafety() and fdcheckstd() may call functions
+* taking sleepable locks, so temporarily drop our locks.
 */
PROC_UNLOCK(p);
VOP_UNLOCK(imgp-vp, 0);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273899 - head/sys/sys

2014-10-31 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Oct 31 10:18:58 2014
New Revision: 273899
URL: https://svnweb.freebsd.org/changeset/base/273899

Log:
  Only put one CTASSERT() inside each macro to avoid compile issues.
  The problem is that the __LINE__ macro is constant inside a macro and
  results in identical assert statements when the compiler does not
  support the static builtin assert function.
  
  MFC:  3 days
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/sys/sysctl.h

Modified: head/sys/sys/sysctl.h
==
--- head/sys/sys/sysctl.h   Fri Oct 31 10:07:56 2014(r273898)
+++ head/sys/sys/sysctl.h   Fri Oct 31 10:18:58 2014(r273899)
@@ -324,9 +324,9 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e
SYSCTL_OID(parent, nbr, name,   \
CTLTYPE_INT | CTLFLAG_MPSAFE | (access),\
ptr, val, sysctl_handle_int, I, descr);   \
-   CTASSERT(((access)  CTLTYPE) == 0 ||   \
-   ((access)  SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \
-   CTASSERT(sizeof(int) == sizeof(*(ptr)))
+   CTASSERTaccess)  CTLTYPE) == 0 ||  \
+   ((access)  SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT)  \
+   sizeof(int) == sizeof(*(ptr)))
 
 #defineSYSCTL_ADD_INT(ctx, parent, nbr, name, access, ptr, val, descr) 
\
 ({ \
@@ -344,9 +344,9 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e
SYSCTL_OID(parent, nbr, name,   \
CTLTYPE_UINT | CTLFLAG_MPSAFE | (access),   \
ptr, val, sysctl_handle_int, IU, descr);  \
-   CTASSERT(((access)  CTLTYPE) == 0 ||   \
-   ((access)  SYSCTL_CT_ASSERT_MASK) == CTLTYPE_UINT);\
-   CTASSERT(sizeof(unsigned) == sizeof(*(ptr)))
+   CTASSERTaccess)  CTLTYPE) == 0 ||  \
+   ((access)  SYSCTL_CT_ASSERT_MASK) == CTLTYPE_UINT)  \
+   sizeof(unsigned) == sizeof(*(ptr)))
 
 #defineSYSCTL_ADD_UINT(ctx, parent, nbr, name, access, ptr, val, 
descr) \
 ({ \
@@ -364,9 +364,9 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e
SYSCTL_OID(parent, nbr, name,   \
CTLTYPE_LONG | CTLFLAG_MPSAFE | (access),   \
ptr, val, sysctl_handle_long, L, descr);  \
-   CTASSERT(((access)  CTLTYPE) == 0 ||   \
-   ((access)  SYSCTL_CT_ASSERT_MASK) == CTLTYPE_LONG);\
-   CTASSERT(sizeof(long) == sizeof(*(ptr)))
+   CTASSERTaccess)  CTLTYPE) == 0 ||  \
+   ((access)  SYSCTL_CT_ASSERT_MASK) == CTLTYPE_LONG)  \
+   sizeof(long) == sizeof(*(ptr)))
 
 #defineSYSCTL_ADD_LONG(ctx, parent, nbr, name, access, ptr, descr) 
\
 ({ \
@@ -384,9 +384,9 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e
SYSCTL_OID(parent, nbr, name,   \
CTLTYPE_ULONG | CTLFLAG_MPSAFE | (access),  \
ptr, val, sysctl_handle_long, LU, descr); \
-   CTASSERT(((access)  CTLTYPE) == 0 ||   \
-   ((access)  SYSCTL_CT_ASSERT_MASK) == CTLTYPE_ULONG);   \
-   CTASSERT(sizeof(unsigned long) == sizeof(*(ptr)))
+   CTASSERTaccess)  CTLTYPE) == 0 ||  \
+   ((access)  SYSCTL_CT_ASSERT_MASK) == CTLTYPE_ULONG)  \
+   sizeof(unsigned long) == sizeof(*(ptr)))
 
 #defineSYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr)
\
 ({ \
@@ -404,9 +404,9 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e
SYSCTL_OID(parent, nbr, name,   \
CTLTYPE_S64 | CTLFLAG_MPSAFE | (access),\
ptr, val, sysctl_handle_64, Q, descr);\
-   CTASSERT(((access)  CTLTYPE) == 0 ||   \
-   ((access)  SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \
-   CTASSERT(sizeof(int64_t) == sizeof(*(ptr)))
+   CTASSERTaccess)  CTLTYPE) == 0 ||  \
+   ((access)  SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64)  \
+   sizeof(int64_t) == sizeof(*(ptr)))
 
 #defineSYSCTL_ADD_QUAD(ctx, parent, nbr, name, access, ptr, descr) 
\
 ({ \
@@ -423,9 +423,9 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e
SYSCTL_OID(parent, nbr, name,   \
CTLTYPE_U64 | CTLFLAG_MPSAFE | (access),\
 ptr, val, sysctl_handle_64, QU, descr);  \
-   CTASSERT(((access)  CTLTYPE) == 0 

svn commit: r273901 - head/sys/kern

2014-10-31 Thread Mateusz Guzik
Author: mjg
Date: Fri Oct 31 10:35:01 2014
New Revision: 273901
URL: https://svnweb.freebsd.org/changeset/base/273901

Log:
  filedesc: drop retval argument from do_dup
  
  It was almost always td_retval anyway.
  
  For the one case where it is not, preserve the old value across the call.

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cFri Oct 31 10:25:31 2014
(r273900)
+++ head/sys/kern/kern_descrip.cFri Oct 31 10:35:01 2014
(r273901)
@@ -101,8 +101,7 @@ static uma_zone_t file_zone;
 
 static int closefp(struct filedesc *fdp, int fd, struct file *fp,
struct thread *td, int holdleaders);
-static int do_dup(struct thread *td, int flags, int old, int new,
-   register_t *retval);
+static int do_dup(struct thread *td, int flags, int old, int new);
 static int fd_first_free(struct filedesc *fdp, int low, int size);
 static int fd_last_used(struct filedesc *fdp, int size);
 static voidfdgrowtable(struct filedesc *fdp, int nfd);
@@ -361,8 +360,7 @@ int
 sys_dup2(struct thread *td, struct dup2_args *uap)
 {
 
-   return (do_dup(td, DUP_FIXED, (int)uap-from, (int)uap-to,
-   td-td_retval));
+   return (do_dup(td, DUP_FIXED, (int)uap-from, (int)uap-to));
 }
 
 /*
@@ -378,7 +376,7 @@ int
 sys_dup(struct thread *td, struct dup_args *uap)
 {
 
-   return (do_dup(td, 0, (int)uap-fd, 0, td-td_retval));
+   return (do_dup(td, 0, (int)uap-fd, 0));
 }
 
 /*
@@ -487,24 +485,22 @@ kern_fcntl(struct thread *td, int fd, in
switch (cmd) {
case F_DUPFD:
tmp = arg;
-   error = do_dup(td, DUP_FCNTL, fd, tmp, td-td_retval);
+   error = do_dup(td, DUP_FCNTL, fd, tmp);
break;
 
case F_DUPFD_CLOEXEC:
tmp = arg;
-   error = do_dup(td, DUP_FCNTL | DUP_CLOEXEC, fd, tmp,
-   td-td_retval);
+   error = do_dup(td, DUP_FCNTL | DUP_CLOEXEC, fd, tmp);
break;
 
case F_DUP2FD:
tmp = arg;
-   error = do_dup(td, DUP_FIXED, fd, tmp, td-td_retval);
+   error = do_dup(td, DUP_FIXED, fd, tmp);
break;
 
case F_DUP2FD_CLOEXEC:
tmp = arg;
-   error = do_dup(td, DUP_FIXED | DUP_CLOEXEC, fd, tmp,
-   td-td_retval);
+   error = do_dup(td, DUP_FIXED | DUP_CLOEXEC, fd, tmp);
break;
 
case F_GETFD:
@@ -803,8 +799,7 @@ getmaxfd(struct proc *p)
  * Common code for dup, dup2, fcntl(F_DUPFD) and fcntl(F_DUP2FD).
  */
 static int
-do_dup(struct thread *td, int flags, int old, int new,
-register_t *retval)
+do_dup(struct thread *td, int flags, int old, int new)
 {
struct filedesc *fdp;
struct filedescent *oldfde, *newfde;
@@ -836,7 +831,7 @@ do_dup(struct thread *td, int flags, int
}
oldfde = fdp-fd_ofiles[old];
if (flags  DUP_FIXED  old == new) {
-   *retval = new;
+   td-td_retval[0] = new;
if (flags  DUP_CLOEXEC)
fdp-fd_ofiles[new].fde_flags |= UF_EXCLOSE;
FILEDESC_XUNLOCK(fdp);
@@ -906,7 +901,7 @@ do_dup(struct thread *td, int flags, int
 #ifdef CAPABILITIES
seq_write_end(newfde-fde_seq);
 #endif
-   *retval = new;
+   td-td_retval[0] = new;
 
if (delfp != NULL) {
(void) closefp(fdp, new, delfp, td, 1);
@@ -2191,7 +2186,7 @@ int
 fdcheckstd(struct thread *td)
 {
struct filedesc *fdp;
-   register_t retval, save;
+   register_t save;
int i, error, devnull;
 
fdp = td-td_proc-p_fd;
@@ -2211,7 +2206,9 @@ fdcheckstd(struct thread *td)
break;
KASSERT(devnull == i, (oof, we didn't get our fd));
} else {
-   error = do_dup(td, DUP_FIXED, devnull, i, retval);
+   save = td-td_retval[0];
+   error = do_dup(td, DUP_FIXED, devnull, i);
+   td-td_retval[0] = save;
if (error != 0)
break;
}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273902 - head/sys/modules/drm2/drm2

2014-10-31 Thread Tijl Coosemans
Author: tijl
Date: Fri Oct 31 10:45:34 2014
New Revision: 273902
URL: https://svnweb.freebsd.org/changeset/base/273902

Log:
  Build ttm_agp_backend.c.
  
  Reported by:  dumbbell
  MFC after:1 month

Modified:
  head/sys/modules/drm2/drm2/Makefile

Modified: head/sys/modules/drm2/drm2/Makefile
==
--- head/sys/modules/drm2/drm2/Makefile Fri Oct 31 10:35:01 2014
(r273901)
+++ head/sys/modules/drm2/drm2/Makefile Fri Oct 31 10:45:34 2014
(r273902)
@@ -35,6 +35,7 @@ SRCS  = \
drm_stub.c \
drm_sysctl.c \
drm_vm.c \
+   ttm_agp_backend.c \
ttm_lock.c \
ttm_object.c \
ttm_tt.c \
@@ -46,7 +47,6 @@ SRCS  = \
ttm_page_alloc.c \
ttm_bo_vm.c \
ati_pcigart.c
-#ttm_agp_backend.c
 #ttm_page_alloc_dma.c
 
 .if ${MACHINE_CPUARCH} == amd64
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273903 - head/sys/netinet

2014-10-31 Thread Andrey V. Elsukov
Author: ae
Date: Fri Oct 31 11:40:49 2014
New Revision: 273903
URL: https://svnweb.freebsd.org/changeset/base/273903

Log:
  Fix typo.

Modified:
  head/sys/netinet/tcp_syncache.c

Modified: head/sys/netinet/tcp_syncache.c
==
--- head/sys/netinet/tcp_syncache.c Fri Oct 31 10:45:34 2014
(r273902)
+++ head/sys/netinet/tcp_syncache.c Fri Oct 31 11:40:49 2014
(r273903)
@@ -1519,7 +1519,7 @@ syncache_respond(struct syncache *sc, st
/*
 * We've got SCF_SIGNATURE flag
 * inherited from listening socket,
-* but to SADB key for given source
+* but no SADB key for given source
 * address. Assume signature is not
 * required and remove signature flag
 * instead of silently dropping
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273904 - head/sys/netipsec

2014-10-31 Thread Andrey V. Elsukov
Author: ae
Date: Fri Oct 31 12:19:22 2014
New Revision: 273904
URL: https://svnweb.freebsd.org/changeset/base/273904

Log:
  Use in_localip() instead of handmade implementation.
  
  MFC after:1 week
  Sponsored by: Yandex LLC

Modified:
  head/sys/netipsec/key.c

Modified: head/sys/netipsec/key.c
==
--- head/sys/netipsec/key.c Fri Oct 31 11:40:49 2014(r273903)
+++ head/sys/netipsec/key.c Fri Oct 31 12:19:22 2014(r273904)
@@ -3906,33 +3906,14 @@ key_dup_lifemsg(const struct sadb_lifeti
  * 0: false
  */
 int
-key_ismyaddr(sa)
-   struct sockaddr *sa;
+key_ismyaddr(struct sockaddr *sa)
 {
-#ifdef INET
-   struct sockaddr_in *sin;
-   struct in_ifaddr *ia;
-#endif
 
IPSEC_ASSERT(sa != NULL, (null sockaddr));
-
switch (sa-sa_family) {
 #ifdef INET
case AF_INET:
-   sin = (struct sockaddr_in *)sa;
-   IN_IFADDR_RLOCK();
-   TAILQ_FOREACH(ia, V_in_ifaddrhead, ia_link)
-   {
-   if (sin-sin_family == ia-ia_addr.sin_family 
-   sin-sin_len == ia-ia_addr.sin_len 
-   sin-sin_addr.s_addr == ia-ia_addr.sin_addr.s_addr)
-   {
-   IN_IFADDR_RUNLOCK();
-   return 1;
-   }
-   }
-   IN_IFADDR_RUNLOCK();
-   break;
+   return (in_localip(satosin(sa)-sin_addr));
 #endif
 #ifdef INET6
case AF_INET6:
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273906 - head/sbin/route

2014-10-31 Thread Alexander V. Chernikov
Author: melifaro
Date: Fri Oct 31 13:37:47 2014
New Revision: 273906
URL: https://svnweb.freebsd.org/changeset/base/273906

Log:
  Print human-readable error for route not found case.
  
  Submitted by: vsevolod (initial version)
  MFC after:2 weeks
  Sponsored by: Yandex LLC

Modified:
  head/sbin/route/route.c

Modified: head/sbin/route/route.c
==
--- head/sbin/route/route.c Fri Oct 31 12:21:43 2014(r273905)
+++ head/sbin/route/route.c Fri Oct 31 13:37:47 2014(r273906)
@@ -1533,9 +1533,18 @@ rtmsg(int cmd, int flags, int fib)
if (debugonly)
return (0);
if ((rlen = write(s, (char *)m_rtmsg, l))  0) {
-   if (errno == EPERM)
+   switch (errno) {
+   case EPERM:
err(1, writing to routing socket);
-   warn(writing to routing socket);
+   case ESRCH:
+   warnx(route has not been found);
+   break;
+   case EEXIST:
+   /* Handled by newroute() */
+   break;
+   default:
+   warn(writing to routing socket);
+   }
return (-1);
}
if (cmd == RTM_GET) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r273872 - in head: etc/defaults etc/rc.d libexec/save-entropy share/examples/kld/random_adaptor sys/conf sys/dev/glxsb sys/dev/random sys/kern sys/modules sys/modules/padlock_rng sys/m

2014-10-31 Thread Dag-Erling Smørgrav
Mark Murray ma...@freebsd.org writes:
 Log:
   This is the much-discussed major upgrade to the random(4) device,
   known to you all as /dev/random.

Much discussed and long-awaited :)  Thank you for your hard work and
persistence!

   Reviewed by:trasz,des(partial),imp(partial?),rwatson(partial?)

Must...  resist...  tentation to make a joke about imp(partial?)...

DES
-- 
Dag-Erling Smørgrav - d...@des.no
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org

Re: svn commit: r273872 - in head: etc/defaults etc/rc.d libexec/save-entropy share/examples/kld/random_adaptor sys/conf sys/dev/glxsb sys/dev/random sys/kern sys/modules sys/modules/padlock_rng sys/m

2014-10-31 Thread Dag-Erling Smørgrav
Andrey Chernov a...@freebsd.org writes:
 Mark Murray ma...@freebsd.org writes:
  Deleted:
head/etc/rc.d/initrandom
 It should be added to ObsoleteFiles.inc

Good catch, fixed in r273907.

DES
-- 
Dag-Erling Smørgrav - d...@des.no
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org

svn commit: r273907 - head

2014-10-31 Thread Dag-Erling Smørgrav
Author: des
Date: Fri Oct 31 14:22:26 2014
New Revision: 273907
URL: https://svnweb.freebsd.org/changeset/base/273907

Log:
  Add /etc/rc.d/initrandom, which was removed in r273872.
  
  Noticed by:   ache@

Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Fri Oct 31 13:37:47 2014(r273906)
+++ head/ObsoleteFiles.inc  Fri Oct 31 14:22:26 2014(r273907)
@@ -38,6 +38,8 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20141031: initrandom obsoleted by new /dev/random code
+OLD_FILES+=etc/rc.d/initrandom
 # 20141028: debug files accidentally installed as directory name
 OLD_FILES+=usr/lib/debug/usr/lib/i18n
 OLD_FILES+=usr/lib/debug/usr/lib/private
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r273872 - in head: etc/defaults etc/rc.d libexec/save-entropy share/examples/kld/random_adaptor sys/conf sys/dev/glxsb sys/dev/random sys/kern sys/modules sys/modules/padlock_rng sys/m

2014-10-31 Thread Dag-Erling Smørgrav
Dag-Erling Smørgrav d...@des.no writes:
 Must...  resist...  tentation to make a joke about imp(partial?)...

Ouch, *temptation.  French leaking into my English.

DES
-- 
Dag-Erling Smørgrav - d...@des.no
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org

Re: svn commit: r273872 - in head: etc/defaults etc/rc.d libexec/save-entropy share/examples/kld/random_adaptor sys/conf sys/dev/glxsb sys/dev/random sys/kern sys/modules sys/modules/padlock_rng sys/m

2014-10-31 Thread Mark R V Murray

 On 31 Oct 2014, at 14:22, Dag-Erling Smørgrav d...@des.no wrote:
 
 Andrey Chernov a...@freebsd.org writes:
 Mark Murray ma...@freebsd.org writes:
 Deleted:
  head/etc/rc.d/initrandom
 It should be added to ObsoleteFiles.inc
 
 Good catch, fixed in r273907.

Thanks!

M
-- 
Mark R V Murray

___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org

Re: svn commit: r273872 - in head: etc/defaults etc/rc.d libexec/save-entropy share/examples/kld/random_adaptor sys/conf sys/dev/glxsb sys/dev/random sys/kern sys/modules sys/modules/padlock_rng sys/m

2014-10-31 Thread Mark R V Murray

 On 31 Oct 2014, at 14:22, Dag-Erling Smørgrav d...@des.no wrote:
 
 Mark Murray ma...@freebsd.org writes:
 Log:
  This is the much-discussed major upgrade to the random(4) device,
  known to you all as /dev/random.
 
 Much discussed and long-awaited :)  Thank you for your hard work and
 persistence!

Thank you!

  Reviewed by:trasz,des(partial),imp(partial?),rwatson(partial?)
 
 Must...  resist...  tentation to make a joke about imp(partial?)…

*snigger* :-)

M
-- 
Mark R V Murray

___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org

svn commit: r273908 - head/sys/arm/arm

2014-10-31 Thread Kevin Lo
Author: kevlo
Date: Fri Oct 31 15:07:51 2014
New Revision: 273908
URL: https://svnweb.freebsd.org/changeset/base/273908

Log:
  Fix usage of kern_getenv().

Modified:
  head/sys/arm/arm/machdep.c

Modified: head/sys/arm/arm/machdep.c
==
--- head/sys/arm/arm/machdep.c  Fri Oct 31 14:22:26 2014(r273907)
+++ head/sys/arm/arm/machdep.c  Fri Oct 31 15:07:51 2014(r273908)
@@ -1246,8 +1246,10 @@ initarm(struct arm_boot_params *abp)
print_kenv();
 
env = kern_getenv(kernelname);
-   if (env != NULL)
+   if (env != NULL) {
strlcpy(kernelname, env, sizeof(kernelname));
+   freeenv(env);
+   }
 
if (err_devmap != 0)
printf(WARNING: could not fully configure devmap, error=%d\n,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273909 - head/sys/netinet

2014-10-31 Thread Andrey V. Elsukov
Author: ae
Date: Fri Oct 31 15:23:24 2014
New Revision: 273909
URL: https://svnweb.freebsd.org/changeset/base/273909

Log:
  Remove the check for packets with broadcast source from if_gif's encapcheck.
  
  The check was recommened in the draft-ietf-ngtrans-mech-05.txt. But it isn't
  clear, should it compare the source with all direct broadcast addresses in the
  system or not.
  RFC 4213 says it is enough to verify that the source address is the address
  of the encapsulator, as configured on the decapsulator. And this verification
  can be extended by administrator with any other forms of IPv4 ingress 
filtering.
  
  Discussed with:   glebius, melifaro
  Sponsored by: Yandex LLC

Modified:
  head/sys/netinet/in_gif.c

Modified: head/sys/netinet/in_gif.c
==
--- head/sys/netinet/in_gif.c   Fri Oct 31 15:07:51 2014(r273908)
+++ head/sys/netinet/in_gif.c   Fri Oct 31 15:23:24 2014(r273909)
@@ -167,7 +167,6 @@ in_gif_input(struct mbuf **mp, int *offp
 static int
 gif_validate4(const struct ip *ip, struct gif_softc *sc, struct ifnet *ifp)
 {
-   struct in_ifaddr *ia4;
 
GIF_RLOCK_ASSERT(sc);
 
@@ -186,19 +185,6 @@ gif_validate4(const struct ip *ip, struc
return (0);
}
 
-   /* reject packets with broadcast on source */
-   /* XXXRW: should use hash lists? */
-   IN_IFADDR_RLOCK();
-   TAILQ_FOREACH(ia4, V_in_ifaddrhead, ia_link) {
-   if ((ia4-ia_ifa.ifa_ifp-if_flags  IFF_BROADCAST) == 0)
-   continue;
-   if (ip-ip_src.s_addr == ia4-ia_broadaddr.sin_addr.s_addr) {
-   IN_IFADDR_RUNLOCK();
-   return (0);
-   }
-   }
-   IN_IFADDR_RUNLOCK();
-
/* ingress filters on outer source */
if ((GIF2IFP(sc)-if_flags  IFF_LINK2) == 0  ifp) {
struct sockaddr_in sin;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273910 - head/sys/netgraph

2014-10-31 Thread Gleb Smirnoff
Author: glebius
Date: Fri Oct 31 16:00:45 2014
New Revision: 273910
URL: https://svnweb.freebsd.org/changeset/base/273910

Log:
  Use macro ERROUT() to make code more laconic and follow style of other
  netgraph code.
  
  Submitted by: Dmitry Luhtionov dmitryluhtionov gmail.com

Modified:
  head/sys/netgraph/ng_frame_relay.c

Modified: head/sys/netgraph/ng_frame_relay.c
==
--- head/sys/netgraph/ng_frame_relay.c  Fri Oct 31 15:23:24 2014
(r273909)
+++ head/sys/netgraph/ng_frame_relay.c  Fri Oct 31 16:00:45 2014
(r273910)
@@ -148,6 +148,8 @@ static struct ng_type typestruct = {
 };
 NETGRAPH_INIT(framerelay, typestruct);
 
+#define ERROUT(x)  do { error = (x); goto done; } while (0)
+
 /*
  * Given a DLCI, return the index of the  context table entry for it,
  * Allocating a new one if needs be, or -1 if none available.
@@ -335,10 +337,8 @@ ngfrm_rcvdata(hook_p hook, item_p item)
char   *data;
 
/* Data doesn't come in from just anywhere (e.g debug hook) */
-   if (ctxp == NULL) {
-   error = ENETDOWN;
-   goto bad;
-   }
+   if (ctxp == NULL)
+   ERROUT(ENETDOWN);
 
/* If coming from downstream, decode it to a channel */
dlci = ctxp-dlci;
@@ -351,20 +351,16 @@ ngfrm_rcvdata(hook_p hook, item_p item)
 
/* If there is no live channel, throw it away */
if ((sc-downstream.hook == NULL)
-   || ((ctxp-flags  CHAN_ACTIVE) == 0)) {
-   error = ENETDOWN;
-   goto bad;
-   }
+   || ((ctxp-flags  CHAN_ACTIVE) == 0))
+   ERROUT(ENETDOWN);
 
/* Store the DLCI on the front of the packet */
alen = sc-addrlen;
if (alen == 0)
alen = 2;   /* default value for transmit */
M_PREPEND(m, alen, M_NOWAIT);
-   if (m == NULL) {
-   error = ENOBUFS;
-   goto bad;
-   }
+   if (m == NULL)
+   ERROUT(ENOBUFS);
data = mtod(m, char *);
 
/*
@@ -401,7 +397,7 @@ ngfrm_rcvdata(hook_p hook, item_p item)
NG_FWD_NEW_DATA(error, item, sc-downstream.hook, m);
return (error);
 
-bad:
+done:
NG_FREE_ITEM(item);
NG_FREE_M(m);
return (error);
@@ -422,10 +418,8 @@ ngfrm_decode(node_p node, item_p item)
struct mbuf *m;
 
NGI_GET_M(item, m);
-   if (m-m_len  4  (m = m_pullup(m, 4)) == NULL) {
-   error = ENOBUFS;
-   goto out;
-   }
+   if (m-m_len  4  (m = m_pullup(m, 4)) == NULL)
+   ERROUT(ENOBUFS);
data = mtod(m, char *);
if ((alen = sc-addrlen) == 0) {
sc-addrlen = alen = ngfrm_addrlen(data);
@@ -447,14 +441,11 @@ ngfrm_decode(node_p node, item_p item)
SHIFTIN(makeup + 3, data[3], dlci);
break;
default:
-   error = EINVAL;
-   goto out;
+   ERROUT(EINVAL);
}
 
-   if (dlci  1023) {
-   error = EINVAL;
-   goto out;
-   }
+   if (dlci  1023)
+   ERROUT(EINVAL);
ctxnum = sc-ALT[dlci];
if ((ctxnum  CTX_VALID)  sc-channel[ctxnum = CTX_VALUE].hook) {
/* Send it */
@@ -464,7 +455,7 @@ ngfrm_decode(node_p node, item_p item)
} else {
error = ENETDOWN;
}
-out:
+done:
NG_FREE_ITEM(item);
NG_FREE_M(m);
return (error);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273911 - in head: share/man/man9 sys/kern sys/powerpc/powerpc sys/sys

2014-10-31 Thread Konstantin Belousov
Author: kib
Date: Fri Oct 31 17:43:21 2014
New Revision: 273911
URL: https://svnweb.freebsd.org/changeset/base/273911

Log:
  Add type qualifier volatile to the base (userspace) address argument
  of fuword(9) and suword(9).  This makes the functions type-compatible
  with volatile objects and does not require devolatile force, e.g. in
  kern_umtx.c.
  
  Requested by: bde
  Reviewed by:  jhb
  Sponsored by: The FreeBSD Foundation
  MFC after:3 weeks

Modified:
  head/share/man/man9/fetch.9
  head/share/man/man9/store.9
  head/sys/kern/kern_umtx.c
  head/sys/kern/subr_uio.c
  head/sys/powerpc/powerpc/copyinout.c
  head/sys/sys/systm.h

Modified: head/share/man/man9/fetch.9
==
--- head/share/man/man9/fetch.9 Fri Oct 31 16:00:45 2014(r273910)
+++ head/share/man/man9/fetch.9 Fri Oct 31 17:43:21 2014(r273911)
@@ -34,7 +34,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd October 21, 2014
+.Dd October 29, 2014
 .Dt FETCH 9
 .Os
 .Sh NAME
@@ -53,21 +53,21 @@
 .In sys/types.h
 .In sys/systm.h
 .Ft int
-.Fn fubyte const void *base
+.Fn fubyte volatile const void *base
 .Ft long
-.Fn fuword const void *base
+.Fn fuword volatile const void *base
 .Ft int
-.Fn fuword16 void *base
+.Fn fuword16 volatile const void *base
 .Ft int32_t
-.Fn fuword32 const void *base
+.Fn fuword32 volatile const void *base
 .Ft int64_t
-.Fn fuword64 const void *base
+.Fn fuword64 volatile const void *base
 .Ft long
-.Fn fueword const void *base long *val
+.Fn fueword volatile const void *base long *val
 .Ft int32_t
-.Fn fueword32 const void *base int32_t *val
+.Fn fueword32 volatile const void *base int32_t *val
 .Ft int64_t
-.Fn fueword64 const void *base int64_t *val
+.Fn fueword64 volatile const void *base int64_t *val
 .In sys/resourcevar.h
 .Ft int
 .Fn fuswintr void *base

Modified: head/share/man/man9/store.9
==
--- head/share/man/man9/store.9 Fri Oct 31 16:00:45 2014(r273910)
+++ head/share/man/man9/store.9 Fri Oct 31 17:43:21 2014(r273911)
@@ -34,7 +34,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd October 5, 2009
+.Dd October 29, 2014
 .Dt STORE 9
 .Os
 .Sh NAME
@@ -48,15 +48,15 @@
 .In sys/time.h
 .In sys/systm.h
 .Ft int
-.Fn subyte void *base int byte
+.Fn subyte volatile void *base int byte
 .Ft int
-.Fn suword void *base long word
+.Fn suword volatile void *base long word
 .Ft int
-.Fn suword16 void *base int word
+.Fn suword16 volatile void *base int word
 .Ft int
-.Fn suword32 void *base int32_t word
+.Fn suword32 volatile void *base int32_t word
 .Ft int
-.Fn suword64 void *base int64_t word
+.Fn suword64 volatile void *base int64_t word
 .In sys/resourcevar.h
 .Ft int
 .Fn suswintr void *base int word
@@ -64,6 +64,8 @@
 The
 .Nm
 functions are designed to copy small amounts of data to user-space.
+If write is successful, it is performed atomically.
+The data written must be naturally aligned.
 .Pp
 The
 .Nm

Modified: head/sys/kern/kern_umtx.c
==
--- head/sys/kern/kern_umtx.c   Fri Oct 31 16:00:45 2014(r273910)
+++ head/sys/kern/kern_umtx.c   Fri Oct 31 17:43:21 2014(r273911)
@@ -942,7 +942,7 @@ do_lock_normal(struct thread *td, struct
 * can fault on any access.
 */
for (;;) {
-   rv = fueword32(__DEVOLATILE(void *, m-m_owner), owner);
+   rv = fueword32(m-m_owner, owner);
if (rv == -1)
return (EFAULT);
if (mode == _UMUTEX_WAIT) {
@@ -1057,7 +1057,7 @@ do_unlock_normal(struct thread *td, stru
/*
 * Make sure we own this mtx.
 */
-   error = fueword32(__DEVOLATILE(uint32_t *, m-m_owner), owner);
+   error = fueword32(m-m_owner, owner);
if (error == -1)
return (EFAULT);
 
@@ -1115,7 +1115,7 @@ do_wake_umutex(struct thread *td, struct
int error;
int count;
 
-   error = fueword32(__DEVOLATILE(uint32_t *, m-m_owner), owner);
+   error = fueword32(m-m_owner, owner);
if (error == -1)
return (EFAULT);
 
@@ -1192,8 +1192,7 @@ do_wake2_umutex(struct thread *td, struc
 * any memory.
 */
if (count  1) {
-   error = fueword32(__DEVOLATILE(uint32_t *, m-m_owner),
-   owner);
+   error = fueword32(m-m_owner, owner);
if (error == -1)
error = EFAULT;
while (error == 0  (owner  UMUTEX_CONTESTED) == 0) {
@@ -1211,8 +1210,7 @@ do_wake2_umutex(struct thread *td, struc
break;
}
} else if (count == 1) {
-   error = fueword32(__DEVOLATILE(uint32_t *, m-m_owner),
-   owner);
+   error = fueword32(m-m_owner, owner);
if (error == -1)
error = 

svn commit: r273913 - head/sys/boot/fdt

2014-10-31 Thread Andrew Turner
Author: andrew
Date: Fri Oct 31 18:20:39 2014
New Revision: 273913
URL: https://svnweb.freebsd.org/changeset/base/273913

Log:
  Clean up the types of a few strings to make them const when they are never
  written to.

Modified:
  head/sys/boot/fdt/fdt_loader_cmd.c

Modified: head/sys/boot/fdt/fdt_loader_cmd.c
==
--- head/sys/boot/fdt/fdt_loader_cmd.c  Fri Oct 31 18:18:04 2014
(r273912)
+++ head/sys/boot/fdt/fdt_loader_cmd.c  Fri Oct 31 18:20:39 2014
(r273913)
@@ -364,11 +364,11 @@ fdt_setup_fdtp()
 (cellbuf), (lim), (cellsize), 16);
 
 static int
-_fdt_strtovect(char *str, void *cellbuf, int lim, unsigned char cellsize,
+_fdt_strtovect(const char *str, void *cellbuf, int lim, unsigned char cellsize,
 uint8_t base)
 {
-   char *buf = str;
-   char *end = str + strlen(str) - 2;
+   const char *buf = str;
+   const char *end = str + strlen(str) - 2;
uint32_t *u32buf = NULL;
uint8_t *u8buf = NULL;
int cnt = 0;
@@ -411,7 +411,8 @@ _fdt_strtovect(char *str, void *cellbuf,
 static void
 fixup_ethernet(const char *env, char *ethstr, int *eth_no, int len)
 {
-   char *end, *str;
+   const char *str;
+   char *end;
uint8_t tmp_addr[6];
int i, n;
 
@@ -1347,7 +1348,7 @@ static int
 fdt_modprop(int nodeoff, char *propname, void *value, char mode)
 {
uint32_t cells[100];
-   char *buf;
+   const char *buf;
int len, rv;
const struct fdt_property *p;
 
@@ -1365,7 +1366,7 @@ fdt_modprop(int nodeoff, char *propname,
}
len = strlen(value);
rv = 0;
-   buf = (char *)value;
+   buf = value;
 
switch (*buf) {
case '':
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273914 - head/sys/boot/fdt

2014-10-31 Thread Andrew Turner
Author: andrew
Date: Fri Oct 31 18:35:03 2014
New Revision: 273914
URL: https://svnweb.freebsd.org/changeset/base/273914

Log:
  The command name is a constant, use the correct type.
  
  MFC after:1 week

Modified:
  head/sys/boot/fdt/fdt_loader_cmd.c

Modified: head/sys/boot/fdt/fdt_loader_cmd.c
==
--- head/sys/boot/fdt/fdt_loader_cmd.c  Fri Oct 31 18:20:39 2014
(r273913)
+++ head/sys/boot/fdt/fdt_loader_cmd.c  Fri Oct 31 18:35:03 2014
(r273914)
@@ -93,9 +93,9 @@ static int fdt_cmd_mres(int argc, char *
 typedef int cmdf_t(int, char *[]);
 
 struct cmdtab {
-   char*name;
-   cmdf_t  *handler;
-   int flags;
+   const char  *name;
+   cmdf_t  *handler;
+   int flags;
 };
 
 static const struct cmdtab commands[] = {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273917 - head/sys/dev/gpio

2014-10-31 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Oct 31 19:15:14 2014
New Revision: 273917
URL: https://svnweb.freebsd.org/changeset/base/273917

Log:
  Fix the gpiobus locking by using a more sane model where it isn't necessary
  hold the gpiobus lock between the gpio calls.
  
  gpiobus_acquire_lock() now accepts a third parameter which tells gpiobus
  what to do when the bus is already busy.
  
  When GPIOBUS_WAIT wait is used, the calling thread will be put to sleep
  until the bus became free.
  
  With GPIOBUS_DONTWAIT the calling thread will receive EWOULDBLOCK right
  away and then it can act upon.
  
  This fixes the gpioiic(4) locking issues that arises when doing multiple
  concurrent access on the bus.

Modified:
  head/sys/dev/gpio/gpiobus.c
  head/sys/dev/gpio/gpiobus_if.m
  head/sys/dev/gpio/gpiobusvar.h
  head/sys/dev/gpio/gpioiic.c
  head/sys/dev/gpio/gpioled.c

Modified: head/sys/dev/gpio/gpiobus.c
==
--- head/sys/dev/gpio/gpiobus.c Fri Oct 31 18:53:16 2014(r273916)
+++ head/sys/dev/gpio/gpiobus.c Fri Oct 31 19:15:14 2014(r273917)
@@ -53,9 +53,7 @@ static void gpiobus_hinted_child(device_
 /*
  * GPIOBUS interface
  */
-static void gpiobus_lock_bus(device_t);
-static void gpiobus_unlock_bus(device_t);
-static void gpiobus_acquire_bus(device_t, device_t);
+static int gpiobus_acquire_bus(device_t, device_t, int);
 static void gpiobus_release_bus(device_t, device_t);
 static int gpiobus_pin_setflags(device_t, device_t, uint32_t, uint32_t);
 static int gpiobus_pin_getflags(device_t, device_t, uint32_t, uint32_t*);
@@ -326,37 +324,26 @@ gpiobus_hinted_child(device_t bus, const
device_delete_child(bus, child);
 }
 
-static void
-gpiobus_lock_bus(device_t busdev)
+static int
+gpiobus_acquire_bus(device_t busdev, device_t child, int how)
 {
struct gpiobus_softc *sc;
 
sc = device_get_softc(busdev);
GPIOBUS_ASSERT_UNLOCKED(sc);
GPIOBUS_LOCK(sc);
-}
-
-static void
-gpiobus_unlock_bus(device_t busdev)
-{
-   struct gpiobus_softc *sc;
-
-   sc = device_get_softc(busdev);
-   GPIOBUS_ASSERT_LOCKED(sc);
+   if (sc-sc_owner != NULL) {
+   if (how == GPIOBUS_DONTWAIT) {
+   GPIOBUS_UNLOCK(sc);
+   return (EWOULDBLOCK);
+   }
+   while (sc-sc_owner != NULL)
+   mtx_sleep(sc, sc-sc_mtx, 0, gpiobuswait, 0);
+   }
+   sc-sc_owner = child;
GPIOBUS_UNLOCK(sc);
-}
 
-static void
-gpiobus_acquire_bus(device_t busdev, device_t child)
-{
-   struct gpiobus_softc *sc;
-
-   sc = device_get_softc(busdev);
-   GPIOBUS_ASSERT_LOCKED(sc);
-
-   if (sc-sc_owner)
-   panic(gpiobus: cannot serialize the access to device.);
-   sc-sc_owner = child;
+   return (0);
 }
 
 static void
@@ -365,14 +352,15 @@ gpiobus_release_bus(device_t busdev, dev
struct gpiobus_softc *sc;
 
sc = device_get_softc(busdev);
-   GPIOBUS_ASSERT_LOCKED(sc);
-
-   if (!sc-sc_owner)
+   GPIOBUS_ASSERT_UNLOCKED(sc);
+   GPIOBUS_LOCK(sc);
+   if (sc-sc_owner == NULL)
panic(gpiobus: releasing unowned bus.);
if (sc-sc_owner != child)
panic(gpiobus: you don't own the bus. game over.);
-
sc-sc_owner = NULL;
+   wakeup(sc);
+   GPIOBUS_UNLOCK(sc);
 }
 
 static int
@@ -469,8 +457,6 @@ static device_method_t gpiobus_methods[]
DEVMETHOD(bus_hinted_child, gpiobus_hinted_child),
 
/* GPIO protocol */
-   DEVMETHOD(gpiobus_lock_bus, gpiobus_lock_bus),
-   DEVMETHOD(gpiobus_unlock_bus,   gpiobus_unlock_bus),
DEVMETHOD(gpiobus_acquire_bus,  gpiobus_acquire_bus),
DEVMETHOD(gpiobus_release_bus,  gpiobus_release_bus),
DEVMETHOD(gpiobus_pin_getflags, gpiobus_pin_getflags),

Modified: head/sys/dev/gpio/gpiobus_if.m
==
--- head/sys/dev/gpio/gpiobus_if.m  Fri Oct 31 18:53:16 2014
(r273916)
+++ head/sys/dev/gpio/gpiobus_if.m  Fri Oct 31 19:15:14 2014
(r273917)
@@ -32,25 +32,12 @@
 INTERFACE gpiobus;
 
 #
-# Lock the gpio bus
-#
-METHOD void lock_bus {
-   device_t busdev;
-};
-
-#
-# Unlock the gpio bus
-#
-METHOD void unlock_bus {
-   device_t busdev;
-};
-
-#
 # Dedicate the gpio bus control for a child
 #
-METHOD void acquire_bus {
+METHOD int acquire_bus {
device_t busdev;
device_t dev;
+   int how;
 };
 
 #

Modified: head/sys/dev/gpio/gpiobusvar.h
==
--- head/sys/dev/gpio/gpiobusvar.h  Fri Oct 31 18:53:16 2014
(r273916)
+++ head/sys/dev/gpio/gpiobusvar.h  Fri Oct 31 19:15:14 2014
(r273917)
@@ -56,6 +56,9 @@
 #defineGPIOBUS_ASSERT_LOCKED(_sc) mtx_assert(_sc-sc_mtx, MA_OWNED)
 #define

svn commit: r273918 - head/sys/cam/ctl

2014-10-31 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri Oct 31 19:26:12 2014
New Revision: 273918
URL: https://svnweb.freebsd.org/changeset/base/273918

Log:
  Change the default log level for iSCSI target from 3 to 1.  It should
  have been 1 from the beginning; not sure how it ended up at 3.
  
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/cam/ctl/ctl_frontend_iscsi.c

Modified: head/sys/cam/ctl/ctl_frontend_iscsi.c
==
--- head/sys/cam/ctl/ctl_frontend_iscsi.c   Fri Oct 31 19:15:14 2014
(r273917)
+++ head/sys/cam/ctl/ctl_frontend_iscsi.c   Fri Oct 31 19:26:12 2014
(r273918)
@@ -84,7 +84,7 @@ static uma_zone_t cfiscsi_data_wait_zone
 
 SYSCTL_NODE(_kern_cam_ctl, OID_AUTO, iscsi, CTLFLAG_RD, 0,
 CAM Target Layer iSCSI Frontend);
-static int debug = 3;
+static int debug = 1;
 SYSCTL_INT(_kern_cam_ctl_iscsi, OID_AUTO, debug, CTLFLAG_RWTUN,
 debug, 1, Enable debug messages);
 static int ping_timeout = 5;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r273872 - in head: etc/defaults etc/rc.d libexec/save-entropy share/examples/kld/random_adaptor sys/conf sys/dev/glxsb sys/dev/random sys/kern sys/modules sys/modules/padlock_rng sys/m

2014-10-31 Thread Garrett Cooper
On Oct 30, 2014, at 14:21, Mark Murray ma...@freebsd.org wrote:

 Author: markm
 Date: Thu Oct 30 21:21:53 2014
 New Revision: 273872
 URL: https://svnweb.freebsd.org/changeset/base/273872
 
 Log:
  This is the much-discussed major upgrade to the random(4) device, known to 
 you all as /dev/random.
 
  This code has had an extensive rewrite and a good series of reviews, both by 
 the author and other parties. This means a lot of code has been simplified. 
 Pluggable structures for high-rate entropy generators are available, and it 
 is most definitely not the case that /dev/random can be driven by only a 
 hardware souce any more. This has been designed out of the device. Hardware 
 sources are stirred into the CSPRNG (Yarrow, Fortuna) like any other entropy 
 source. Pluggable modules may be written by third parties for additional 
 sources.
 
  The harvesting structures and consequently the locking have been simplified. 
 Entropy harvesting is done in a more general way (the documentation for this 
 will follow). There is some GREAT entropy to be had in the UMA allocator, but 
 it is disabled for now as messing with that is likely to annoy many people.
 
  The venerable (but effective) Yarrow algorithm, which is no longer supported 
 by its authors now has an alternative, Fortuna. For now, Yarrow is retained 
 as the default algorithm, but this may be changed using a kernel option. It 
 is intended to make Fortuna the default algorithm for 11.0. Interested 
 parties are encouraged to read ISBN 978-0-470-47424-2 Cryptography 
 Engineering By Ferguson, Schneier and Kohno for Fortuna's gory details. 
 Heck, read it anyway.
 
  Many thanks to Arthur Mesh who did early grunt work, and who got caught in 
 the crossfire rather more than he deserved to.
 
  My thanks also to folks who helped me thresh this out on whiteboards and in 
 the odd Hallway track, or otherwise.
 
  My Nomex pants are on. Let the feedback commence!
 
  Reviewed by: trasz,des(partial),imp(partial?),rwatson(partial?)
  Approved by: so(des)

Hi Mark,

Could you please add an UPDATING entry for this? Some users (like me) who do 
make installworld from old kernels are experiencing issues (some dealing with 
filesystem corruption). Please see this thread on -current@ for more details: 
https://lists.freebsd.org/pipermail/freebsd-current/2014-October/053039.html

This also should have had “Relnotes: yes” in the commit message because this 
deserves to be put in the release notes for 11.0

Thanks!


signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: svn commit: r273734 - head/bin/dd

2014-10-31 Thread Garrett Cooper
On Oct 28, 2014, at 4:33, Bruce Evans b...@optusnet.com.au wrote:

 On Tue, 28 Oct 2014, [utf-8] Dag-Erling Smørgrav wrote:
 
 Bruce Evans b...@optusnet.com.au writes:
 Dag-Erling Smørgrav d...@des.no writes:
 This is a bug on all platforms, and both clang and (recent) gcc
 should complain about it.  That printf() call will print garbage.
 No, this is only a bug on 32-bit arches.  The is is SSIZE_MAX.
 
 If you mean it only has consequences on 32-bit arches, then I agree -
 but it is still a bug to pass an int to %jd.
 
 This is machine-dependent.  intmax_t may be int.  The only requirement
 on intmax_t is that it can represent any value of any signed integer
 type.  This is possible if the largest integer type is 64 bits (the
 smallest permitted largest type) and int is also 64 bits (and there
 are no complications for padding bits).  intmax_t can even be signed
 char if that is wide enough (not in POSIX starting 10-15 years ago,
 since signed char is now required to be 8 bits.  It is weird for
 intmax_t to have the lowest rank (not counting Bool), but FreeBSD uses
 this loophole to make it have second highest rank on 64-bit arches.

Indeed. For some giggles, look at this bug: 
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=191674 (printf(%tu, 
(intmax_t)-1) returns UINT64_MAX on i386, not UINT32_MAX”).
Cheers,


signature.asc
Description: Message signed with OpenPGP using GPGMail


svn commit: r273919 - head/etc/rc.d

2014-10-31 Thread Xin LI
Author: delphij
Date: Fri Oct 31 22:20:27 2014
New Revision: 273919
URL: https://svnweb.freebsd.org/changeset/base/273919

Log:
  rc.d/geli should not depend on random, as the attach functionality
  do not require additional entropy to function.
  
  It would create a circular dependency (not immediately obvious:
  geli provides 'disks' and requires 'random' as of r273872,
  'random' requires 'FILESYSTEMS', 'FILESYSTEMS' requires 'root',
  'root' requires 'swap', and finally 'swap' requires 'disk').

Modified:
  head/etc/rc.d/geli

Modified: head/etc/rc.d/geli
==
--- head/etc/rc.d/geli  Fri Oct 31 19:26:12 2014(r273918)
+++ head/etc/rc.d/geli  Fri Oct 31 22:20:27 2014(r273919)
@@ -28,7 +28,6 @@
 #
 
 # PROVIDE: disks
-# REQUIRE: random
 # KEYWORD: nojail
 
 . /etc/rc.subr
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273920 - in head/bin/sh: . tests/expansion

2014-10-31 Thread Jilles Tjoelker
Author: jilles
Date: Fri Oct 31 22:28:10 2014
New Revision: 273920
URL: https://svnweb.freebsd.org/changeset/base/273920

Log:
  sh: Fix corruption of CTL* bytes in positional parameters in redirection.
  
  EXP_REDIR was not being checked for while expanding positional parameters in
  redirection, so CTL* bytes were not being prefixed where they should be.
  
  MFC after:1 week

Added:
  head/bin/sh/tests/expansion/redir1.0   (contents, props changed)
Modified:
  head/bin/sh/expand.c
  head/bin/sh/tests/expansion/Makefile

Modified: head/bin/sh/expand.c
==
--- head/bin/sh/expand.cFri Oct 31 22:20:27 2014(r273919)
+++ head/bin/sh/expand.cFri Oct 31 22:28:10 2014(r273920)
@@ -862,7 +862,7 @@ varisset(const char *name, int nulok)
 static void
 strtodest(const char *p, int flag, int subtype, int quoted)
 {
-   if (flag  (EXP_FULL | EXP_CASE)  subtype != VSLENGTH)
+   if (flag  (EXP_FULL | EXP_CASE | EXP_REDIR)  subtype != VSLENGTH)
STPUTS_QUOTES(p, quoted ? DQSYNTAX : BASESYNTAX, expdest);
else
STPUTS(p, expdest);

Modified: head/bin/sh/tests/expansion/Makefile
==
--- head/bin/sh/tests/expansion/MakefileFri Oct 31 22:20:27 2014
(r273919)
+++ head/bin/sh/tests/expansion/MakefileFri Oct 31 22:28:10 2014
(r273920)
@@ -72,6 +72,7 @@ FILES+=   plus-minus7.0
 FILES+=plus-minus8.0
 FILES+=question1.0
 FILES+=readonly1.0
+FILES+=redir1.0
 FILES+=set-u1.0
 FILES+=set-u2.0
 FILES+=set-u3.0

Added: head/bin/sh/tests/expansion/redir1.0
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/bin/sh/tests/expansion/redir1.0Fri Oct 31 22:28:10 2014
(r273920)
@@ -0,0 +1,26 @@
+# $FreeBSD$
+
+bad=0
+for i in 0 1 2 3; do
+   for j in 0 1 2 3 4 5 6 7; do
+   for k in 0 1 2 3 4 5 6 7; do
+   case $i$j$k in
+   000) continue ;;
+   esac
+   set -- $(printf \\$i$j$k@)
+   set -- ${1%@}
+   ff=
+   for f in /dev/null /dev/zero /; do
+   if [ -e $f ]  [ ! -e $f$1 ]; then
+   ff=$f
+   fi
+   done
+   [ -n $ff ] || continue
+   if { true $ff$1; } 2/dev/null; then
+   echo Bad: $i$j$k ($ff) 2
+   : $((bad += 1))
+   fi
+   done
+   done
+done
+exit $((bad ? 2 : 0))
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r273734 - head/bin/dd

2014-10-31 Thread John-Mark Gurney
Garrett Cooper wrote this message on Fri, Oct 31, 2014 at 14:30 -0700:
 On Oct 28, 2014, at 4:33, Bruce Evans b...@optusnet.com.au wrote:
 
  On Tue, 28 Oct 2014, [utf-8] Dag-Erling Smørgrav wrote:
  
  Bruce Evans b...@optusnet.com.au writes:
  Dag-Erling Smørgrav d...@des.no writes:
  This is a bug on all platforms, and both clang and (recent) gcc
  should complain about it.  That printf() call will print garbage.
  No, this is only a bug on 32-bit arches.  The is is SSIZE_MAX.
  
  If you mean it only has consequences on 32-bit arches, then I agree -
  but it is still a bug to pass an int to %jd.
  
  This is machine-dependent.  intmax_t may be int.  The only requirement
  on intmax_t is that it can represent any value of any signed integer
  type.  This is possible if the largest integer type is 64 bits (the
  smallest permitted largest type) and int is also 64 bits (and there
  are no complications for padding bits).  intmax_t can even be signed
  char if that is wide enough (not in POSIX starting 10-15 years ago,
  since signed char is now required to be 8 bits.  It is weird for
  intmax_t to have the lowest rank (not counting Bool), but FreeBSD uses
  this loophole to make it have second highest rank on 64-bit arches.
 
 Indeed. For some giggles, look at this bug: 
 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=191674 (printf(%tu, 
 (intmax_t)-1) returns UINT64_MAX on i386, not UINT32_MAX?).

That isn't surprising.. because you're sign extending -1 via intmax_t...
Even if you didn't mix unsigned and signed in your printf, and casted to
uintmax_t, you'd still get UINT64_MAX...  This is just how casting of
signed numbers work and conversion from signed to unsigned...

The bug (from 191674) is in [SU]JARG casting ptrdiff_t to intmax_t if
anywhere...  It should be cast to the correct intXX_t sized value
instead..

In the SJARG case, a simple cast to ptrdiff_t is sufficient..  Now bde
will have better idea on the UJARG case, but that needs to go be casted
to uintXX_t, and no further casting is needed...

-- 
  John-Mark Gurney  Voice: +1 415 225 5579

 All that I will do, has been done, All that I have, has not.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r273734 - head/bin/dd

2014-10-31 Thread Ian Lepore
On Fri, 2014-10-31 at 14:30 -0700, Garrett Cooper wrote:
 On Oct 28, 2014, at 4:33, Bruce Evans b...@optusnet.com.au wrote:
 
  On Tue, 28 Oct 2014, [utf-8] Dag-Erling Smørgrav wrote:
  
  Bruce Evans b...@optusnet.com.au writes:
  Dag-Erling Smørgrav d...@des.no writes:
  This is a bug on all platforms, and both clang and (recent) gcc
  should complain about it.  That printf() call will print garbage.
  No, this is only a bug on 32-bit arches.  The is is SSIZE_MAX.
  
  If you mean it only has consequences on 32-bit arches, then I agree -
  but it is still a bug to pass an int to %jd.
  
  This is machine-dependent.  intmax_t may be int.  The only requirement
  on intmax_t is that it can represent any value of any signed integer
  type.  This is possible if the largest integer type is 64 bits (the
  smallest permitted largest type) and int is also 64 bits (and there
  are no complications for padding bits).  intmax_t can even be signed
  char if that is wide enough (not in POSIX starting 10-15 years ago,
  since signed char is now required to be 8 bits.  It is weird for
  intmax_t to have the lowest rank (not counting Bool), but FreeBSD uses
  this loophole to make it have second highest rank on 64-bit arches.
 
 Indeed. For some giggles, look at this bug: 
 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=191674 (printf(%tu, 
 (intmax_t)-1) returns UINT64_MAX on i386, not UINT32_MAX”).
 Cheers,

Isn't the problem in that bug that the cast doesn't match the printf
format, and the correct code would be something like the following?

 printf(%tu, (ptrdiff_t)-1);

-- Ian


___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273922 - head/usr.sbin/bsdinstall

2014-10-31 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Oct 31 23:52:02 2014
New Revision: 273922
URL: https://svnweb.freebsd.org/changeset/base/273922

Log:
  Rewrite some of the disk setup documentation to be clearer and contain
  less obsolete information. Also move the entropy command down the list --
  the list is ordered by likelihood of use rather than alphabetically.
  
  MFC after:1 week

Modified:
  head/usr.sbin/bsdinstall/bsdinstall.8

Modified: head/usr.sbin/bsdinstall/bsdinstall.8
==
--- head/usr.sbin/bsdinstall/bsdinstall.8   Fri Oct 31 23:10:58 2014
(r273921)
+++ head/usr.sbin/bsdinstall/bsdinstall.8   Fri Oct 31 23:52:02 2014
(r273922)
@@ -25,7 +25,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd October 15, 2013
+.Dd October 31, 2014
 .Dt BSDINSTALL 8
 .Os
 .Sh NAME
@@ -73,10 +73,6 @@ targets.
 .Bl -tag -width .Cm jail Ar destination
 .It Cm auto
 Run the standard interactive installation, including disk partitioning.
-.It Cm entropy
-Reads a small amount of data from
-.Pa /dev/random
-and stores it in a file in the new system's root directory.
 .It Cm jail Ar destination
 Sets up a new chroot system at
 .Pa destination ,
@@ -119,32 +115,28 @@ If
 is set, also configures the network interfaces of the current system to match.
 .It Cm autopart
 Provides the installer's interactive guided disk partitioner for single-disk
-installations. Partitions disks, runs
-.Xr newfs 8 ,
-and writes the new system's
-.Pa fstab .
+installations. Defaults to UFS.
 .It Cm zfsboot
-Provides the installer's
-.Pq experimental
-interactive/scriptable ZFS partitioner for multi-disk installations.
+Provides an alternative ZFS-only automatic interactive disk partitioner.
 Creates a single
 .Ic zpool
-with datasets and writes to the new system's
-.Pa rc.conf ,
-.Pa loader.conf ,
+with separate datasets for
+.Pa /tmp ,
+.Pa /usr ,
+.Pa /usr/home ,
+.Pa /usr/ports ,
+.Pa /usr/src ,
 and
-.Pa fstab .
-Supports
-.Xr geli 8 ,
-.Xr gnop 8 ,
-and many other features.
+.Pa /var .
+Optionally can set up
+.Xr geli 8 
+to encrypt the disk.
 .It Cm partedit
-Provides the installer's interactive manual disk partitioner, with support
-for multi disk setups, non-UFS file systems, and manual selection of
-partition schemes. Partitions disks, runs
-.Xr newfs 8 ,
-and writes the new system's
-.Pa fstab .
+Provides the installer's interactive manual disk partitioner with an interface
+identical to
+.Xr sade 8 .
+Supports multiple disks as well as UFS, ZFS, and FAT file systems. ZFS
+is set up with one pool and dataset per partition.
 .It Cm scriptedpart Ar parameters
 Sets up disks like
 .Cm autopart
@@ -190,13 +182,19 @@ keyword causes the partition to take all
 .Ar type
 option chooses the
 .Xr gpart 8
-filesystem type (e.g. freebsd-ufs or freebsd-swap).
+filesystem type (e.g. freebsd-ufs, freebsd-zfs, or freebsd-swap).
 The optional
 .Ar mount point
 argument sets where the created partition is to be mounted in the installed
 system. As an example, a typical invocation looks like:
 .Pp
 bsdinstall scriptedpart ada0 { 20G freebsd-ufs /, 4G freebsd-swap, 20G 
freebsd-ufs /var, auto freebsd-ufs /usr }
+.Pp
+A shorter invocation to use the default partitioning (as
+.Cm autopart
+would have used) on the same disk:
+.Pp
+bsdinstall scriptedpart ada0
 .It Cm mount
 Mounts the file systems previously configured by
 .Cm autopart ,
@@ -235,6 +233,10 @@ Interactively sets the time, date, and t
 Queries the user for the system daemons to begin at system startup,
 writing the result into the new system's
 .Pa rc.conf .
+.It Cm entropy
+Reads a small amount of data from
+.Pa /dev/random
+and stores it in a file in the new system's root directory.
 .It Cm config
 Installs the configuration files destined for the new system (e.g. rc.conf
 fragments generated by
@@ -346,14 +348,14 @@ which is passed to the
 .Cm scriptedpart
 target to control disk setup.
 Alternatively,
+to use
+.Cm zfsboot
 instead of
-.Ev PARTITIONS ,
+.Cm partedit ,
 the preamble can contain the variable
 .Ev ZFSBOOT_DATASETS
-which is parsed by the
-.Pq experimental
-.Cm zfsboot
-target to control ZFS datasets/options of the boot pool setup.
+instead of 
+.Ev PARTITIONS .
 .Ss SETUP SCRIPT
 Following the preamble is an optional shell script, beginning with a #!
 declaration. This script will be run at the end of the installation process
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r273919 - head/etc/rc.d

2014-10-31 Thread Dag-Erling Smørgrav
Xin LI delp...@freebsd.org writes:
 Log:
   rc.d/geli should not depend on random, as the attach functionality
   do not require additional entropy to function.
   
   It would create a circular dependency (not immediately obvious:
   geli provides 'disks' and requires 'random' as of r273872,
   'random' requires 'FILESYSTEMS', 'FILESYSTEMS' requires 'root',
   'root' requires 'swap', and finally 'swap' requires 'disk').

My first instinct was: shouldn't rcorder warn about this?  It turns out
that it does, but in a very cryptic fashion:

des@nine ~head/etc/rc.d% svn up -qr273871  
des@nine ~head/etc/rc.d% rcorder * /dev/null
des@nine ~head/etc/rc.d% svn up -qr273872
des@nine ~head/etc/rc.d% rcorder * /dev/null
rcorder: Circular dependency on file `zfs'.
rcorder: Circular dependency on provision `mountcritlocal' in file `zfs'.
rcorder: Circular dependency on provision `mountcritlocal' in file `var'.
rcorder: Circular dependency on provision `mountcritlocal' in file 
`FILESYSTEMS'.
rcorder: Circular dependency on provision `root' in file `FILESYSTEMS'.
des@nine ~head/etc/rc.d% svn up -qr273919
des@nine ~head/etc/rc.d% rcorder * /dev/null
des@nine ~head/etc/rc.d% 

DES
-- 
Dag-Erling Smørgrav - d...@des.no
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org

Re: svn commit: r273919 - head/etc/rc.d

2014-10-31 Thread Garrett Cooper
On Oct 31, 2014, at 17:51, Dag-Erling Smørgrav d...@des.no wrote:

 Xin LI delp...@freebsd.org writes:
 Log:
  rc.d/geli should not depend on random, as the attach functionality
  do not require additional entropy to function.
 
  It would create a circular dependency (not immediately obvious:
  geli provides 'disks' and requires 'random' as of r273872,
  'random' requires 'FILESYSTEMS', 'FILESYSTEMS' requires 'root',
  'root' requires 'swap', and finally 'swap' requires 'disk').
 
 My first instinct was: shouldn't rcorder warn about this?  It turns out
 that it does, but in a very cryptic fashion:
 
 des@nine ~head/etc/rc.d% svn up -qr273871  
 des@nine ~head/etc/rc.d% rcorder * /dev/null
 des@nine ~head/etc/rc.d% svn up -qr273872
 des@nine ~head/etc/rc.d% rcorder * /dev/null
 rcorder: Circular dependency on file `zfs'.
 rcorder: Circular dependency on provision `mountcritlocal' in file `zfs'.
 rcorder: Circular dependency on provision `mountcritlocal' in file `var'.
 rcorder: Circular dependency on provision `mountcritlocal' in file 
 `FILESYSTEMS'.
 rcorder: Circular dependency on provision `root' in file `FILESYSTEMS'.
 des@nine ~head/etc/rc.d% svn up -qr273919
 des@nine ~head/etc/rc.d% rcorder * /dev/null
 des@nine ~head/etc/rc.d% 

rcorder errors are indeed cryptic/confusing. I can quickly add a testcase for 
this if you like (basically check for all the scenarios that need to be covered 
via /etc/rc). Does that sound good?
Thanks!


signature.asc
Description: Message signed with OpenPGP using GPGMail