svn commit: r212034 - head/sbin/hastd

2010-08-30 Thread Pawel Jakub Dawidek
Author: pjd
Date: Mon Aug 30 22:28:04 2010
New Revision: 212034
URL: http://svn.freebsd.org/changeset/base/212034

Log:
  Use pjdlog_exit() before fork().
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Mon Aug 30 22:26:42 2010(r212033)
+++ head/sbin/hastd/primary.c   Mon Aug 30 22:28:04 2010(r212034)
@@ -771,14 +771,14 @@ hastd_primary(struct hast_resource *res)
 */
if (proto_client("socketpair://", &res->hr_ctrl) < 0) {
KEEP_ERRNO((void)pidfile_remove(pfh));
-   primary_exit(EX_OSERR,
+   pjdlog_exit(EX_OSERR,
"Unable to create control sockets between parent and 
child");
}
 
pid = fork();
if (pid < 0) {
KEEP_ERRNO((void)pidfile_remove(pfh));
-   primary_exit(EX_TEMPFAIL, "Unable to fork");
+   pjdlog_exit(EX_TEMPFAIL, "Unable to fork");
}
 
if (pid > 0) {
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r212033 - head/sbin/hastd

2010-08-30 Thread Pawel Jakub Dawidek
Author: pjd
Date: Mon Aug 30 22:26:42 2010
New Revision: 212033
URL: http://svn.freebsd.org/changeset/base/212033

Log:
  Constify arguments we can constify.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/hast_proto.c
  head/sbin/hastd/hast_proto.h
  head/sbin/hastd/proto.c
  head/sbin/hastd/proto.h

Modified: head/sbin/hastd/hast_proto.c
==
--- head/sbin/hastd/hast_proto.cMon Aug 30 22:24:26 2010
(r212032)
+++ head/sbin/hastd/hast_proto.cMon Aug 30 22:26:42 2010
(r212033)
@@ -56,8 +56,10 @@ struct hast_main_header {
uint32_tsize;
 } __packed;
 
-typedef int hps_send_t(struct hast_resource *, struct nv *nv, void **, size_t 
*, bool *);
-typedef int hps_recv_t(struct hast_resource *, struct nv *nv, void **, size_t 
*, bool *);
+typedef int hps_send_t(const struct hast_resource *, struct nv *nv, void **,
+size_t *, bool *);
+typedef int hps_recv_t(const struct hast_resource *, struct nv *nv, void **,
+size_t *, bool *);
 
 struct hast_pipe_stage {
const char  *hps_name;
@@ -65,14 +67,14 @@ struct hast_pipe_stage {
hps_recv_t  *hps_recv;
 };
 
-static int compression_send(struct hast_resource *res, struct nv *nv,
+static int compression_send(const struct hast_resource *res, struct nv *nv,
 void **datap, size_t *sizep, bool *freedatap);
-static int compression_recv(struct hast_resource *res, struct nv *nv,
+static int compression_recv(const struct hast_resource *res, struct nv *nv,
 void **datap, size_t *sizep, bool *freedatap);
 #ifdef HAVE_CRYPTO
-static int checksum_send(struct hast_resource *res, struct nv *nv,
+static int checksum_send(const struct hast_resource *res, struct nv *nv,
 void **datap, size_t *sizep, bool *freedatap);
-static int checksum_recv(struct hast_resource *res, struct nv *nv,
+static int checksum_recv(const struct hast_resource *res, struct nv *nv,
 void **datap, size_t *sizep, bool *freedatap);
 #endif
 
@@ -84,7 +86,7 @@ static struct hast_pipe_stage pipeline[]
 };
 
 static int
-compression_send(struct hast_resource *res, struct nv *nv, void **datap,
+compression_send(const struct hast_resource *res, struct nv *nv, void **datap,
 size_t *sizep, bool *freedatap)
 {
unsigned char *newbuf;
@@ -132,7 +134,7 @@ compression_send(struct hast_resource *r
 }
 
 static int
-compression_recv(struct hast_resource *res, struct nv *nv, void **datap,
+compression_recv(const struct hast_resource *res, struct nv *nv, void **datap,
 size_t *sizep, bool *freedatap)
 {
unsigned char *newbuf;
@@ -169,7 +171,7 @@ compression_recv(struct hast_resource *r
 
 #ifdef HAVE_CRYPTO
 static int
-checksum_send(struct hast_resource *res, struct nv *nv, void **datap,
+checksum_send(const struct hast_resource *res, struct nv *nv, void **datap,
 size_t *sizep, bool *freedatap __unused)
 {
unsigned char hash[SHA256_DIGEST_LENGTH];
@@ -188,7 +190,7 @@ checksum_send(struct hast_resource *res,
 }
 
 static int
-checksum_recv(struct hast_resource *res, struct nv *nv, void **datap,
+checksum_recv(const struct hast_resource *res, struct nv *nv, void **datap,
 size_t *sizep, bool *freedatap __unused)
 {
unsigned char chash[SHA256_DIGEST_LENGTH];
@@ -236,7 +238,7 @@ checksum_recv(struct hast_resource *res,
  * There can be no data at all (data is NULL then).
  */
 int
-hast_proto_send(struct hast_resource *res, struct proto_conn *conn,
+hast_proto_send(const struct hast_resource *res, struct proto_conn *conn,
 struct nv *nv, const void *data, size_t size)
 {
struct hast_main_header hdr;
@@ -293,7 +295,7 @@ end:
 }
 
 int
-hast_proto_recv_hdr(struct proto_conn *conn, struct nv **nvp)
+hast_proto_recv_hdr(const struct proto_conn *conn, struct nv **nvp)
 {
struct hast_main_header hdr;
struct nv *nv;
@@ -335,7 +337,7 @@ fail:
 }
 
 int
-hast_proto_recv_data(struct hast_resource *res, struct proto_conn *conn,
+hast_proto_recv_data(const struct hast_resource *res, struct proto_conn *conn,
 struct nv *nv, void *data, size_t size)
 {
unsigned int ii;
@@ -384,7 +386,7 @@ if (ret < 0) printf("%s:%u %s\n", __func
 }
 
 int
-hast_proto_recv(struct hast_resource *res, struct proto_conn *conn,
+hast_proto_recv(const struct hast_resource *res, struct proto_conn *conn,
 struct nv **nvp, void *data, size_t size)
 {
struct nv *nv;

Modified: head/sbin/hastd/hast_proto.h
==
--- head/sbin/hastd/hast_proto.hMon Aug 30 22:24:26 2010
(r212032)
+++ head/sbin/hastd/hast_proto.hMon Aug 30 22:26:42 2010
(r212033)
@@ -37,12 +37,12 @@
 #include 
 #include 
 
-int hast_proto_send(struct hast_resource *res, struct proto_conn *conn,
+int hast_proto_send(const struct hast_resource *res, struct proto_

Re: svn commit: r211722 - head/cddl/lib/libzpool

2010-08-30 Thread Pawel Jakub Dawidek
On Mon, Aug 23, 2010 at 05:36:00PM -0600, M. Warner Losh wrote:
> In message: <201008232204.o7nm4upa054...@svn.freebsd.org>
> Marius Strobl  writes:
> : Author: marius
> : Date: Mon Aug 23 22:04:30 2010
> : New Revision: 211722
> : URL: http://svn.freebsd.org/changeset/base/211722
> : 
> : Log:
> :   Use real atomic operations for sparc64.
> :   
> :   MFC after:1 week
> : 
> : Modified:
> :   head/cddl/lib/libzpool/Makefile
> : 
> : Modified: head/cddl/lib/libzpool/Makefile
> : 
> ==
> : --- head/cddl/lib/libzpool/Makefile Mon Aug 23 21:40:03 2010
> (r211721)
> : +++ head/cddl/lib/libzpool/Makefile Mon Aug 23 22:04:30 2010
> (r211722)
> : @@ -11,7 +11,7 @@
> :  # LIST_SRCS
> :  .PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/os
> :  # ATOMIC_SRCS
> : -.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" || 
> ${MACHINE_ARCH} == "ia64" || ${MACHINE_ARCH} == "powerpc64"
> : +.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" || 
> ${MACHINE_ARCH} == "ia64" || ${MACHINE_ARCH} == "sparc64" || ${MACHINE_ARCH} 
> == "powerpc64"
> :  .PATH: 
> ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/atomic/${MACHINE_ARCH}
> :  ATOMIC_SRCS=   opensolaris_atomic.S
> :  .else
> 
> I find it disturbing that we have 3 or 4 copies of this code in our
> Makefiles...

Then you will like @183089 :)

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgpGokkKX3rln.pgp
Description: PGP signature


Re: svn commit: r211983 - head/sbin/hastd

2010-08-30 Thread Pawel Jakub Dawidek
On Sun, Aug 29, 2010 at 08:20:47PM -0400, Philip M. Gollucci wrote:
> On 8/29/2010 8:12 PM, Pawel Jakub Dawidek wrote:
> >Author: pjd
> >Date: Mon Aug 30 00:12:10 2010
> >New Revision: 211983
> >URL: http://svn.freebsd.org/changeset/base/211983
> >
> >Log:
> >   Execute hook when split-brain is detected.
> >
> >   MFC after:2 weeks
> >   Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com
> Do you work for them or something ?

Yes, I'm actually a co-founder.

> The site's not in english

Try "english version" in top right corner or ask:)

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgp4qC6Mx5GNS.pgp
Description: PGP signature


svn commit: r211984 - head/sbin/hastd

2010-08-29 Thread Pawel Jakub Dawidek
Author: pjd
Date: Mon Aug 30 00:31:30 2010
New Revision: 211984
URL: http://svn.freebsd.org/changeset/base/211984

Log:
  Execute hook when connection between the nodes is established or lost.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/hast.conf.5
  head/sbin/hastd/primary.c
  head/sbin/hastd/secondary.c

Modified: head/sbin/hastd/hast.conf.5
==
--- head/sbin/hastd/hast.conf.5 Mon Aug 30 00:12:10 2010(r211983)
+++ head/sbin/hastd/hast.conf.5 Mon Aug 30 00:31:30 2010(r211984)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 29, 2010
+.Dd August 30, 2010
 .Dt HAST.CONF 5
 .Os
 .Sh NAME
@@ -212,6 +212,20 @@ Execute the given program on various HAS
 Below is the list of currently implemented events and arguments the given
 program is executed with:
 .Bl -tag -width ".Ic "
+.It Ic " role   "
+.Pp
+Executed on both primary and secondary nodes when resource role is changed.
+.Pp
+.It Ic " connect "
+.Pp
+Executed on both primary and secondary nodes when connection for the given
+resource between the nodes is established.
+.Pp
+.It Ic " disconnect "
+.Pp
+Executed on both primary and secondary nodes when connection for the given
+resource between the nodes is lost.
+.Pp
 .It Ic " syncstart "
 .Pp
 Executed on primary node when synchronization process of secondary node is
@@ -228,10 +242,6 @@ Executed on primary node when synchroniz
 interrupted, most likely due to secondary node outage or connection failure
 between the nodes.
 .Pp
-.It Ic " role   "
-.Pp
-Executed on both primary and secondary nodes when resource role is changed.
-.Pp
 .It Ic " split-brain "
 .Pp
 Executed on both primary and secondary nodes when split-brain condition is

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Mon Aug 30 00:12:10 2010(r211983)
+++ head/sbin/hastd/primary.c   Mon Aug 30 00:31:30 2010(r211984)
@@ -672,6 +672,7 @@ init_remote(struct hast_resource *res, s
res->hr_remotein = in;
res->hr_remoteout = out;
}
+   hook_exec(res->hr_exec, "connect", res->hr_name, NULL);
return (true);
 close:
if (errmsg != NULL && strcmp(errmsg, "Split-brain condition!") == 0)
@@ -765,8 +766,6 @@ hastd_primary(struct hast_resource *res)
pid_t pid;
int error;
 
-   gres = res;
-
/*
 * Create communication channel between parent and child.
 */
@@ -788,6 +787,8 @@ hastd_primary(struct hast_resource *res)
return;
}
 
+   gres = res;
+
(void)pidfile_close(pfh);
hook_fini();
 
@@ -894,6 +895,8 @@ remote_close(struct hast_resource *res, 
 * Stop synchronization if in-progress.
 */
sync_stop();
+
+   hook_exec(res->hr_exec, "disconnect", res->hr_name, NULL);
 }
 
 /*

Modified: head/sbin/hastd/secondary.c
==
--- head/sbin/hastd/secondary.c Mon Aug 30 00:12:10 2010(r211983)
+++ head/sbin/hastd/secondary.c Mon Aug 30 00:31:30 2010(r211984)
@@ -74,6 +74,8 @@ struct hio {
TAILQ_ENTRY(hio) hio_next;
 };
 
+static struct hast_resource *gres;
+
 /*
  * Free list holds unused structures. When free list is empty, we have to wait
  * until some in-progress requests are freed.
@@ -360,6 +362,8 @@ hastd_secondary(struct hast_resource *re
return;
}
 
+   gres = res;
+
(void)pidfile_close(pfh);
hook_fini();
 
@@ -378,6 +382,7 @@ hastd_secondary(struct hast_resource *re
init_local(res);
init_remote(res, nvin);
init_environment();
+   hook_exec(res->hr_exec, "connect", res->hr_name, NULL);
 
error = pthread_create(&td, NULL, recv_thread, res);
assert(error == 0);
@@ -501,6 +506,19 @@ end:
return (hio->hio_error);
 }
 
+static void
+secondary_exit(int exitcode, const char *fmt, ...)
+{
+   va_list ap;
+
+   assert(exitcode != EX_OK);
+   va_start(ap, fmt);
+   pjdlogv_errno(LOG_ERR, fmt, ap);
+   va_end(ap);
+   hook_exec(gres->hr_exec, "disconnect", gres->hr_name, NULL);
+   exit(exitcode);
+}
+
 /*
  * Thread receives requests from the primary node.
  */
@@ -515,7 +533,7 @@ recv_thread(void *arg)
QUEUE_TAKE(free, hio);
pjdlog_debug(2, "recv: (%p) Got request.", hio);
if (hast_proto_recv_hdr(res->hr_remotein, &hio->hio_nv) < 0) {
-   pjdlog_exit(EX_TEMPFAIL,
+   secondary_exit(EX_TEMPFAIL,
"Unable to receive request header");
}
if (requnpack(res, hio) != 0) {
@@ -537,7 +555,7 @@ recv_thread(void *arg)
} else if (hio->

svn commit: r211983 - head/sbin/hastd

2010-08-29 Thread Pawel Jakub Dawidek
Author: pjd
Date: Mon Aug 30 00:12:10 2010
New Revision: 211983
URL: http://svn.freebsd.org/changeset/base/211983

Log:
  Execute hook when split-brain is detected.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/hast.conf.5
  head/sbin/hastd/primary.c
  head/sbin/hastd/secondary.c

Modified: head/sbin/hastd/hast.conf.5
==
--- head/sbin/hastd/hast.conf.5 Mon Aug 30 00:06:05 2010(r211982)
+++ head/sbin/hastd/hast.conf.5 Mon Aug 30 00:12:10 2010(r211983)
@@ -232,6 +232,11 @@ between the nodes.
 .Pp
 Executed on both primary and secondary nodes when resource role is changed.
 .Pp
+.It Ic " split-brain "
+.Pp
+Executed on both primary and secondary nodes when split-brain condition is
+detected.
+.Pp
 .El
 The
 .Aq path

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Mon Aug 30 00:06:05 2010(r211982)
+++ head/sbin/hastd/primary.c   Mon Aug 30 00:12:10 2010(r211983)
@@ -498,6 +498,7 @@ init_remote(struct hast_resource *res, s
assert(real_remote(res));
 
in = out = NULL;
+   errmsg = NULL;
 
/* Prepare outgoing connection with remote node. */
if (proto_client(res->hr_remoteaddr, &out) < 0) {
@@ -673,6 +674,8 @@ init_remote(struct hast_resource *res, s
}
return (true);
 close:
+   if (errmsg != NULL && strcmp(errmsg, "Split-brain condition!") == 0)
+   hook_exec(res->hr_exec, "split-brain", res->hr_name, NULL);
proto_close(out);
if (in != NULL)
proto_close(in);

Modified: head/sbin/hastd/secondary.c
==
--- head/sbin/hastd/secondary.c Mon Aug 30 00:06:05 2010(r211982)
+++ head/sbin/hastd/secondary.c Mon Aug 30 00:12:10 2010(r211983)
@@ -323,6 +323,7 @@ init_remote(struct hast_resource *res, s
if (res->hr_secondary_localcnt > res->hr_primary_remotecnt &&
 res->hr_primary_localcnt > res->hr_secondary_remotecnt) {
/* Exit on split-brain. */
+   hook_exec(res->hr_exec, "split-brain", res->hr_name, NULL);
exit(EX_CONFIG);
}
 }
@@ -373,6 +374,7 @@ hastd_secondary(struct hast_resource *re
if (proto_timeout(res->hr_remoteout, res->hr_timeout) < 0)
pjdlog_errno(LOG_WARNING, "Unable to set connection timeout");
 
+   hook_init();
init_local(res);
init_remote(res, nvin);
init_environment();
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211982 - head/sbin/hastd

2010-08-29 Thread Pawel Jakub Dawidek
Author: pjd
Date: Mon Aug 30 00:06:05 2010
New Revision: 211982
URL: http://svn.freebsd.org/changeset/base/211982

Log:
  Use sigtimedwait(2) for signals handling in primary process.
  This fixes various races and eliminates use of pthread* API in signal handler.
  
  Pointed out by:   kib
  With help from:   jilles
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Sun Aug 29 22:55:21 2010(r211981)
+++ head/sbin/hastd/primary.c   Mon Aug 30 00:06:05 2010(r211982)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -132,8 +133,6 @@ static pthread_cond_t sync_cond;
  * The lock below allows to synchornize access to remote connections.
  */
 static pthread_rwlock_t *hio_remote_lock;
-static pthread_mutex_t hio_guard_lock;
-static pthread_cond_t hio_guard_cond;
 
 /*
  * Lock to synchronize metadata updates. Also synchronize access to
@@ -152,13 +151,9 @@ static pthread_mutex_t metadata_lock;
  */
 #defineHAST_NCOMPONENTS2
 /*
- * Number of seconds to sleep between keepalive packets.
+ * Number of seconds to sleep between reconnect retries or keepalive packets.
  */
-#defineKEEPALIVE_SLEEP 10
-/*
- * Number of seconds to sleep between reconnect retries.
- */
-#defineRECONNECT_SLEEP 5
+#defineRETRY_SLEEP 10
 
 #defineISCONNECTED(res, no)\
((res)->hr_remotein != NULL && (res)->hr_remoteout != NULL)
@@ -230,7 +225,11 @@ static void *ggate_send_thread(void *arg
 static void *sync_thread(void *arg);
 static void *guard_thread(void *arg);
 
-static void sighandler(int sig);
+static void
+dummy_sighandler(int sig __unused)
+{
+   /* Nothing to do. */
+}
 
 static void
 cleanup(struct hast_resource *res)
@@ -319,6 +318,7 @@ init_environment(struct hast_resource *r
 {
struct hio *hio;
unsigned int ii, ncomps;
+   sigset_t mask;
 
/*
 * In the future it might be per-resource value.
@@ -389,8 +389,6 @@ init_environment(struct hast_resource *r
TAILQ_INIT(&hio_done_list);
mtx_init(&hio_done_list_lock);
cv_init(&hio_done_list_cond);
-   mtx_init(&hio_guard_lock);
-   cv_init(&hio_guard_cond);
mtx_init(&metadata_lock);
 
/*
@@ -431,10 +429,10 @@ init_environment(struct hast_resource *r
/*
 * Turn on signals handling.
 */
-   signal(SIGINT, sighandler);
-   signal(SIGTERM, sighandler);
-   signal(SIGHUP, sighandler);
-   signal(SIGCHLD, sighandler);
+   /* Because SIGCHLD is ignored by default, setup dummy handler for it. */
+   PJDLOG_VERIFY(signal(SIGCHLD, dummy_sighandler) != SIG_ERR);
+   PJDLOG_VERIFY(sigfillset(&mask) == 0);
+   PJDLOG_VERIFY(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);
 }
 
 static void
@@ -893,16 +891,6 @@ remote_close(struct hast_resource *res, 
 * Stop synchronization if in-progress.
 */
sync_stop();
-
-   /*
-* Wake up guard thread (if we are not called from within guard thread),
-* so it can immediately start reconnect.
-*/
-   if (!mtx_owned(&hio_guard_lock)) {
-   mtx_lock(&hio_guard_lock);
-   cv_signal(&hio_guard_cond);
-   mtx_unlock(&hio_guard_lock);
-   }
 }
 
 /*
@@ -1734,35 +1722,6 @@ free_queue:
 }
 
 static void
-sighandler(int sig)
-{
-   bool unlock;
-
-   switch (sig) {
-   case SIGINT:
-   case SIGTERM:
-   sigexit_received = true;
-   break;
-   case SIGHUP:
-   sighup_received = true;
-   break;
-   case SIGCHLD:
-   sigchld_received = true;
-   break;
-   default:
-   assert(!"invalid condition");
-   }
-   /*
-* Racy, but if we cannot obtain hio_guard_lock here, we don't
-* want to risk deadlock.
-*/
-   unlock = mtx_trylock(&hio_guard_lock);
-   cv_signal(&hio_guard_cond);
-   if (unlock)
-   mtx_unlock(&hio_guard_lock);
-}
-
-static void
 config_reload(void)
 {
struct hastd_config *newcfg;
@@ -1973,48 +1932,48 @@ guard_thread(void *arg)
 {
struct hast_resource *res = arg;
unsigned int ii, ncomps;
+   struct timespec timeout;
time_t lastcheck, now;
-   int timeout;
+   sigset_t mask;
+   int signo;
 
ncomps = HAST_NCOMPONENTS;
lastcheck = time(NULL);
 
+   PJDLOG_VERIFY(sigemptyset(&mask) == 0);
+   PJDLOG_VERIFY(sigaddset(&mask, SIGHUP) == 0);
+   PJDLOG_VERIFY(sigaddset(&mask, SIGINT) == 0);
+   PJDLOG_VERIFY(sigaddset(&mask, SIGTERM) == 0);
+   PJDLOG_VERIFY(sigaddset(&mask, SIGCHL

svn commit: r211981 - head/sbin/hastd

2010-08-29 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Aug 29 22:55:21 2010
New Revision: 211981
URL: http://svn.freebsd.org/changeset/base/211981

Log:
  - Move functionality responsible for checking one connection to separate
function to make code more readable.
  - Be sure not to reconnect too often in case of signal delivery, etc.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Sun Aug 29 22:22:15 2010(r211980)
+++ head/sbin/hastd/primary.c   Sun Aug 29 22:55:21 2010(r211981)
@@ -1903,6 +1903,67 @@ keepalive_send(struct hast_resource *res
pjdlog_debug(2, "keepalive_send: Request sent.");
 }
 
+static void
+guard_one(struct hast_resource *res, unsigned int ncomp)
+{
+   struct proto_conn *in, *out;
+
+   if (!ISREMOTE(ncomp))
+   return;
+
+   rw_rlock(&hio_remote_lock[ncomp]);
+
+   if (!real_remote(res)) {
+   rw_unlock(&hio_remote_lock[ncomp]);
+   return;
+   }
+
+   if (ISCONNECTED(res, ncomp)) {
+   assert(res->hr_remotein != NULL);
+   assert(res->hr_remoteout != NULL);
+   keepalive_send(res, ncomp);
+   }
+
+   if (ISCONNECTED(res, ncomp)) {
+   assert(res->hr_remotein != NULL);
+   assert(res->hr_remoteout != NULL);
+   rw_unlock(&hio_remote_lock[ncomp]);
+   pjdlog_debug(2, "remote_guard: Connection to %s is ok.",
+   res->hr_remoteaddr);
+   return;
+   }
+
+   assert(res->hr_remotein == NULL);
+   assert(res->hr_remoteout == NULL);
+   /*
+* Upgrade the lock. It doesn't have to be atomic as no other thread
+* can change connection status from disconnected to connected.
+*/
+   rw_unlock(&hio_remote_lock[ncomp]);
+   pjdlog_debug(2, "remote_guard: Reconnecting to %s.",
+   res->hr_remoteaddr);
+   in = out = NULL;
+   if (init_remote(res, &in, &out)) {
+   rw_wlock(&hio_remote_lock[ncomp]);
+   assert(res->hr_remotein == NULL);
+   assert(res->hr_remoteout == NULL);
+   assert(in != NULL && out != NULL);
+   res->hr_remotein = in;
+   res->hr_remoteout = out;
+   rw_unlock(&hio_remote_lock[ncomp]);
+   pjdlog_info("Successfully reconnected to %s.",
+   res->hr_remoteaddr);
+   sync_start();
+   } else {
+   /* Both connections should be NULL. */
+   assert(res->hr_remotein == NULL);
+   assert(res->hr_remoteout == NULL);
+   assert(in == NULL && out == NULL);
+   pjdlog_debug(2, "remote_guard: Reconnect to %s failed.",
+   res->hr_remoteaddr);
+   }
+}
+
 /*
  * Thread guards remote connections and reconnects when needed, handles
  * signals, etc.
@@ -1911,11 +1972,12 @@ static void *
 guard_thread(void *arg)
 {
struct hast_resource *res = arg;
-   struct proto_conn *in, *out;
unsigned int ii, ncomps;
+   time_t lastcheck, now;
int timeout;
 
ncomps = HAST_NCOMPONENTS;
+   lastcheck = time(NULL);
 
for (;;) {
if (sigexit_received) {
@@ -1930,63 +1992,24 @@ guard_thread(void *arg)
if (sigchld_received)
sigchld_received = false;
 
-   timeout = KEEPALIVE_SLEEP;
pjdlog_debug(2, "remote_guard: Checking connections.");
mtx_lock(&hio_guard_lock);
+   timeout = KEEPALIVE_SLEEP;
for (ii = 0; ii < ncomps; ii++) {
-   if (!ISREMOTE(ii))
-   continue;
-   rw_rlock(&hio_remote_lock[ii]);
-   if (ISCONNECTED(res, ii)) {
-   assert(res->hr_remotein != NULL);
-   assert(res->hr_remoteout != NULL);
-   keepalive_send(res, ii);
+   if (!ISCONNECTED(res, ii)) {
+   timeout = RECONNECT_SLEEP;
+   break;
}
-   if (ISCONNECTED(res, ii)) {
-   assert(res->hr_remotein != NULL);
-   assert(res->hr_remoteout != NULL);
-   rw_unlock(&hio_remote_lock[ii]);
-   pjdlog_debug(2,
-   "remote_guard: Connection to %s is ok.",
-   res->hr_remoteaddr);
-   } else if (real_remote(res)) {
-   assert(res->hr_remotein == NULL);
-   assert(res-

svn commit: r211979 - head/sbin/hastd

2010-08-29 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Aug 29 22:17:53 2010
New Revision: 211979
URL: http://svn.freebsd.org/changeset/base/211979

Log:
  Disconnect after logging errors.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Sun Aug 29 21:42:45 2010(r211978)
+++ head/sbin/hastd/primary.c   Sun Aug 29 22:17:53 2010(r211979)
@@ -1234,12 +1234,12 @@ remote_send_thread(void *arg)
data != NULL ? length : 0) < 0) {
hio->hio_errors[ncomp] = errno;
rw_unlock(&hio_remote_lock[ncomp]);
-   remote_close(res, ncomp);
pjdlog_debug(2,
"remote_send: (%p) Unable to send request.", hio);
reqlog(LOG_ERR, 0, ggio,
"Unable to send request (%s): ",
strerror(hio->hio_errors[ncomp]));
+   remote_close(res, ncomp);
/*
 * Take request back from the receive queue and move
 * it immediately to the done queue.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211977 - head/sbin/hastd

2010-08-29 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Aug 29 21:41:53 2010
New Revision: 211977
URL: http://svn.freebsd.org/changeset/base/211977

Log:
  Allow to run hooks from the main hastd process.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/hastd.c
  head/sbin/hastd/primary.c
  head/sbin/hastd/secondary.c

Modified: head/sbin/hastd/hastd.c
==
--- head/sbin/hastd/hastd.c Sun Aug 29 21:39:49 2010(r211976)
+++ head/sbin/hastd/hastd.c Sun Aug 29 21:41:53 2010(r211977)
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
 #include "hast.h"
 #include "hast_proto.h"
 #include "hastd.h"
+#include "hooks.h"
 #include "subr.h"
 
 /* Path to configuration file. */
@@ -70,6 +71,9 @@ bool sigexit_received = false;
 /* PID file handle. */
 struct pidfh *pfh;
 
+/* How often check for hooks running for too long. */
+#defineREPORT_INTERVAL 10
+
 static void
 usage(void)
 {
@@ -144,8 +148,10 @@ child_exit(void)
if (res == NULL) {
/*
 * This can happen when new connection arrives and we
-* cancel child responsible for the old one.
+* cancel child responsible for the old one or if this
+* was hook which we executed.
 */
+   hook_check_one(pid, status);
continue;
}
pjdlog_prefix_set("[%s] (%s) ", res->hr_name,
@@ -620,6 +626,10 @@ main_loop(void)
 {
fd_set rfds, wfds;
int cfd, lfd, maxfd, ret;
+   struct timeval timeout;
+
+   timeout.tv_sec = REPORT_INTERVAL;
+   timeout.tv_usec = 0;
 
for (;;) {
if (sigexit_received) {
@@ -648,8 +658,10 @@ main_loop(void)
FD_SET(cfd, &wfds);
FD_SET(lfd, &wfds);
 
-   ret = select(maxfd + 1, &rfds, &wfds, NULL, NULL);
-   if (ret == -1) {
+   ret = select(maxfd + 1, &rfds, &wfds, NULL, &timeout);
+   if (ret == 0)
+   hook_check(false);
+   else if (ret == -1) {
if (errno == EINTR)
continue;
KEEP_ERRNO((void)pidfile_remove(pfh));
@@ -754,6 +766,8 @@ main(int argc, char *argv[])
}
}
 
+   hook_init();
+
main_loop();
 
exit(0);

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Sun Aug 29 21:39:49 2010(r211976)
+++ head/sbin/hastd/primary.c   Sun Aug 29 21:41:53 2010(r211977)
@@ -786,7 +786,9 @@ hastd_primary(struct hast_resource *res)
res->hr_workerpid = pid;
return;
}
+
(void)pidfile_close(pfh);
+   hook_fini();
 
setproctitle("%s (primary)", res->hr_name);
 

Modified: head/sbin/hastd/secondary.c
==
--- head/sbin/hastd/secondary.c Sun Aug 29 21:39:49 2010(r211976)
+++ head/sbin/hastd/secondary.c Sun Aug 29 21:41:53 2010(r211977)
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
 #include "hast.h"
 #include "hast_proto.h"
 #include "hastd.h"
+#include "hooks.h"
 #include "metadata.h"
 #include "proto.h"
 #include "subr.h"
@@ -357,7 +358,9 @@ hastd_secondary(struct hast_resource *re
res->hr_workerpid = pid;
return;
}
+
(void)pidfile_close(pfh);
+   hook_fini();
 
setproctitle("%s (secondary)", res->hr_name);
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211978 - head/sbin/hastd

2010-08-29 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Aug 29 21:42:45 2010
New Revision: 211978
URL: http://svn.freebsd.org/changeset/base/211978

Log:
  - Call hook on role change.
  - Document new event.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/control.c
  head/sbin/hastd/hast.conf.5

Modified: head/sbin/hastd/control.c
==
--- head/sbin/hastd/control.c   Sun Aug 29 21:41:53 2010(r211977)
+++ head/sbin/hastd/control.c   Sun Aug 29 21:42:45 2010(r211978)
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include "hast.h"
 #include "hastd.h"
 #include "hast_proto.h"
+#include "hooks.h"
 #include "nv.h"
 #include "pjdlog.h"
 #include "proto.h"
@@ -54,6 +55,7 @@ static void
 control_set_role_common(struct hastd_config *cfg, struct nv *nvout,
 uint8_t role, struct hast_resource *res, const char *name, unsigned int no)
 {
+   int oldrole;
 
/* Name is always needed. */
if (name != NULL)
@@ -85,6 +87,7 @@ control_set_role_common(struct hastd_con
pjdlog_info("Role changed to %s.", role2str(role));
 
/* Change role to the new one. */
+   oldrole = res->hr_role;
res->hr_role = role;
pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role));
 
@@ -113,6 +116,8 @@ control_set_role_common(struct hastd_con
if (role == HAST_ROLE_PRIMARY)
hastd_primary(res);
pjdlog_prefix_set("%s", "");
+   hook_exec(res->hr_exec, "role", res->hr_name, role2str(oldrole),
+   role2str(res->hr_role), NULL);
 }
 
 void

Modified: head/sbin/hastd/hast.conf.5
==
--- head/sbin/hastd/hast.conf.5 Sun Aug 29 21:41:53 2010(r211977)
+++ head/sbin/hastd/hast.conf.5 Sun Aug 29 21:42:45 2010(r211978)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 27, 2010
+.Dd August 29, 2010
 .Dt HAST.CONF 5
 .Os
 .Sh NAME
@@ -228,6 +228,10 @@ Executed on primary node when synchroniz
 interrupted, most likely due to secondary node outage or connection failure
 between the nodes.
 .Pp
+.It Ic " role   "
+.Pp
+Executed on both primary and secondary nodes when resource role is changed.
+.Pp
 .El
 The
 .Aq path
@@ -241,6 +245,22 @@ The
 .Aq resource
 argument is resource name from the configuration file.
 .Pp
+The
+.Aq oldrole
+argument is previous resource role (before the change).
+It can be one of:
+.Ar init ,
+.Ar secondary ,
+.Ar primary .
+.Pp
+The
+.Aq newrole
+argument is current resource role (after the change).
+It can be one of:
+.Ar init ,
+.Ar secondary ,
+.Ar primary .
+.Pp
 .It Ic name Aq name
 .Pp
 GEOM provider name that will appear as
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211976 - head/sbin/hastd

2010-08-29 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Aug 29 21:39:49 2010
New Revision: 211976
URL: http://svn.freebsd.org/changeset/base/211976

Log:
  - Add hook_fini() which should be called after fork() from the main hastd
process, once it start to use hooks.
  - Add hook_check_one() in case the caller expects different child processes
and once it can recognize it, it will pass pid and status to 
hook_check_one().
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/hooks.c
  head/sbin/hastd/hooks.h

Modified: head/sbin/hastd/hooks.c
==
--- head/sbin/hastd/hooks.c Sun Aug 29 21:37:21 2010(r211975)
+++ head/sbin/hastd/hooks.c Sun Aug 29 21:39:49 2010(r211976)
@@ -82,6 +82,9 @@ struct hookproc {
 static TAILQ_HEAD(, hookproc) hookprocs;
 static pthread_mutex_t hookprocs_lock;
 
+static void hook_remove(struct hookproc *hp);
+static void hook_free(struct hookproc *hp);
+
 static void
 descriptors(void)
 {
@@ -147,11 +150,35 @@ void
 hook_init(void)
 {
 
+   assert(!hooks_initialized);
+
mtx_init(&hookprocs_lock);
TAILQ_INIT(&hookprocs);
hooks_initialized = true;
 }
 
+void
+hook_fini(void)
+{
+   struct hookproc *hp;
+
+   assert(hooks_initialized);
+
+   mtx_lock(&hookprocs_lock);
+   while ((hp = TAILQ_FIRST(&hookprocs)) != NULL) {
+   assert(hp->hp_magic == HOOKPROC_MAGIC_ONLIST);
+   assert(hp->hp_pid > 0);
+
+   hook_remove(hp);
+   hook_free(hp);
+   }
+   mtx_unlock(&hookprocs_lock);
+
+   mtx_destroy(&hookprocs_lock);
+   TAILQ_INIT(&hookprocs);
+   hooks_initialized = false;
+}
+
 static struct hookproc *
 hook_alloc(const char *path, char **args)
 {
@@ -238,6 +265,34 @@ hook_find(pid_t pid)
 }
 
 void
+hook_check_one(pid_t pid, int status)
+{
+   struct hookproc *hp;
+
+   mtx_lock(&hookprocs_lock);
+   hp = hook_find(pid);
+   if (hp == NULL) {
+   mtx_unlock(&hookprocs_lock);
+   pjdlog_debug(1, "Unknown process pid=%u", pid);
+   return;
+   }
+   hook_remove(hp);
+   mtx_unlock(&hookprocs_lock);
+   if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
+   pjdlog_debug(1, "Hook exited gracefully (pid=%u, cmd=[%s]).",
+   pid, hp->hp_comm);
+   } else if (WIFSIGNALED(status)) {
+   pjdlog_error("Hook was killed (pid=%u, signal=%d, cmd=[%s]).",
+   pid, WTERMSIG(status), hp->hp_comm);
+   } else {
+   pjdlog_error("Hook exited ungracefully (pid=%u, exitcode=%d, 
cmd=[%s]).",
+   pid, WIFEXITED(status) ? WEXITSTATUS(status) : -1,
+   hp->hp_comm);
+   }
+   hook_free(hp);
+}
+
+void
 hook_check(bool sigchld)
 {
struct hookproc *hp, *hp2;
@@ -250,28 +305,9 @@ hook_check(bool sigchld)
/*
 * If SIGCHLD was received, garbage collect finished processes.
 */
-   while (sigchld && (pid = wait3(&status, WNOHANG, NULL)) > 0) {
-   mtx_lock(&hookprocs_lock);
-   hp = hook_find(pid);
-   if (hp == NULL) {
-   mtx_unlock(&hookprocs_lock);
-   pjdlog_warning("Unknown process pid=%u", pid);
-   continue;
-   }
-   hook_remove(hp);
-   mtx_unlock(&hookprocs_lock);
-   if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
-   pjdlog_debug(1, "Hook exited gracefully (pid=%u, 
cmd=[%s]).",
-   pid, hp->hp_comm);
-   } else if (WIFSIGNALED(status)) {
-   pjdlog_error("Hook was killed (pid=%u, signal=%d, 
cmd=[%s]).",
-   pid, WTERMSIG(status), hp->hp_comm);
-   } else {
-   pjdlog_error("Hook exited ungracefully (pid=%u, 
exitcode=%d, cmd=[%s]).",
-   pid, WIFEXITED(status) ? WEXITSTATUS(status) : -1,
-   hp->hp_comm);
-   }
-   hook_free(hp);
+   if (sigchld) {
+   while ((pid = wait3(&status, WNOHANG, NULL)) > 0)
+   hook_check_one(pid, status);
}
 
/*

Modified: head/sbin/hastd/hooks.h
==
--- head/sbin/hastd/hooks.h Sun Aug 29 21:37:21 2010(r211975)
+++ head/sbin/hastd/hooks.h Sun Aug 29 21:39:49 2010(r211976)
@@ -33,10 +33,14 @@
 #ifndef_HOOKS_H_
 #define_HOOKS_H_
 
+#include 
+
 #include 
 #include 
 
 void hook_init(void);
+void hook_fini(void);
+void hook_check_one(pid_t pid, int status);
 void hook_check(bool sigchld);
 void hook_exec(const char *path, ...);
 void hook_execv(const char *path, va_list ap);

svn commit: r211975 - head/sbin/hastd

2010-08-29 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Aug 29 21:37:21 2010
New Revision: 211975
URL: http://svn.freebsd.org/changeset/base/211975

Log:
  Implement mtx_destroy() and rw_destroy().
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/synch.h

Modified: head/sbin/hastd/synch.h
==
--- head/sbin/hastd/synch.h Sun Aug 29 21:05:34 2010(r211974)
+++ head/sbin/hastd/synch.h Sun Aug 29 21:37:21 2010(r211975)
@@ -48,6 +48,14 @@ mtx_init(pthread_mutex_t *lock)
assert(error == 0);
 }
 static __inline void
+mtx_destroy(pthread_mutex_t *lock)
+{
+   int error;
+
+   error = pthread_mutex_destroy(lock);
+   assert(error == 0);
+}
+static __inline void
 mtx_lock(pthread_mutex_t *lock)
 {
int error;
@@ -88,6 +96,14 @@ rw_init(pthread_rwlock_t *lock)
assert(error == 0);
 }
 static __inline void
+rw_destroy(pthread_rwlock_t *lock)
+{
+   int error;
+
+   error = pthread_rwlock_destroy(lock);
+   assert(error == 0);
+}
+static __inline void
 rw_rlock(pthread_rwlock_t *lock)
 {
int error;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211972 - head/cddl/contrib/opensolaris/cmd/zfs

2010-08-29 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Aug 29 20:25:25 2010
New Revision: 211972
URL: http://svn.freebsd.org/changeset/base/211972

Log:
  Give user a hint what to do when /usr/lib/zfs/pyzfs.py is missing.
  
  MFC after:2 weeks

Modified:
  head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c

Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
==
--- head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.cSun Aug 29 20:21:10 
2010(r211971)
+++ head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.cSun Aug 29 20:25:25 
2010(r211972)
@@ -1736,6 +1736,7 @@ zfs_do_userspace(int argc, char **argv)
(void) fprintf(stderr, "internal error: %s not found\n"
"falling back on built-in implementation, "
"some features will not work\n", pypath);
+   (void) fprintf(stderr, "install sysutils/py-zfs port to correct 
this\n");
 
if ((zhp = zfs_open(g_zfs, argv[argc-1], ZFS_TYPE_DATASET)) == NULL)
return (1);
@@ -3798,6 +3799,7 @@ zfs_do_python(int argc, char **argv)
 {
(void) execv(pypath, argv-1);
(void) fprintf(stderr, "internal error: %s not found\n", pypath);
+   (void) fprintf(stderr, "install sysutils/py-zfs port to correct 
this\n");
return (-1);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211971 - head/cddl/contrib/opensolaris/cmd/zfs

2010-08-29 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Aug 29 20:21:10 2010
New Revision: 211971
URL: http://svn.freebsd.org/changeset/base/211971

Log:
  Print errors on stderr.
  
  MFC after:2 weeks

Modified:
  head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c

Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
==
--- head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.cSun Aug 29 20:18:06 
2010(r211970)
+++ head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.cSun Aug 29 20:21:10 
2010(r211971)
@@ -1733,7 +1733,7 @@ zfs_do_userspace(int argc, char **argv)
 */
(void) execv(pypath, argv-1);
 
-   (void) printf("internal error: %s not found\n"
+   (void) fprintf(stderr, "internal error: %s not found\n"
"falling back on built-in implementation, "
"some features will not work\n", pypath);
 
@@ -3797,7 +3797,7 @@ static int
 zfs_do_python(int argc, char **argv)
 {
(void) execv(pypath, argv-1);
-   (void) printf("internal error: %s not found\n", pypath);
+   (void) fprintf(stderr, "internal error: %s not found\n", pypath);
return (-1);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211970 - head/cddl/contrib/opensolaris/lib/pyzfs/common

2010-08-29 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Aug 29 20:18:06 2010
New Revision: 211970
URL: http://svn.freebsd.org/changeset/base/211970

Log:
  Fix 'zfs allow' (maybe not only) returning:
  
cannot access dataset system/usr/home: Operation not supported
  
  by including libzfs_impl.h. What libzfs_impl.h does is to redefine ioctl() to
  be compatible with OpenSolaris. More specifically OpenSolaris returns ENOMEM
  when buffer is too small and sets field zc_nvlist_dst_size to the size that
  will be big enough for the data. In FreeBSD case ioctl() doesn't copy data
  structure back in case of a failure. We work-around it in kernel and libzfs by
  returning 0 from ioctl() and always checking if zc_nvlist_dst_size hasn't
  changed. For this work-around to work in pyzfs we need this compatible ioctl()
  which is implemented in libzfs_impl.h.
  
  MFC after:2 weeks

Modified:
  head/cddl/contrib/opensolaris/lib/pyzfs/common/ioctl.c

Modified: head/cddl/contrib/opensolaris/lib/pyzfs/common/ioctl.c
==
--- head/cddl/contrib/opensolaris/lib/pyzfs/common/ioctl.c  Sun Aug 29 
18:50:30 2010(r211969)
+++ head/cddl/contrib/opensolaris/lib/pyzfs/common/ioctl.c  Sun Aug 29 
20:18:06 2010(r211970)
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "zfs_prop.h"
 
 static PyObject *ZFSError;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r211932 - in head/sys/cddl: compat/opensolaris/kern compat/opensolaris/sys contrib/opensolaris/uts/common contrib/opensolaris/uts/common/fs/zfs contrib/opensolaris/uts/common/fs/zfs/sy

2010-08-28 Thread Pawel Jakub Dawidek
On Sat, Aug 28, 2010 at 09:41:39PM +0200, Martin Matuska wrote:
>  Thank you, committed just minutes ahead of me :-)
> Both mistakes are due to a mis-patch. I will include the fixed version
> it in the post-v15 merge.

BTW. 'zfs allow' doesn't work for me anymore. It might be due to py-zfs
being compiled from more recent source than my userland and kernel was
build. Does it work for you?

# zfs allow foo/bar
cannot access dataset foo/bar: Operation not supported

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgpP4AnrqXUfp.pgp
Description: PGP signature


Re: svn commit: r211932 - in head/sys/cddl: compat/opensolaris/kern compat/opensolaris/sys contrib/opensolaris/uts/common contrib/opensolaris/uts/common/fs/zfs contrib/opensolaris/uts/common/fs/zfs/sy

2010-08-28 Thread Pawel Jakub Dawidek
On Sat, Aug 28, 2010 at 07:40:39PM +0200, Pawel Jakub Dawidek wrote:
> Those two chunks are incorrect, please consult my p4 branch.

I just went ahead and fixed those.

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgpUTkmZHFDfC.pgp
Description: PGP signature


svn commit: r211948 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2010-08-28 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sat Aug 28 19:29:06 2010
New Revision: 211948
URL: http://svn.freebsd.org/changeset/base/211948

Log:
  Return NULL pointer instead of B_FALSE as it is done in the vendor code.
  
  Obtained from://depot/user/pjd/zfs/...

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c   Sat Aug 
28 19:28:12 2010(r211947)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c   Sat Aug 
28 19:29:06 2010(r211948)
@@ -82,7 +82,7 @@ rrn_find(rrwlock_t *rrl)
rrw_node_t *rn;
 
if (refcount_count(&rrl->rr_linked_rcount) == 0)
-   return (B_FALSE);
+   return (NULL);
 
for (rn = tsd_get(rrw_tsd_key); rn != NULL; rn = rn->rn_next) {
if (rn->rn_rrl == rrl)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211947 - head/sys/cddl/contrib/opensolaris/uts/common

2010-08-28 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sat Aug 28 19:28:12 2010
New Revision: 211947
URL: http://svn.freebsd.org/changeset/base/211947

Log:
  Move ZUT_OBJS in the same place that is used in vendor code.
  
  Obtained from://depot/user/pjd/zfs/...

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/Makefile.files

Modified: head/sys/cddl/contrib/opensolaris/uts/common/Makefile.files
==
--- head/sys/cddl/contrib/opensolaris/uts/common/Makefile.files Sat Aug 28 
19:02:51 2010(r211946)
+++ head/sys/cddl/contrib/opensolaris/uts/common/Makefile.files Sat Aug 28 
19:28:12 2010(r211947)
@@ -19,9 +19,6 @@
 # CDDL HEADER END
 #
 
-ZUT_OBJS +=\
-   zut.o
-
 #
 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
@@ -109,3 +106,6 @@ ZFS_OBJS += \
zfs_vfsops.o\
zfs_vnops.o \
zvol.o
+
+ZUT_OBJS +=\
+   zut.o
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r211853 - head/sys/rpc

2010-08-28 Thread Pawel Jakub Dawidek
On Fri, Aug 27, 2010 at 07:48:09PM +0400, pluknet wrote:
> On 27 August 2010 03:33, Pawel Jakub Dawidek  wrote:
> > Author: pjd
> > Date: Thu Aug 26 23:33:04 2010
> > New Revision: 211853
> > URL: http://svn.freebsd.org/changeset/base/211853
> >
> > Log:
> >  - Check the result of malloc(M_NOWAIT) in replay_alloc(). The caller
> >    (replay_alloc()) knows how to handle replay_alloc() failure.
> >  - Eliminate 'freed_one' variable, it is not needed - when no entry is found
> >    rce will be NULL.
> >  - Add locking assertions where we expect a rc_lock to be held.
> 
> Hi,
> 
> may this help fixing memory leak seen on nfsclient.ko unload right
> after nfs_unmount()?
> 
> Warning: memory type rpc leaked memory on destroy (3 allocations, 1216
> bytes leaked).

Nope. This change is related to NFS server, not client.

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgpwhqgnUzs2P.pgp
Description: PGP signature


Re: svn commit: r211932 - in head/sys/cddl: compat/opensolaris/kern compat/opensolaris/sys contrib/opensolaris/uts/common contrib/opensolaris/uts/common/fs/zfs contrib/opensolaris/uts/common/fs/zfs/sy

2010-08-28 Thread Pawel Jakub Dawidek
On Sat, Aug 28, 2010 at 09:24:11AM +, Martin Matuska wrote:
> Author: mm
> Date: Sat Aug 28 09:24:11 2010
> New Revision: 211932
> URL: http://svn.freebsd.org/changeset/base/211932
> 
> Log:
>   Import changes from OpenSolaris that provide
>   - better ACL caching and speedup of ACL permission checks
>   - faster handling of stat()
>   - lowered mutex contention in the read/writer lock (rrwlock)
>   - several related bugfixes
>   
>   Detailed information (OpenSolaris onnv changesets and Bug IDs):
>   
>   9749:105f407a2680
>   6802734 Support for Access Based Enumeration (not used on FreeBSD)
>   6844861 inconsistent xattr readdir behavior with too-small buffer
>   
>   9866:ddc5f1d8eb4e
>   6848431 zfs with rstchown=0 or file_chown_self privilege allows user to 
> "take" ownership
>   
>   9981:b4907297e740
>   6775100 stat() performance on files on zfs should be improved
>   6827779 rrwlock is overly protective of its counters
>   
>   10143:d2d432dfe597
>   6857433 memory leaks found at: zfs_acl_alloc/zfs_acl_node_alloc
>   6860318 truncate() on zfsroot succeeds when file has a component of its 
> path set without access permission
>   
>   10232:f37b85f7e03e
>   6865875 zfs sometimes incorrectly giving search access to a dir
>   
>   10250:b179ceb34b62
>   6867395 zpool_upgrade_007_pos testcase panic'd with BAD TRAP: type=e 
> (#pf Page fault)
>   
>   10269:2788675568fd
>   6868276 zfs_rezget() can be hazardous when znode has a cached ACL
>   
>   10295:f7a18a1e9610
>   6870564 panic in zfs_getsecattr
>   
>   Approved by:delphij (mentor)
>   Obtained from:  OpenSolaris (multiple Bug IDs)
>   MFC after:  2 weeks
[...]
> --- head/sys/cddl/contrib/opensolaris/uts/common/Makefile.files   Sat Aug 
> 28 08:59:55 2010(r211931)
> +++ head/sys/cddl/contrib/opensolaris/uts/common/Makefile.files   Sat Aug 
> 28 09:24:11 2010(r211932)
> @@ -19,6 +19,9 @@
>  # CDDL HEADER END
>  #
>  
> +ZUT_OBJS +=  \
> + zut.o
> +
>  #
>  # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
>  # Use is subject to license terms.
[...]
> --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c Sat Aug 
> 28 08:59:55 2010(r211931)
> +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c Sat Aug 
> 28 09:24:11 2010(r211932)
[...]
> @@ -84,7 +82,7 @@ rrn_find(rrwlock_t *rrl)
>   rrw_node_t *rn;
>  
>   if (refcount_count(&rrl->rr_linked_rcount) == 0)
> - return (NULL);
> + return (B_FALSE);
>  
>   for (rn = tsd_get(rrw_tsd_key); rn != NULL; rn = rn->rn_next) {
>   if (rn->rn_rrl == rrl)

Those two chunks are incorrect, please consult my p4 branch.

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgpvqFnoJ72UR.pgp
Description: PGP signature


Re: svn commit: r211553 - head/sys/cddl/compat/opensolaris/kern

2010-08-28 Thread Pawel Jakub Dawidek
On Sat, Aug 21, 2010 at 11:41:32AM +, Rui Paulo wrote:
> Author: rpaulo
> Date: Sat Aug 21 11:41:32 2010
> New Revision: 211553
> URL: http://svn.freebsd.org/changeset/base/211553
> 
> Log:
>   Add sysname to struct opensolaris_utsname. This is needed by one DTrace
>   test.
>   
>   Sponsored by:   The FreeBSD Foundation
> 
> Modified:
>   head/sys/cddl/compat/opensolaris/kern/opensolaris_misc.c
> 
> Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris_misc.c
> ==
> --- head/sys/cddl/compat/opensolaris/kern/opensolaris_misc.c  Sat Aug 21 
> 11:33:49 2010(r211552)
> +++ head/sys/cddl/compat/opensolaris/kern/opensolaris_misc.c  Sat Aug 21 
> 11:41:32 2010(r211553)
> @@ -38,7 +38,8 @@ __FBSDID("$FreeBSD$");
>  char hw_serial[11] = "0";
>  
>  struct opensolaris_utsname utsname = {
> - .nodename = "unset"
> + .nodename = "unset",
> + .sysname  = "SunOS"

This collides with the changes I have in perforce. Could you take a look at:

//depot/user/pjd/zfs/sys/cddl/compat/opensolaris/kern/opensolaris_misc.c
//depot/user/pjd/zfs/sys/cddl/compat/opensolaris/sys/misc.h

I'd prefer sysname to say FreeBSD on FreeBSD, rather than SunOS.
I see it is being used in one DTrace test. Changing 'tst.str.d.out' to
expect "FreeBSD" instead of "SunOS" is ok?

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgpLj1fxc3JAh.pgp
Description: PGP signature


Re: svn commit: r211896 - head/sbin/hastd

2010-08-28 Thread Pawel Jakub Dawidek
On Sat, Aug 28, 2010 at 10:50:42AM +0200, Pawel Jakub Dawidek wrote:
> Ehh, I'm lame. All I need to do is to use cv_timedwait_sig() instead of
> cv_timedwait() and I can remove all pthread stuff from the sighandler.

...not! This is userland, not the kernel so there is no equivalent of
cv_timedwait_sig()...

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgpS0xO0bg0NH.pgp
Description: PGP signature


svn commit: r211930 - in head/sys: kern sys

2010-08-28 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sat Aug 28 08:57:15 2010
New Revision: 211930
URL: http://svn.freebsd.org/changeset/base/211930

Log:
  There is a bug in vfs_allocate_syncvnode() failure handling in mount code.
  Actually it is hard to properly handle such a failure, especially in 
MNT_UPDATE
  case. The only reason for the vfs_allocate_syncvnode() function to fail is
  getnewvnode() failure. Fortunately it is impossible for current implementation
  of getnewvnode() to fail, so we can assert this and make
  vfs_allocate_syncvnode() void. This in turn free us from handling its failures
  in the mount code.
  
  Reviewed by:  kib
  MFC after:1 month

Modified:
  head/sys/kern/vfs_mount.c
  head/sys/kern/vfs_subr.c
  head/sys/sys/mount.h

Modified: head/sys/kern/vfs_mount.c
==
--- head/sys/kern/vfs_mount.c   Sat Aug 28 08:39:37 2010(r211929)
+++ head/sys/kern/vfs_mount.c   Sat Aug 28 08:57:15 2010(r211930)
@@ -1036,7 +1036,7 @@ vfs_domount(
MNT_IUNLOCK(mp);
if ((mp->mnt_flag & MNT_RDONLY) == 0) {
if (mp->mnt_syncer == NULL)
-   error = vfs_allocate_syncvnode(mp);
+   vfs_allocate_syncvnode(mp);
} else {
if (mp->mnt_syncer != NULL)
vrele(mp->mnt_syncer);
@@ -1078,10 +1078,8 @@ vfs_domount(
mountcheckdirs(vp, newdp);
vrele(newdp);
if ((mp->mnt_flag & MNT_RDONLY) == 0)
-   error = vfs_allocate_syncvnode(mp);
+   vfs_allocate_syncvnode(mp);
vfs_unbusy(mp);
-   if (error)
-   vrele(vp);
} else {
vfs_unbusy(mp);
vfs_mount_destroy(mp);
@@ -1311,7 +1309,7 @@ dounmount(mp, flags, td)
mp->mnt_kern_flag &= ~MNTK_NOINSMNTQ;
if ((mp->mnt_flag & MNT_RDONLY) == 0 && mp->mnt_syncer == NULL) 
{
MNT_IUNLOCK(mp);
-   (void) vfs_allocate_syncvnode(mp);
+   vfs_allocate_syncvnode(mp);
MNT_ILOCK(mp);
}
mp->mnt_kern_flag &= ~(MNTK_UNMOUNT | MNTK_UNMOUNTF);

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cSat Aug 28 08:39:37 2010(r211929)
+++ head/sys/kern/vfs_subr.cSat Aug 28 08:57:15 2010(r211930)
@@ -3365,7 +3365,7 @@ static struct vop_vector sync_vnodeops =
 /*
  * Create a new filesystem syncer vnode for the specified mount point.
  */
-int
+void
 vfs_allocate_syncvnode(struct mount *mp)
 {
struct vnode *vp;
@@ -3374,16 +3374,15 @@ vfs_allocate_syncvnode(struct mount *mp)
int error;
 
/* Allocate a new vnode */
-   if ((error = getnewvnode("syncer", mp, &sync_vnodeops, &vp)) != 0) {
-   mp->mnt_syncer = NULL;
-   return (error);
-   }
+   error = getnewvnode("syncer", mp, &sync_vnodeops, &vp);
+   if (error != 0)
+   panic("vfs_allocate_syncvnode: getnewvnode() failed");
vp->v_type = VNON;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
vp->v_vflag |= VV_FORCEINSMQ;
error = insmntque(vp, mp);
if (error != 0)
-   panic("vfs_allocate_syncvnode: insmntque failed");
+   panic("vfs_allocate_syncvnode: insmntque() failed");
vp->v_vflag &= ~VV_FORCEINSMQ;
VOP_UNLOCK(vp, 0);
/*
@@ -3411,7 +3410,6 @@ vfs_allocate_syncvnode(struct mount *mp)
mtx_unlock(&sync_mtx);
BO_UNLOCK(bo);
mp->mnt_syncer = vp;
-   return (0);
 }
 
 /*

Modified: head/sys/sys/mount.h
==
--- head/sys/sys/mount.hSat Aug 28 08:39:37 2010(r211929)
+++ head/sys/sys/mount.hSat Aug 28 08:57:15 2010(r211930)
@@ -730,7 +730,7 @@ voidvfs_msync(struct mount *, int);
 intvfs_busy(struct mount *, int);
 intvfs_export   /* process mount export info */
(struct mount *, struct export_args *);
-intvfs_allocate_syncvnode(struct mount *);
+void   vfs_allocate_syncvnode(struct mount *);
 intvfs_donmount(struct thread *td, int fsflags, struct uio *fsoptions);
 void   vfs_getnewfsid(struct mount *);
 struct cdev *vfs_getrootfsid(struct mount *);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r211896 - head/sbin/hastd

2010-08-28 Thread Pawel Jakub Dawidek
On Sat, Aug 28, 2010 at 11:43:55AM +0300, Kostik Belousov wrote:
> On Fri, Aug 27, 2010 at 11:54:02PM +0200, Pawel Jakub Dawidek wrote:
> > On Sat, Aug 28, 2010 at 12:38:27AM +0300, Kostik Belousov wrote:
> > > > --- head/sbin/hastd/primary.c   Fri Aug 27 20:48:12 2010
> > > > (r211895)
> > > > +++ head/sbin/hastd/primary.c   Fri Aug 27 20:49:06 2010
> > > > (r211896)
> > > > @@ -1988,7 +1988,9 @@ guard_thread(void *arg)
> > > > rw_unlock(&hio_remote_lock[ii]);
> > > > }
> > > > }
> > > > -   (void)cv_timedwait(&hio_guard_cond, &hio_guard_lock, 
> > > > timeout);
> > > > +   /* Sleep only if a signal wasn't delivered in the 
> > > > meantime. */
> > > > +   if (!sigexit_received && !sighup_received && 
> > > > !sigchld_received)
> > > > +   cv_timedwait(&hio_guard_cond, &hio_guard_lock, 
> > > > timeout);
> > > > mtx_unlock(&hio_guard_lock);
> > > > }
> > > > /* NOTREACHED */
> > > I wanted to say that this is racy, because if a signal is delivered after
> > > the check is done but before the sleep, you loose.
> > 
> > Yes, I know it is racy, but the race isn't critical anymore, as we will
> > eventually wait at most 10 seconds to handle signals.
> > 
> > > After looking at the signal handler, I noted that you call not async-safe
> > > functions in the handler. This is easy way to get undefined behaviour,
> > > i.e. probably crash. And wakeup from the handler would have the same
> > > race as sigXXX_received check.
> > 
> > Which aren't async-safe? pthread stuff?
> 
> Yes. All pthread_* namespace is not async-signal safe.

Ehh, I'm lame. All I need to do is to use cv_timedwait_sig() instead of
cv_timedwait() and I can remove all pthread stuff from the sighandler.

Thanks!

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgphi8LtoaOuD.pgp
Description: PGP signature


svn commit: r211928 - head/sys/kern

2010-08-28 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sat Aug 28 08:38:03 2010
New Revision: 211928
URL: http://svn.freebsd.org/changeset/base/211928

Log:
  Run all tasks from a proper context, with proper priority, etc.
  
  Reviewed by:  jhb
  MFC after:1 month

Modified:
  head/sys/kern/subr_taskqueue.c

Modified: head/sys/kern/subr_taskqueue.c
==
--- head/sys/kern/subr_taskqueue.c  Sat Aug 28 08:30:20 2010
(r211927)
+++ head/sys/kern/subr_taskqueue.c  Sat Aug 28 08:38:03 2010
(r211928)
@@ -141,7 +141,6 @@ taskqueue_free(struct taskqueue *queue)
 
TQ_LOCK(queue);
queue->tq_flags &= ~TQ_FLAGS_ACTIVE;
-   taskqueue_run(queue, &queue->tq_running);
taskqueue_terminate(queue->tq_threads, queue);
mtx_destroy(&queue->tq_mutex);
free(queue->tq_threads, M_TASKQUEUE);
@@ -372,6 +371,7 @@ taskqueue_thread_loop(void *arg)
break;
TQ_SLEEP(tq, tq, &tq->tq_mutex, 0, "-", 0);
}
+   taskqueue_run(tq, &running);
 
/* rendezvous with thread that asked us to terminate */
tq->tq_tcount--;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r211927 - head/sys/geom/eli

2010-08-28 Thread Pawel Jakub Dawidek
On Sat, Aug 28, 2010 at 08:30:20AM +, Pawel Jakub Dawidek wrote:
> Author: pjd
> Date: Sat Aug 28 08:30:20 2010
> New Revision: 211927
> URL: http://svn.freebsd.org/changeset/base/211927
> 
> Log:
>   Correct offset conversion to little endian. It was implemented in version 2,
>   but because of a bug it was a no-op, so we were still using offsets in 
> native
>   byte order for the host. Do it properly this time, bump version to 4 and set
>   the G_ELI_FLAG_NATIVE_BYTE_ORDER flag when version is under 4.

I forgot to add:

Reported by:    ivoras

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgpW6zka0twKz.pgp
Description: PGP signature


svn commit: r211927 - head/sys/geom/eli

2010-08-28 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sat Aug 28 08:30:20 2010
New Revision: 211927
URL: http://svn.freebsd.org/changeset/base/211927

Log:
  Correct offset conversion to little endian. It was implemented in version 2,
  but because of a bug it was a no-op, so we were still using offsets in native
  byte order for the host. Do it properly this time, bump version to 4 and set
  the G_ELI_FLAG_NATIVE_BYTE_ORDER flag when version is under 4.
  
  MFC after:2 weeks

Modified:
  head/sys/geom/eli/g_eli.c
  head/sys/geom/eli/g_eli.h

Modified: head/sys/geom/eli/g_eli.c
==
--- head/sys/geom/eli/g_eli.c   Sat Aug 28 08:18:20 2010(r211926)
+++ head/sys/geom/eli/g_eli.c   Sat Aug 28 08:30:20 2010(r211927)
@@ -384,11 +384,13 @@ g_eli_crypto_ivgen(struct g_eli_softc *s
u_char off[8], hash[SHA256_DIGEST_LENGTH];
SHA256_CTX ctx;
 
-   if (!(sc->sc_flags & G_ELI_FLAG_NATIVE_BYTE_ORDER))
+   if ((sc->sc_flags & G_ELI_FLAG_NATIVE_BYTE_ORDER) != 0)
+   bcopy(&offset, off, sizeof(off));
+   else
le64enc(off, (uint64_t)offset);
/* Copy precalculated SHA256 context for IV-Key. */
bcopy(&sc->sc_ivctx, &ctx, sizeof(ctx));
-   SHA256_Update(&ctx, (uint8_t *)&offset, sizeof(offset));
+   SHA256_Update(&ctx, off, sizeof(off));
SHA256_Final(hash, &ctx);
bcopy(hash, iv, size);
 }
@@ -544,7 +546,7 @@ g_eli_create(struct gctl_req *req, struc
sc->sc_crypto = G_ELI_CRYPTO_SW;
sc->sc_flags = md->md_flags;
/* Backward compatibility. */
-   if (md->md_version < 2)
+   if (md->md_version < 4)
sc->sc_flags |= G_ELI_FLAG_NATIVE_BYTE_ORDER;
sc->sc_ealgo = md->md_ealgo;
sc->sc_nkey = nkey;

Modified: head/sys/geom/eli/g_eli.h
==
--- head/sys/geom/eli/g_eli.h   Sat Aug 28 08:18:20 2010(r211926)
+++ head/sys/geom/eli/g_eli.h   Sat Aug 28 08:30:20 2010(r211927)
@@ -57,11 +57,11 @@
  * 1 - Added data authentication support (md_aalgo field and
  * G_ELI_FLAG_AUTH flag).
  * 2 - Added G_ELI_FLAG_READONLY.
- *   - IV is generated from offset converted to little-endian
- * (flag G_ELI_FLAG_NATIVE_BYTE_ORDER will be set for older versions).
  * 3 - Added 'configure' subcommand.
+ * 4 - IV is generated from offset converted to little-endian
+ * (flag G_ELI_FLAG_NATIVE_BYTE_ORDER will be set for older versions).
  */
-#defineG_ELI_VERSION   3
+#defineG_ELI_VERSION   4
 
 /* ON DISK FLAGS. */
 /* Use random, onetime keys. */
@@ -394,7 +394,7 @@ g_eli_keylen(u_int algo, u_int keylen)
keylen = 0;
}
return (keylen);
-   case CRYPTO_AES_CBC: /* FALLTHROUGH */
+   case CRYPTO_AES_CBC:
case CRYPTO_CAMELLIA_CBC:
switch (keylen) {
case 0:
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r211896 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
On Sat, Aug 28, 2010 at 12:38:27AM +0300, Kostik Belousov wrote:
> > --- head/sbin/hastd/primary.c   Fri Aug 27 20:48:12 2010
> > (r211895)
> > +++ head/sbin/hastd/primary.c   Fri Aug 27 20:49:06 2010
> > (r211896)
> > @@ -1988,7 +1988,9 @@ guard_thread(void *arg)
> > rw_unlock(&hio_remote_lock[ii]);
> > }
> > }
> > -   (void)cv_timedwait(&hio_guard_cond, &hio_guard_lock, timeout);
> > +   /* Sleep only if a signal wasn't delivered in the meantime. */
> > +   if (!sigexit_received && !sighup_received && !sigchld_received)
> > +   cv_timedwait(&hio_guard_cond, &hio_guard_lock, timeout);
> > mtx_unlock(&hio_guard_lock);
> > }
> > /* NOTREACHED */
> I wanted to say that this is racy, because if a signal is delivered after
> the check is done but before the sleep, you loose.

Yes, I know it is racy, but the race isn't critical anymore, as we will
eventually wait at most 10 seconds to handle signals.

> After looking at the signal handler, I noted that you call not async-safe
> functions in the handler. This is easy way to get undefined behaviour,
> i.e. probably crash. And wakeup from the handler would have the same
> race as sigXXX_received check.

Which aren't async-safe? pthread stuff?

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgpMLKyZvhbo2.pgp
Description: PGP signature


svn commit: r211900 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 21:31:15 2010
New Revision: 211900
URL: http://svn.freebsd.org/changeset/base/211900

Log:
  Use ZFS_CTLDIR_NAME instead of hardcoding ".zfs".

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.cFri Aug 
27 21:28:02 2010(r211899)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.cFri Aug 
27 21:31:15 2010(r211900)
@@ -965,9 +965,10 @@ zfsctl_snapdir_lookup(ap)
dmu_objset_close(snap);
 domount:
mountpoint_len = strlen(dvp->v_vfsp->mnt_stat.f_mntonname) +
-   strlen("/.zfs/snapshot/") + strlen(nm) + 1;
+   strlen("/" ZFS_CTLDIR_NAME "/snapshot/") + strlen(nm) + 1;
mountpoint = kmem_alloc(mountpoint_len, KM_SLEEP);
-   (void) snprintf(mountpoint, mountpoint_len, "%s/.zfs/snapshot/%s",
+   (void) snprintf(mountpoint, mountpoint_len,
+   "%s/" ZFS_CTLDIR_NAME "/snapshot/%s",
dvp->v_vfsp->mnt_stat.f_mntonname, nm);
err = mount_snapshot(curthread, vpp, "zfs", mountpoint, snapname, 0);
kmem_free(mountpoint, mountpoint_len);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211899 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 21:28:02 2010
New Revision: 211899
URL: http://svn.freebsd.org/changeset/base/211899

Log:
  When SIGTERM or SIGINT is received, terminate worker processes.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/hastd.c

Modified: head/sbin/hastd/hastd.c
==
--- head/sbin/hastd/hastd.c Fri Aug 27 21:26:55 2010(r211898)
+++ head/sbin/hastd/hastd.c Fri Aug 27 21:28:02 2010(r211899)
@@ -82,6 +82,10 @@ sighandler(int sig)
 {
 
switch (sig) {
+   case SIGINT:
+   case SIGTERM:
+   sigexit_received = true;
+   break;
case SIGCHLD:
sigchld_received = true;
break;
@@ -374,6 +378,25 @@ failed:
 }
 
 static void
+terminate_workers(void)
+{
+   struct hast_resource *res;
+
+   pjdlog_info("Termination signal received, exiting.");
+   TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) {
+   if (res->hr_workerpid == 0)
+   continue;
+   pjdlog_info("Terminating worker process (resource=%s, role=%s, 
pid=%u).",
+   res->hr_name, role2str(res->hr_role), res->hr_workerpid);
+   if (kill(res->hr_workerpid, SIGTERM) == 0)
+   continue;
+   pjdlog_errno(LOG_WARNING,
+   "Unable to send signal to worker process (resource=%s, 
role=%s, pid=%u).",
+   res->hr_name, role2str(res->hr_role), res->hr_workerpid);
+   }
+}
+
+static void
 listen_accept(void)
 {
struct hast_resource *res;
@@ -599,6 +622,11 @@ main_loop(void)
int cfd, lfd, maxfd, ret;
 
for (;;) {
+   if (sigexit_received) {
+   sigexit_received = false;
+   terminate_workers();
+   exit(EX_OK);
+   }
if (sigchld_received) {
sigchld_received = false;
child_exit();
@@ -692,6 +720,8 @@ main(int argc, char *argv[])
cfg = yy_config_parse(cfgpath, true);
assert(cfg != NULL);
 
+   signal(SIGINT, sighandler);
+   signal(SIGTERM, sighandler);
signal(SIGHUP, sighandler);
signal(SIGCHLD, sighandler);
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211898 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 21:26:55 2010
New Revision: 211898
URL: http://svn.freebsd.org/changeset/base/211898

Log:
  When logging to stdout/stderr, flush after each log.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/pjdlog.c

Modified: head/sbin/hastd/pjdlog.c
==
--- head/sbin/hastd/pjdlog.cFri Aug 27 21:20:32 2010(r211897)
+++ head/sbin/hastd/pjdlog.cFri Aug 27 21:26:55 2010(r211898)
@@ -217,6 +217,7 @@ pjdlogv_common(int loglevel, int debugle
if (error != -1)
fprintf(out, ": %s.", strerror(error));
fprintf(out, "\n");
+   fflush(out);
break;
}
case PJDLOG_MODE_SYSLOG:
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211897 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 21:20:32 2010
New Revision: 211897
URL: http://svn.freebsd.org/changeset/base/211897

Log:
  Correct when we log interrupted synchronization.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Fri Aug 27 20:49:06 2010(r211896)
+++ head/sbin/hastd/primary.c   Fri Aug 27 21:20:32 2010(r211897)
@@ -1507,18 +1507,16 @@ sync_thread(void *arg __unused)
 
ncomps = HAST_NCOMPONENTS;
dorewind = true;
-   synced = -1;
+   synced = 0;
+   offset = -1;
 
for (;;) {
mtx_lock(&sync_lock);
-   if (synced == -1)
-   synced = 0;
-   else if (!sync_inprogress) {
+   if (offset >= 0 && !sync_inprogress) {
pjdlog_info("Synchronization interrupted. "
"%jd bytes synchronized so far.",
(intmax_t)synced);
-   hook_exec(res->hr_exec, "syncintr",
-   res->hr_name, NULL);
+   hook_exec(res->hr_exec, "syncintr", res->hr_name, NULL);
}
while (!sync_inprogress) {
dorewind = true;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211896 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 20:49:06 2010
New Revision: 211896
URL: http://svn.freebsd.org/changeset/base/211896

Log:
  Check if no signals were delivered just before going to sleep.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Fri Aug 27 20:48:12 2010(r211895)
+++ head/sbin/hastd/primary.c   Fri Aug 27 20:49:06 2010(r211896)
@@ -1988,7 +1988,9 @@ guard_thread(void *arg)
rw_unlock(&hio_remote_lock[ii]);
}
}
-   (void)cv_timedwait(&hio_guard_cond, &hio_guard_lock, timeout);
+   /* Sleep only if a signal wasn't delivered in the meantime. */
+   if (!sigexit_received && !sighup_received && !sigchld_received)
+   cv_timedwait(&hio_guard_cond, &hio_guard_lock, timeout);
mtx_unlock(&hio_guard_lock);
}
/* NOTREACHED */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211895 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 20:48:12 2010
New Revision: 211895
URL: http://svn.freebsd.org/changeset/base/211895

Log:
  Add hooks execution.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Fri Aug 27 19:57:17 2010(r211894)
+++ head/sbin/hastd/primary.c   Fri Aug 27 20:48:12 2010(r211895)
@@ -1517,6 +1517,8 @@ sync_thread(void *arg __unused)
pjdlog_info("Synchronization interrupted. "
"%jd bytes synchronized so far.",
(intmax_t)synced);
+   hook_exec(res->hr_exec, "syncintr",
+   res->hr_name, NULL);
}
while (!sync_inprogress) {
dorewind = true;
@@ -1549,6 +1551,8 @@ sync_thread(void *arg __unused)
pjdlog_info("Synchronization started. %ju bytes 
to go.",
(uintmax_t)(res->hr_extentsize *
activemap_ndirty(res->hr_amp)));
+   hook_exec(res->hr_exec, "syncstart",
+   res->hr_name, NULL);
}
}
if (offset < 0) {
@@ -1565,6 +1569,8 @@ sync_thread(void *arg __unused)
pjdlog_info("Synchronization complete. "
"%jd bytes synchronized.",
(intmax_t)synced);
+   hook_exec(res->hr_exec, "syncdone",
+   res->hr_name, NULL);
}
mtx_lock(&metadata_lock);
res->hr_syncsrc = HAST_SYNCSRC_UNDEF;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211887 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 15:20:31 2010
New Revision: 211887
URL: http://svn.freebsd.org/changeset/base/211887

Log:
  Document new 'exec' parameter.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/hast.conf.5

Modified: head/sbin/hastd/hast.conf.5
==
--- head/sbin/hastd/hast.conf.5 Fri Aug 27 15:16:52 2010(r211886)
+++ head/sbin/hastd/hast.conf.5 Fri Aug 27 15:20:31 2010(r211887)
@@ -1,4 +1,5 @@
 .\" Copyright (c) 2010 The FreeBSD Foundation
+.\" Copyright (c) 2010 Pawel Jakub Dawidek 
 .\" All rights reserved.
 .\"
 .\" This software was developed by Pawel Jakub Dawidek under sponsorship from
@@ -27,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 5, 2010
+.Dd August 27, 2010
 .Dt HAST.CONF 5
 .Os
 .Sh NAME
@@ -59,6 +60,7 @@ control 
 listen 
 replication 
 timeout 
+exec 
 
 on  {
# Node section
@@ -78,6 +80,7 @@ resource  {
name 
local 
timeout 
+   exec 
 
on  {
# Resource-node section
@@ -203,6 +206,41 @@ replication mode is currently not implem
 Connection timeout in seconds.
 The default value is
 .Va 5 .
+.It Ic exec Aq path
+.Pp
+Execute the given program on various HAST events.
+Below is the list of currently implemented events and arguments the given
+program is executed with:
+.Bl -tag -width ".Ic "
+.It Ic " syncstart "
+.Pp
+Executed on primary node when synchronization process of secondary node is
+started.
+.Pp
+.It Ic " syncdone "
+.Pp
+Executed on primary node when synchronization process of secondary node is
+completed successfully.
+.Pp
+.It Ic " syncintr "
+.Pp
+Executed on primary node when synchronization process of secondary node is
+interrupted, most likely due to secondary node outage or connection failure
+between the nodes.
+.Pp
+.El
+The
+.Aq path
+argument should contain full path to executable program.
+If the given program exits with code different than
+.Va 0 ,
+.Nm hastd
+will log it as an error.
+.Pp
+The
+.Aq resource
+argument is resource name from the configuration file.
+.Pp
 .It Ic name Aq name
 .Pp
 GEOM provider name that will appear as
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r211886 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
On Fri, Aug 27, 2010 at 03:16:52PM +, Pawel Jakub Dawidek wrote:
> Author: pjd
> Date: Fri Aug 27 15:16:52 2010
> New Revision: 211886
> URL: http://svn.freebsd.org/changeset/base/211886
> 
> Log:
>   Allow to execute specified program on various HAST events.

Manual page update will follow soon:)

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgpRonZW5OiFX.pgp
Description: PGP signature


svn commit: r211886 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 15:16:52 2010
New Revision: 211886
URL: http://svn.freebsd.org/changeset/base/211886

Log:
  Allow to execute specified program on various HAST events.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/hast.h
  head/sbin/hastd/hastd.c
  head/sbin/hastd/hastd.h
  head/sbin/hastd/parse.y
  head/sbin/hastd/primary.c
  head/sbin/hastd/token.l

Modified: head/sbin/hastd/hast.h
==
--- head/sbin/hastd/hast.h  Fri Aug 27 14:38:12 2010(r211885)
+++ head/sbin/hastd/hast.h  Fri Aug 27 15:16:52 2010(r211886)
@@ -127,6 +127,8 @@ struct hast_resource {
int hr_extentsize;
/* Maximum number of extents that are kept dirty. */
int hr_keepdirty;
+   /* Path to a program to execute on various events. */
+   charhr_exec[PATH_MAX];
 
/* Path to local component. */
charhr_localpath[PATH_MAX];

Modified: head/sbin/hastd/hastd.c
==
--- head/sbin/hastd/hastd.c Fri Aug 27 14:38:12 2010(r211885)
+++ head/sbin/hastd/hastd.c Fri Aug 27 15:16:52 2010(r211886)
@@ -62,7 +62,7 @@ const char *cfgpath = HAST_CONFIG;
 /* Hastd configuration. */
 static struct hastd_config *cfg;
 /* Was SIGCHLD signal received? */
-static bool sigchld_received = false;
+bool sigchld_received = false;
 /* Was SIGHUP signal received? */
 bool sighup_received = false;
 /* Was SIGINT or SIGTERM signal received? */
@@ -189,6 +189,8 @@ resource_needs_restart(const struct hast
return (true);
if (res0->hr_timeout != res1->hr_timeout)
return (true);
+   if (strcmp(res0->hr_exec, res1->hr_exec) != 0)
+   return (true);
}
return (false);
 }
@@ -211,6 +213,8 @@ resource_needs_reload(const struct hast_
return (true);
if (res0->hr_timeout != res1->hr_timeout)
return (true);
+   if (strcmp(res0->hr_exec, res1->hr_exec) != 0)
+   return (true);
return (false);
 }
 

Modified: head/sbin/hastd/hastd.h
==
--- head/sbin/hastd/hastd.h Fri Aug 27 14:38:12 2010(r211885)
+++ head/sbin/hastd/hastd.h Fri Aug 27 15:16:52 2010(r211886)
@@ -40,7 +40,7 @@
 #include "hast.h"
 
 extern const char *cfgpath;
-extern bool sigexit_received, sighup_received;
+extern bool sigchld_received, sigexit_received, sighup_received;
 extern struct pidfh *pfh;
 
 void hastd_primary(struct hast_resource *res);

Modified: head/sbin/hastd/parse.y
==
--- head/sbin/hastd/parse.y Fri Aug 27 14:38:12 2010(r211885)
+++ head/sbin/hastd/parse.y Fri Aug 27 15:16:52 2010(r211886)
@@ -61,6 +61,7 @@ static char depth0_control[HAST_ADDRSIZE
 static char depth0_listen[HAST_ADDRSIZE];
 static int depth0_replication;
 static int depth0_timeout;
+static char depth0_exec[PATH_MAX];
 
 static char depth1_provname[PATH_MAX];
 static char depth1_localpath[PATH_MAX];
@@ -130,6 +131,7 @@ yy_config_parse(const char *config, bool
depth0_replication = HAST_REPLICATION_MEMSYNC;
strlcpy(depth0_control, HAST_CONTROL, sizeof(depth0_control));
strlcpy(depth0_listen, HASTD_LISTEN, sizeof(depth0_listen));
+   depth0_exec[0] = '\0';
 
lconfig = calloc(1, sizeof(*lconfig));
if (lconfig == NULL) {
@@ -190,6 +192,14 @@ yy_config_parse(const char *config, bool
 */
curres->hr_timeout = depth0_timeout;
}
+   if (curres->hr_exec[0] == '\0') {
+   /*
+* Exec is not set at resource-level.
+* Use global or default setting.
+*/
+   strlcpy(curres->hr_exec, depth0_exec,
+   sizeof(curres->hr_exec));
+   }
}
 
return (lconfig);
@@ -208,7 +218,7 @@ yy_config_free(struct hastd_config *conf
 }
 %}
 
-%token CONTROL LISTEN PORT REPLICATION TIMEOUT EXTENTSIZE RESOURCE NAME LOCAL 
REMOTE ON
+%token CONTROL LISTEN PORT REPLICATION TIMEOUT EXEC EXTENTSIZE RESOURCE NAME 
LOCAL REMOTE ON
 %token FULLSYNC MEMSYNC ASYNC
 %token NUM STR OB CB
 
@@ -239,6 +249,8 @@ statement:
|
timeout_statement
|
+   exec_statement
+   |
node_statement
|
resource_statement
@@ -338,6 +350,32 @@ timeout_statement: TIMEOUT NUM
}
;
 
+exec_statement:EXEC STR
+   {
+   switch (depth) {
+   case 0:
+   if (strlcpy(depth0_exec, $2, sizeof(dep

svn commit: r211885 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 14:38:12 2010
New Revision: 211885
URL: http://svn.freebsd.org/changeset/base/211885

Log:
  - Run hooks in background - don't block waiting for them to finish.
  - Keep all hooks we're running in a global list, so we can report when
they finish and also report when they are running for too long.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/hooks.c
  head/sbin/hastd/hooks.h

Modified: head/sbin/hastd/hooks.c
==
--- head/sbin/hastd/hooks.c Fri Aug 27 14:35:39 2010(r211884)
+++ head/sbin/hastd/hooks.c Fri Aug 27 14:38:12 2010(r211885)
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2010 The FreeBSD Foundation
+ * Copyright (c) 2010 Pawel Jakub Dawidek 
  * All rights reserved.
  *
  * This software was developed by Pawel Jakub Dawidek under sponsorship from
@@ -31,21 +32,55 @@
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
 #include 
 
 #include 
+#include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
-#include 
 #include 
 #include 
-#include 
-#include 
+#include 
 
 #include 
 
 #include "hooks.h"
+#include "synch.h"
+
+/* Report processes that are running for too long not often than this value. */
+#defineREPORT_INTERVAL 60
+
+/* Are we initialized? */
+static bool hooks_initialized = false;
+
+/*
+ * Keep all processes we forked on a global queue, so we can report nicely
+ * when they finish or report that they are running for a long time.
+ */
+#defineHOOKPROC_MAGIC_ALLOCATED0x80090ca
+#defineHOOKPROC_MAGIC_ONLIST   0x80090c0
+struct hookproc {
+   /* Magic. */
+   int hp_magic;
+   /* PID of a forked child. */
+   pid_t   hp_pid;
+   /* When process were forked? */
+   time_t  hp_birthtime;
+   /* When we logged previous reported? */
+   time_t  hp_lastreport;
+   /* Path to executable and all the arguments we passed. */
+   charhp_comm[PATH_MAX];
+   TAILQ_ENTRY(hookproc) hp_next;
+};
+static TAILQ_HEAD(, hookproc) hookprocs;
+static pthread_mutex_t hookprocs_lock;
 
 static void
 descriptors(void)
@@ -108,28 +143,197 @@ descriptors(void)
}
 }
 
-int
+void
+hook_init(void)
+{
+
+   mtx_init(&hookprocs_lock);
+   TAILQ_INIT(&hookprocs);
+   hooks_initialized = true;
+}
+
+static struct hookproc *
+hook_alloc(const char *path, char **args)
+{
+   struct hookproc *hp;
+   unsigned int ii;
+
+   hp = malloc(sizeof(*hp));
+   if (hp == NULL) {
+   pjdlog_error("Unable to allocate %zu bytes of memory for a 
hook.",
+   sizeof(*hp));
+   return (NULL);
+   }
+
+   hp->hp_pid = 0;
+   hp->hp_birthtime = hp->hp_lastreport = time(NULL);
+   (void)strlcpy(hp->hp_comm, path, sizeof(hp->hp_comm));
+   /* We start at 2nd argument as we don't want to have exec name twice. */
+   for (ii = 1; args[ii] != NULL; ii++) {
+   (void)strlcat(hp->hp_comm, " ", sizeof(hp->hp_comm));
+   (void)strlcat(hp->hp_comm, args[ii], sizeof(hp->hp_comm));
+   }
+   if (strlen(hp->hp_comm) >= sizeof(hp->hp_comm) - 1) {
+   pjdlog_error("Exec path too long, correct configuration file.");
+   free(hp);
+   return (NULL);
+   }
+   hp->hp_magic = HOOKPROC_MAGIC_ALLOCATED;
+   return (hp);
+}
+
+static void
+hook_add(struct hookproc *hp, pid_t pid)
+{
+
+   assert(hp->hp_magic == HOOKPROC_MAGIC_ALLOCATED);
+   assert(hp->hp_pid == 0);
+
+   hp->hp_pid = pid;
+   mtx_lock(&hookprocs_lock);
+   hp->hp_magic = HOOKPROC_MAGIC_ONLIST;
+   TAILQ_INSERT_TAIL(&hookprocs, hp, hp_next);
+   mtx_unlock(&hookprocs_lock);
+}
+
+static void
+hook_remove(struct hookproc *hp)
+{
+
+   assert(hp->hp_magic == HOOKPROC_MAGIC_ONLIST);
+   assert(hp->hp_pid > 0);
+   assert(mtx_owned(&hookprocs_lock));
+
+   TAILQ_REMOVE(&hookprocs, hp, hp_next);
+   hp->hp_magic = HOOKPROC_MAGIC_ALLOCATED;
+}
+
+static void
+hook_free(struct hookproc *hp)
+{
+
+   assert(hp->hp_magic == HOOKPROC_MAGIC_ALLOCATED);
+   assert(hp->hp_pid > 0);
+
+   hp->hp_magic = 0;
+   free(hp);
+}
+
+static struct hookproc *
+hook_find(pid_t pid)
+{
+   struct hookproc *hp;
+
+   assert(mtx_owned(&hookprocs_lock));
+
+   TAILQ_FOREACH(hp, &hookprocs, hp_next) {
+   assert(hp->hp_magic == HOOKPROC_MAGIC_ONLIST);
+   assert(hp->hp_pid > 0);
+
+   if (hp->hp_pid == pid)
+   break;
+   }
+
+   return (hp);
+}
+
+void
+hook_check(bool sigchld)

svn commit: r211884 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 14:35:39 2010
New Revision: 211884
URL: http://svn.freebsd.org/changeset/base/211884

Log:
  When logging to stdout/stderr don't close those descriptors after fork().
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/hooks.c

Modified: head/sbin/hastd/hooks.c
==
--- head/sbin/hastd/hooks.c Fri Aug 27 14:28:39 2010(r211883)
+++ head/sbin/hastd/hooks.c Fri Aug 27 14:35:39 2010(r211884)
@@ -61,8 +61,21 @@ descriptors(void)
pjdlog_errno(LOG_WARNING, "sysconf(_SC_OPEN_MAX) failed");
maxfd = 1024;
}
-   for (fd = 0; fd <= maxfd; fd++)
-   close(fd);
+   for (fd = 0; fd <= maxfd; fd++) {
+   switch (fd) {
+   case STDIN_FILENO:
+   case STDOUT_FILENO:
+   case STDERR_FILENO:
+   if (pjdlog_mode_get() == PJDLOG_MODE_STD)
+   break;
+   /* FALLTHROUGH */
+   default:
+   close(fd);
+   break;
+   }
+   }
+   if (pjdlog_mode_get() == PJDLOG_MODE_STD)
+   return;
/*
 * Redirect stdin, stdout and stderr to /dev/null.
 */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211883 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 14:28:39 2010
New Revision: 211883
URL: http://svn.freebsd.org/changeset/base/211883

Log:
  Reduce indent where possible.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/parse.y

Modified: head/sbin/hastd/parse.y
==
--- head/sbin/hastd/parse.y Fri Aug 27 14:26:37 2010(r211882)
+++ head/sbin/hastd/parse.y Fri Aug 27 14:28:39 2010(r211883)
@@ -256,13 +256,13 @@ control_statement:CONTROL STR
}
break;
case 1:
-   if (mynode) {
-   if (strlcpy(lconfig->hc_controladdr, $2,
-   sizeof(lconfig->hc_controladdr)) >=
-   sizeof(lconfig->hc_controladdr)) {
-   pjdlog_error("control argument is too 
long.");
-   return (1);
-   }
+   if (!mynode)
+   break;
+   if (strlcpy(lconfig->hc_controladdr, $2,
+   sizeof(lconfig->hc_controladdr)) >=
+   sizeof(lconfig->hc_controladdr)) {
+   pjdlog_error("control argument is too long.");
+   return (1);
}
break;
default:
@@ -283,13 +283,13 @@ listen_statement: LISTEN STR
}
break;
case 1:
-   if (mynode) {
-   if (strlcpy(lconfig->hc_listenaddr, $2,
-   sizeof(lconfig->hc_listenaddr)) >=
-   sizeof(lconfig->hc_listenaddr)) {
-   pjdlog_error("listen argument is too 
long.");
-   return (1);
-   }
+   if (!mynode)
+   break;
+   if (strlcpy(lconfig->hc_listenaddr, $2,
+   sizeof(lconfig->hc_listenaddr)) >=
+   sizeof(lconfig->hc_listenaddr)) {
+   pjdlog_error("listen argument is too long.");
+   return (1);
}
break;
default:
@@ -493,14 +493,14 @@ name_statement:   NAME STR
}
break;
case 2:
-   if (mynode) {
-   assert(curres != NULL);
-   if (strlcpy(curres->hr_provname, $2,
-   sizeof(curres->hr_provname)) >=
-   sizeof(curres->hr_provname)) {
-   pjdlog_error("name argument is too 
long.");
-   return (1);
-   }
+   if (!mynode)
+   break;
+   assert(curres != NULL);
+   if (strlcpy(curres->hr_provname, $2,
+   sizeof(curres->hr_provname)) >=
+   sizeof(curres->hr_provname)) {
+   pjdlog_error("name argument is too long.");
+   return (1);
}
break;
default:
@@ -521,14 +521,14 @@ local_statement:  LOCAL STR
}
break;
case 2:
-   if (mynode) {
-   assert(curres != NULL);
-   if (strlcpy(curres->hr_localpath, $2,
-   sizeof(curres->hr_localpath)) >=
-   sizeof(curres->hr_localpath)) {
-   pjdlog_error("local argument is too 
long.");
-   return (1);
-   }
+   if (!mynode)
+   break;
+   assert(curres != NULL);
+   if (strlcpy(curres->hr_localpath, $2,
+   sizeof(curres->hr_localpath)) >=
+   sizeof(curres->hr_localpath)) {
+   pjdlog_error("local argument is too long.");
+   return (1);
}
break;
default:
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscr

svn commit: r211882 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 14:26:37 2010
New Revision: 211882
URL: http://svn.freebsd.org/changeset/base/211882

Log:
  Implement keepalive mechanism inside HAST protocol so we can detect secondary
  node failures quickly for HAST resources that are rarely modified.
  
  Remove XXX from a comment now that the guard thread never sleeps infinitely.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/hast.h
  head/sbin/hastd/primary.c
  head/sbin/hastd/secondary.c

Modified: head/sbin/hastd/hast.h
==
--- head/sbin/hastd/hast.h  Fri Aug 27 14:12:53 2010(r211881)
+++ head/sbin/hastd/hast.h  Fri Aug 27 14:26:37 2010(r211882)
@@ -48,7 +48,12 @@
 
 #include "proto.h"
 
-#defineHAST_PROTO_VERSION  0
+/*
+ * Version history:
+ * 0 - initial version
+ * 1 - HIO_KEEPALIVE added
+ */
+#defineHAST_PROTO_VERSION  1
 
 #defineEHAST_OK0
 #defineEHAST_NOENTRY   1
@@ -74,6 +79,7 @@
 #defineHIO_WRITE   2
 #defineHIO_DELETE  3
 #defineHIO_FLUSH   4
+#defineHIO_KEEPALIVE   5
 
 #defineHAST_TIMEOUT5
 #defineHAST_CONFIG "/etc/hast.conf"

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Fri Aug 27 14:12:53 2010(r211881)
+++ head/sbin/hastd/primary.c   Fri Aug 27 14:26:37 2010(r211882)
@@ -151,7 +151,11 @@ static pthread_mutex_t metadata_lock;
  */
 #defineHAST_NCOMPONENTS2
 /*
- * Number of seconds to sleep before next reconnect try.
+ * Number of seconds to sleep between keepalive packets.
+ */
+#defineKEEPALIVE_SLEEP 10
+/*
+ * Number of seconds to sleep between reconnect retries.
  */
 #defineRECONNECT_SLEEP 5
 
@@ -886,11 +890,14 @@ remote_close(struct hast_resource *res, 
sync_stop();
 
/*
-* Wake up guard thread, so it can immediately start reconnect.
+* Wake up guard thread (if we are not called from within guard thread),
+* so it can immediately start reconnect.
 */
-   mtx_lock(&hio_guard_lock);
-   cv_signal(&hio_guard_cond);
-   mtx_unlock(&hio_guard_lock);
+   if (!mtx_owned(&hio_guard_lock)) {
+   mtx_lock(&hio_guard_lock);
+   cv_signal(&hio_guard_cond);
+   mtx_unlock(&hio_guard_lock);
+   }
 }
 
 /*
@@ -1734,7 +1741,7 @@ sighandler(int sig)
assert(!"invalid condition");
}
/*
-* XXX: Racy, but if we cannot obtain hio_guard_lock here, we don't
+* Racy, but if we cannot obtain hio_guard_lock here, we don't
 * want to risk deadlock.
 */
unlock = mtx_trylock(&hio_guard_lock);
@@ -1851,6 +1858,32 @@ failed:
pjdlog_warning("Configuration not reloaded.");
 }
 
+static void
+keepalive_send(struct hast_resource *res, unsigned int ncomp)
+{
+   struct nv *nv;
+
+   nv = nv_alloc();
+   nv_add_uint8(nv, HIO_KEEPALIVE, "cmd");
+   if (nv_error(nv) != 0) {
+   nv_free(nv);
+   pjdlog_debug(1,
+   "keepalive_send: Unable to prepare header to send.");
+   return;
+   }
+   if (hast_proto_send(res, res->hr_remoteout, nv, NULL, 0) < 0) {
+   pjdlog_common(LOG_DEBUG, 1, errno,
+   "keepalive_send: Unable to send request");
+   nv_free(nv);
+   rw_unlock(&hio_remote_lock[ncomp]);
+   remote_close(res, ncomp);
+   rw_rlock(&hio_remote_lock[ncomp]);
+   return;
+   }
+   nv_free(nv);
+   pjdlog_debug(2, "keepalive_send: Request sent.");
+}
+
 /*
  * Thread guards remote connections and reconnects when needed, handles
  * signals, etc.
@@ -1874,14 +1907,8 @@ guard_thread(void *arg)
sighup_received = false;
config_reload();
}
-   /*
-* If all the connection will be fine, we will sleep until
-* someone wakes us up.
-* If any of the connections will be broken and we won't be
-* able to connect, we will sleep only for RECONNECT_SLEEP
-* seconds so we can retry soon.
-*/
-   timeout = 0;
+
+   timeout = KEEPALIVE_SLEEP;
pjdlog_debug(2, "remote_guard: Checking connections.");
mtx_lock(&hio_guard_lock);
for (ii = 0; ii < ncomps; ii++) {
@@ -1891,6 +1918,11 @@ guard_thread(void *arg)
if (ISCONNECTED(res, ii)) {
assert(res->hr_remotein != NULL);
assert(res->hr_remoteou

svn commit: r211881 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 14:12:53 2010
New Revision: 211881
URL: http://svn.freebsd.org/changeset/base/211881

Log:
  - Remove redundant and incorrect 'old' word from debug message.
  - Log disconnects as warnings.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Fri Aug 27 14:10:25 2010(r211880)
+++ head/sbin/hastd/primary.c   Fri Aug 27 14:12:53 2010(r211881)
@@ -867,17 +867,19 @@ remote_close(struct hast_resource *res, 
assert(res->hr_remotein != NULL);
assert(res->hr_remoteout != NULL);
 
-   pjdlog_debug(2, "Closing old incoming connection to %s.",
+   pjdlog_debug(2, "Closing incoming connection to %s.",
res->hr_remoteaddr);
proto_close(res->hr_remotein);
res->hr_remotein = NULL;
-   pjdlog_debug(2, "Closing old outgoing connection to %s.",
+   pjdlog_debug(2, "Closing outgoing connection to %s.",
res->hr_remoteaddr);
proto_close(res->hr_remoteout);
res->hr_remoteout = NULL;
 
rw_unlock(&hio_remote_lock[ncomp]);
 
+   pjdlog_warning("Disconnected from %s.", res->hr_remoteaddr);
+
/*
 * Stop synchronization if in-progress.
 */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211880 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 14:10:25 2010
New Revision: 211880
URL: http://svn.freebsd.org/changeset/base/211880

Log:
  Don't increase number synchronized bytes in case of an error.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Fri Aug 27 14:08:10 2010(r211879)
+++ head/sbin/hastd/primary.c   Fri Aug 27 14:10:25 2010(r211880)
@@ -1699,15 +1699,14 @@ sync_thread(void *arg __unused)
strerror(hio->hio_errors[ncomp]));
goto free_queue;
}
+
+   synced += length;
 free_queue:
mtx_lock(&range_lock);
rangelock_del(range_sync, offset, length);
if (range_regular_wait)
cv_signal(&range_regular_cond);
mtx_unlock(&range_lock);
-
-   synced += length;
-
pjdlog_debug(2, "sync: (%p) Moving request to the free queue.",
hio);
QUEUE_INSERT2(hio, free);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211879 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 14:08:10 2010
New Revision: 211879
URL: http://svn.freebsd.org/changeset/base/211879

Log:
  Log that synchronization was interrupted in a proper place.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Fri Aug 27 14:06:00 2010(r211878)
+++ head/sbin/hastd/primary.c   Fri Aug 27 14:08:10 2010(r211879)
@@ -1495,10 +1495,17 @@ sync_thread(void *arg __unused)
 
ncomps = HAST_NCOMPONENTS;
dorewind = true;
-   synced = 0;
+   synced = -1;
 
for (;;) {
mtx_lock(&sync_lock);
+   if (synced == -1)
+   synced = 0;
+   else if (!sync_inprogress) {
+   pjdlog_info("Synchronization interrupted. "
+   "%jd bytes synchronized so far.",
+   (intmax_t)synced);
+   }
while (!sync_inprogress) {
dorewind = true;
synced = 0;
@@ -1559,10 +1566,6 @@ sync_thread(void *arg __unused)
(uintmax_t)res->hr_secondary_localcnt);
(void)metadata_write(res);
mtx_unlock(&metadata_lock);
-   } else if (synced > 0) {
-   pjdlog_info("Synchronization interrupted. "
-   "%jd bytes synchronized so far.",
-   (intmax_t)synced);
}
rw_unlock(&hio_remote_lock[ncomp]);
continue;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211878 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 14:06:00 2010
New Revision: 211878
URL: http://svn.freebsd.org/changeset/base/211878

Log:
  We have sync_start() function to start synchronization, introduce sync_stop()
  function to stop it.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Fri Aug 27 14:01:28 2010(r211877)
+++ head/sbin/hastd/primary.c   Fri Aug 27 14:06:00 2010(r211878)
@@ -686,6 +686,16 @@ sync_start(void)
 }
 
 static void
+sync_stop(void)
+{
+
+   mtx_lock(&sync_lock);
+   if (sync_inprogress)
+   sync_inprogress = false;
+   mtx_unlock(&sync_lock);
+}
+
+static void
 init_ggate(struct hast_resource *res)
 {
struct g_gate_ctl_create ggiocreate;
@@ -871,10 +881,7 @@ remote_close(struct hast_resource *res, 
/*
 * Stop synchronization if in-progress.
 */
-   mtx_lock(&sync_lock);
-   if (sync_inprogress)
-   sync_inprogress = false;
-   mtx_unlock(&sync_lock);
+   sync_stop();
 
/*
 * Wake up guard thread, so it can immediately start reconnect.
@@ -1526,9 +1533,7 @@ sync_thread(void *arg __unused)
}
}
if (offset < 0) {
-   mtx_lock(&sync_lock);
-   sync_inprogress = false;
-   mtx_unlock(&sync_lock);
+   sync_stop();
pjdlog_debug(1, "Nothing to synchronize.");
/*
 * Synchronization complete, make both localcnt and
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211877 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 14:01:28 2010
New Revision: 211877
URL: http://svn.freebsd.org/changeset/base/211877

Log:
  Add QUEUE_INSERT() and QUEUE_TAKE() macros that simplify the code a bit.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/secondary.c

Modified: head/sbin/hastd/secondary.c
==
--- head/sbin/hastd/secondary.c Fri Aug 27 13:58:38 2010(r211876)
+++ head/sbin/hastd/secondary.c Fri Aug 27 14:01:28 2010(r211877)
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2009-2010 The FreeBSD Foundation
+ * Copyright (c) 2010 Pawel Jakub Dawidek 
  * All rights reserved.
  *
  * This software was developed by Pawel Jakub Dawidek under sponsorship from
@@ -102,6 +103,26 @@ static void *recv_thread(void *arg);
 static void *disk_thread(void *arg);
 static void *send_thread(void *arg);
 
+#defineQUEUE_INSERT(name, hio) do {
\
+   bool _wakeup;   \
+   \
+   mtx_lock(&hio_##name##_list_lock);  \
+   _wakeup = TAILQ_EMPTY(&hio_##name##_list);  \
+   TAILQ_INSERT_TAIL(&hio_##name##_list, (hio), hio_next); \
+   mtx_unlock(&hio_##name##_list_lock);\
+   if (_wakeup)\
+   cv_signal(&hio_##name##_list_cond); \
+} while (0)
+#defineQUEUE_TAKE(name, hio)   do {
\
+   mtx_lock(&hio_##name##_list_lock);  \
+   while (((hio) = TAILQ_FIRST(&hio_##name##_list)) == NULL) { \
+   cv_wait(&hio_##name##_list_cond,\
+   &hio_##name##_list_lock);   \
+   }   \
+   TAILQ_REMOVE(&hio_##name##_list, (hio), hio_next);  \
+   mtx_unlock(&hio_##name##_list_lock);\
+} while (0)
+
 static void
 init_environment(void)
 {
@@ -478,24 +499,22 @@ recv_thread(void *arg)
 {
struct hast_resource *res = arg;
struct hio *hio;
-   bool wakeup;
 
for (;;) {
pjdlog_debug(2, "recv: Taking free request.");
-   mtx_lock(&hio_free_list_lock);
-   while ((hio = TAILQ_FIRST(&hio_free_list)) == NULL) {
-   pjdlog_debug(2, "recv: No free requests, waiting.");
-   cv_wait(&hio_free_list_cond, &hio_free_list_lock);
-   }
-   TAILQ_REMOVE(&hio_free_list, hio, hio_next);
-   mtx_unlock(&hio_free_list_lock);
+   QUEUE_TAKE(free, hio);
pjdlog_debug(2, "recv: (%p) Got request.", hio);
if (hast_proto_recv_hdr(res->hr_remotein, &hio->hio_nv) < 0) {
pjdlog_exit(EX_TEMPFAIL,
"Unable to receive request header");
}
-   if (requnpack(res, hio) != 0)
-   goto send_queue;
+   if (requnpack(res, hio) != 0) {
+   pjdlog_debug(2,
+   "recv: (%p) Moving request to the send queue.",
+   hio);
+   QUEUE_INSERT(send, hio);
+   continue;
+   }
reqlog(LOG_DEBUG, 2, -1, hio,
"recv: (%p) Got request header: ", hio);
if (hio->hio_cmd == HIO_WRITE) {
@@ -507,22 +526,7 @@ recv_thread(void *arg)
}
pjdlog_debug(2, "recv: (%p) Moving request to the disk queue.",
hio);
-   mtx_lock(&hio_disk_list_lock);
-   wakeup = TAILQ_EMPTY(&hio_disk_list);
-   TAILQ_INSERT_TAIL(&hio_disk_list, hio, hio_next);
-   mtx_unlock(&hio_disk_list_lock);
-   if (wakeup)
-   cv_signal(&hio_disk_list_cond);
-   continue;
-send_queue:
-   pjdlog_debug(2, "recv: (%p) Moving request to the send queue.",
-   hio);
-   mtx_lock(&hio_send_list_lock);
-   wakeup = TAILQ_EMPTY(&hio_send_list);
-   TAILQ_INSERT_TAIL(&hio_send_list, hio, hio_next);
-   mtx_unlock(&hio_send_list_lock);
-   if (wakeup)
-   cv_signal(&hio_send_list_cond);
+   QUEUE_INSERT(disk, hio);
}
/* NOTREACHED */
return (N

svn commit: r211876 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 13:58:38 2010
New Revision: 211876
URL: http://svn.freebsd.org/changeset/base/211876

Log:
  Add mtx_owned() implementation.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/synch.h

Modified: head/sbin/hastd/synch.h
==
--- head/sbin/hastd/synch.h Fri Aug 27 13:54:17 2010(r211875)
+++ head/sbin/hastd/synch.h Fri Aug 27 13:58:38 2010(r211876)
@@ -33,7 +33,9 @@
 #define_SYNCH_H_
 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 
@@ -70,6 +72,12 @@ mtx_unlock(pthread_mutex_t *lock)
error = pthread_mutex_unlock(lock);
assert(error == 0);
 }
+static __inline bool
+mtx_owned(pthread_mutex_t *lock)
+{
+
+   return (pthread_mutex_isowned_np(lock) != 0);
+}
 
 static __inline void
 rw_init(pthread_rwlock_t *lock)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211875 - head/sbin/hastd

2010-08-27 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 27 13:54:17 2010
New Revision: 211875
URL: http://svn.freebsd.org/changeset/base/211875

Log:
  Make comment more readable.
  
  MFC after:2 weeks
  Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com

Modified:
  head/sbin/hastd/proto_tcp4.c

Modified: head/sbin/hastd/proto_tcp4.c
==
--- head/sbin/hastd/proto_tcp4.cFri Aug 27 12:34:53 2010
(r211874)
+++ head/sbin/hastd/proto_tcp4.cFri Aug 27 13:54:17 2010
(r211875)
@@ -242,8 +242,8 @@ tcp4_connect(void *ctx)
return (errno);
}
/*
-* We make socket non-blocking so we have decided about connection
-* timeout.
+* We make socket non-blocking so we can handle connection timeout
+* manually.
 */
flags |= O_NONBLOCK;
if (fcntl(tctx->tc_fd, F_SETFL, flags) == -1) {
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r211859 - head/lib/libthr/thread

2010-08-27 Thread Pawel Jakub Dawidek
On Fri, Aug 27, 2010 at 03:23:07AM +, David Xu wrote:
[...]

Hi David.

While you at libthr... I found implementation of
_pthread_mutex_isowned_np(), which makes me wonder:

int
_pthread_mutex_isowned_np(pthread_mutex_t *mutex)
{
struct pthread *curthread = _get_curthread();
int ret;

if (__predict_false(*mutex == NULL)) {
ret = init_static(curthread, mutex);
if (__predict_false(ret))
return (ret);
}
return ((*mutex)->m_owner == curthread);
}

When init_static() fails, the caller will interpret the answer as 'true',
which seems wrong. What does this if statement do exactly? It
initializes mutex if it isn't? If so, can't we simply assert that it has
to be initialized?

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgpcSVQWuhuRW.pgp
Description: PGP signature


svn commit: r211855 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2010-08-26 Thread Pawel Jakub Dawidek
Author: pjd
Date: Thu Aug 26 23:44:32 2010
New Revision: 211855
URL: http://svn.freebsd.org/changeset/base/211855

Log:
  Update comment now that I finally committed r211854.
  
  MFC after:1 month

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.cThu Aug 
26 23:41:40 2010(r211854)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.cThu Aug 
26 23:44:32 2010(r211855)
@@ -1563,15 +1563,9 @@ zfs_vget(vfs_t *vfsp, ino_t ino, int fla
int err;
 
/*
-* XXXPJD: zfs_zget() can't operate on virtual entires like .zfs/ or
-* .zfs/snapshot/ directories, so for now just return EOPNOTSUPP.
-* This will make NFS to fall back to using READDIR instead of
-* READDIRPLUS.
-* Also snapshots are stored in AVL tree, but based on their names,
-* not inode numbers, so it will be very inefficient to iterate
-* over all snapshots to find the right one.
-* Note that OpenSolaris READDIRPLUS implementation does LOOKUP on
-* d_name, and not VGET on d_fileno as we do.
+* zfs_zget() can't operate on virtual entires like .zfs/ or
+* .zfs/snapshot/ directories, that's why we return EOPNOTSUPP.
+* This will make NFS to switch to LOOKUP instead of using VGET.
 */
if (ino == ZFSCTL_INO_ROOT || ino == ZFSCTL_INO_SNAPDIR)
return (EOPNOTSUPP);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211854 - head/sys/nfsserver

2010-08-26 Thread Pawel Jakub Dawidek
Author: pjd
Date: Thu Aug 26 23:41:40 2010
New Revision: 211854
URL: http://svn.freebsd.org/changeset/base/211854

Log:
  - When VFS_VGET() is not supported, switch to VOP_LOOKUP().
  - We are fine by only share-locking the vnode.
  - Remove assertion that doesn't hold for ZFS where we cross mount points
boundaries by going into .zfs/snapshot//.
  
  Reviewed by:  rmacklem
  MFC after:1 month

Modified:
  head/sys/nfsserver/nfs_serv.c

Modified: head/sys/nfsserver/nfs_serv.c
==
--- head/sys/nfsserver/nfs_serv.c   Thu Aug 26 23:33:04 2010
(r211853)
+++ head/sys/nfsserver/nfs_serv.c   Thu Aug 26 23:41:40 2010
(r211854)
@@ -3041,7 +3041,8 @@ nfsrv_readdirplus(struct nfsrv_descript 
u_quad_t off, toff, verf;
u_long *cookies = NULL, *cookiep; /* needs to be int64_t or off_t */
int v3 = (nfsd->nd_flag & ND_NFSV3);
-   int vfslocked;
+   int usevget = 1, vfslocked;
+   struct componentname cn;
 
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
vfslocked = 0;
@@ -3186,28 +3187,6 @@ again:
goto again;
}
 
-   /*
-* Probe one of the directory entries to see if the filesystem
-* supports VGET.
-*/
-   error = VFS_VGET(vp->v_mount, dp->d_fileno, LK_EXCLUSIVE, &nvp);
-   if (error) {
-   if (error == EOPNOTSUPP)
-   error = NFSERR_NOTSUPP;
-   else
-   error = NFSERR_SERVERFAULT;
-   vrele(vp);
-   vp = NULL;
-   free((caddr_t)cookies, M_TEMP);
-   free((caddr_t)rbuf, M_TEMP);
-   nfsm_reply(NFSX_V3POSTOPATTR);
-   nfsm_srvpostop_attr(getret, &at);
-   error = 0;
-   goto nfsmout;
-   }
-   vput(nvp);
-   nvp = NULL;
-
dirlen = len = NFSX_V3POSTOPATTR + NFSX_V3COOKIEVERF +
2 * NFSX_UNSIGNED;
nfsm_reply(cnt);
@@ -3224,23 +3203,49 @@ again:
nlen = dp->d_namlen;
rem = nfsm_rndup(nlen)-nlen;
 
-   /*
-* For readdir_and_lookup get the vnode using
-* the file number.
-*/
-   if (VFS_VGET(vp->v_mount, dp->d_fileno, LK_EXCLUSIVE,
-   &nvp))
-   goto invalid;
+   if (usevget) {
+   /*
+* For readdir_and_lookup get the vnode using
+* the file number.
+*/
+   error = VFS_VGET(vp->v_mount, dp->d_fileno,
+   LK_SHARED, &nvp);
+   if (error != 0 && error != EOPNOTSUPP) {
+   error = 0;
+   goto invalid;
+   } else if (error == EOPNOTSUPP) {
+   /*
+* VFS_VGET() not supported?
+* Let's switch to VOP_LOOKUP().
+*/
+   error = 0;
+   usevget = 0;
+   cn.cn_nameiop = LOOKUP;
+   cn.cn_flags = ISLASTCN | NOFOLLOW | \
+   LOCKSHARED | LOCKLEAF | MPSAFE;
+   cn.cn_lkflags = LK_SHARED | LK_RETRY;
+   cn.cn_cred = cred;
+   cn.cn_thread = curthread;
+   }
+   }
+   if (!usevget) {
+   cn.cn_nameptr = dp->d_name;
+   cn.cn_namelen = dp->d_namlen;
+   if (dp->d_namlen == 2 &&
+   dp->d_name[0] == '.' &&
+   dp->d_name[1] == '.') {
+   cn.cn_flags |= ISDOTDOT;
+   } else {
+   cn.cn_flags &= ~ISDOTDOT;
+   }
+   if (!VOP_ISLOCKED(vp))
+   vn_lock(vp, LK_SHARED | LK_RETRY);
+   if (VOP_LOOKUP(vp, &nvp, &cn) != 0)
+   goto invalid;
+   }
+
bzero((caddr_t)nfhp, NFSX_V3FH);
-   nfhp->fh_fsid =
-   nvp->v_mount->mnt_stat.f_fsid;
-   /*
-* XXXRW: Assert the mountpoints are

svn commit: r211853 - head/sys/rpc

2010-08-26 Thread Pawel Jakub Dawidek
Author: pjd
Date: Thu Aug 26 23:33:04 2010
New Revision: 211853
URL: http://svn.freebsd.org/changeset/base/211853

Log:
  - Check the result of malloc(M_NOWAIT) in replay_alloc(). The caller
(replay_alloc()) knows how to handle replay_alloc() failure.
  - Eliminate 'freed_one' variable, it is not needed - when no entry is found
rce will be NULL.
  - Add locking assertions where we expect a rc_lock to be held.
  
  Reviewed by:  rmacklem
  MFC after:2 weeks

Modified:
  head/sys/rpc/replay.c

Modified: head/sys/rpc/replay.c
==
--- head/sys/rpc/replay.c   Thu Aug 26 22:07:27 2010(r211852)
+++ head/sys/rpc/replay.c   Thu Aug 26 23:33:04 2010(r211853)
@@ -113,8 +113,12 @@ replay_alloc(struct replay_cache *rc,
 {
struct replay_cache_entry *rce;
 
+   mtx_assert(&rc->rc_lock, MA_OWNED);
+
rc->rc_count++;
rce = malloc(sizeof(*rce), M_RPC, M_NOWAIT|M_ZERO);
+   if (!rce)
+   return (NULL);
rce->rce_hash = h;
rce->rce_msg = *msg;
bcopy(addr, &rce->rce_addr, addr->sa_len);
@@ -129,6 +133,8 @@ static void
 replay_free(struct replay_cache *rc, struct replay_cache_entry *rce)
 {
 
+   mtx_assert(&rc->rc_lock, MA_OWNED);
+
rc->rc_count--;
TAILQ_REMOVE(&rc->rc_cache[rce->rce_hash], rce, rce_link);
TAILQ_REMOVE(&rc->rc_all, rce, rce_alllink);
@@ -143,26 +149,25 @@ static void
 replay_prune(struct replay_cache *rc)
 {
struct replay_cache_entry *rce;
-   bool_t freed_one;
 
-   if (rc->rc_count >= REPLAY_MAX || rc->rc_size > rc->rc_maxsize) {
-   do {
-   freed_one = FALSE;
-   /*
-* Try to free an entry. Don't free in-progress entries
-*/
-   TAILQ_FOREACH_REVERSE(rce, &rc->rc_all,
-   replay_cache_list, rce_alllink) {
-   if (rce->rce_repmsg.rm_xid) {
-   replay_free(rc, rce);
-   freed_one = TRUE;
-   break;
-   }
-   }
-   } while (freed_one
-   && (rc->rc_count >= REPLAY_MAX
-   || rc->rc_size > rc->rc_maxsize));
-   }
+   mtx_assert(&rc->rc_lock, MA_OWNED);
+
+   if (rc->rc_count < REPLAY_MAX && rc->rc_size <= rc->rc_maxsize)
+   return;
+
+   do {
+   /*
+* Try to free an entry. Don't free in-progress entries.
+*/
+   TAILQ_FOREACH_REVERSE(rce, &rc->rc_all, replay_cache_list,
+   rce_alllink) {
+   if (rce->rce_repmsg.rm_xid)
+   break;
+   }
+   if (rce)
+   replay_free(rc, rce);
+   } while (rce && (rc->rc_count >= REPLAY_MAX
+   || rc->rc_size > rc->rc_maxsize));
 }
 
 enum replay_state
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r211830 - head/sys/rpc

2010-08-26 Thread Pawel Jakub Dawidek
On Wed, Aug 25, 2010 at 11:23:00PM +, Rick Macklem wrote:
> Author: rmacklem
> Date: Wed Aug 25 23:23:00 2010
> New Revision: 211830
> URL: http://svn.freebsd.org/changeset/base/211830
> 
> Log:
>   Add mutex locking for the call to replay_prune() in
>   replay_setsize(), since replay_prune() expects the
>   rc_lock to be held when it is called.

Ah! Rick, I've more fixes to this file. Could you review the following
patch:

http://people.freebsd.org/~pjd/patches/rpc_replay.c.patch

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgpLJRiRwj0d7.pgp
Description: PGP signature


Re: svn commit: r211501 - in head/sys: modules modules/send netinet netinet6 sys

2010-08-22 Thread Pawel Jakub Dawidek
On Thu, Aug 19, 2010 at 06:33:40PM -0700, Doug Barton wrote:
> On 08/19/2010 14:50, Bjoern A. Zeeb wrote:
> >Yes I can: soon will be when it'll be comitted.
> 
> I'm guessing that's an attempt at humor, [...]
[...]
> [...] If the answer is "someday" 
> then I'm going to request that the code be backed out until the man 
> page(s) are done. [...]

I'm guessing that's an attempt at humor?

What Ana should learn from this and I'm sure she will is that if she is
going to commit manual page later, she shouldn't mention that. This way
nobody's time will be wasted, because nobody will notice that manual
page was missing in the first place until its committed.

PS. Great stuff, Ana, keep up the good work!:)

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgpjW3wPuMMN2.pgp
Description: PGP signature


svn commit: r211474 - in head/tools/regression/pjdfstest/tests: chflags chmod chown link mkdir mkfifo mknod open rename rmdir symlink

2010-08-18 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Aug 18 22:06:43 2010
New Revision: 211474
URL: http://svn.freebsd.org/changeset/base/211474

Log:
  More tests.

Modified:
  head/tools/regression/pjdfstest/tests/chflags/01.t
  head/tools/regression/pjdfstest/tests/chmod/01.t
  head/tools/regression/pjdfstest/tests/chmod/06.t
  head/tools/regression/pjdfstest/tests/chown/01.t
  head/tools/regression/pjdfstest/tests/link/01.t
  head/tools/regression/pjdfstest/tests/link/10.t
  head/tools/regression/pjdfstest/tests/mkdir/01.t
  head/tools/regression/pjdfstest/tests/mkfifo/01.t
  head/tools/regression/pjdfstest/tests/mkfifo/09.t
  head/tools/regression/pjdfstest/tests/mknod/01.t
  head/tools/regression/pjdfstest/tests/mknod/08.t
  head/tools/regression/pjdfstest/tests/open/01.t
  head/tools/regression/pjdfstest/tests/rename/12.t
  head/tools/regression/pjdfstest/tests/rmdir/06.t
  head/tools/regression/pjdfstest/tests/symlink/08.t

Modified: head/tools/regression/pjdfstest/tests/chflags/01.t
==
--- head/tools/regression/pjdfstest/tests/chflags/01.t  Wed Aug 18 21:51:05 
2010(r211473)
+++ head/tools/regression/pjdfstest/tests/chflags/01.t  Wed Aug 18 22:06:43 
2010(r211474)
@@ -8,13 +8,15 @@ dir=`dirname $0`
 
 require chflags
 
-echo "1..5"
+echo "1..17"
 
 n0=`namegen`
 n1=`namegen`
 
 expect 0 mkdir ${n0} 0755
-expect 0 create ${n0}/${n1} 0644
-expect ENOTDIR chflags ${n0}/${n1}/test SF_IMMUTABLE
-expect 0 unlink ${n0}/${n1}
+for type in regular fifo block char socket; do
+   create_file ${type} ${n0}/${n1}
+   expect ENOTDIR chflags ${n0}/${n1}/test SF_IMMUTABLE
+   expect 0 unlink ${n0}/${n1}
+done
 expect 0 rmdir ${n0}

Modified: head/tools/regression/pjdfstest/tests/chmod/01.t
==
--- head/tools/regression/pjdfstest/tests/chmod/01.tWed Aug 18 21:51:05 
2010(r211473)
+++ head/tools/regression/pjdfstest/tests/chmod/01.tWed Aug 18 22:06:43 
2010(r211474)
@@ -6,13 +6,15 @@ desc="chmod returns ENOTDIR if a compone
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..5"
+echo "1..17"
 
 n0=`namegen`
 n1=`namegen`
 
 expect 0 mkdir ${n0} 0755
-expect 0 create ${n0}/${n1} 0644
-expect ENOTDIR chmod ${n0}/${n1}/test 0644
-expect 0 unlink ${n0}/${n1}
+for type in regular fifo block char socket; do
+   create_file ${type} ${n0}/${n1}
+   expect ENOTDIR chmod ${n0}/${n1}/test 0644
+   expect 0 unlink ${n0}/${n1}
+done
 expect 0 rmdir ${n0}

Modified: head/tools/regression/pjdfstest/tests/chmod/06.t
==
--- head/tools/regression/pjdfstest/tests/chmod/06.tWed Aug 18 21:51:05 
2010(r211473)
+++ head/tools/regression/pjdfstest/tests/chmod/06.tWed Aug 18 22:06:43 
2010(r211474)
@@ -7,9 +7,9 @@ dir=`dirname $0`
 . ${dir}/../misc.sh
 
 if supported lchmod; then
-   echo "1..8"
+   echo "1..10"
 else
-   echo "1..6"
+   echo "1..8"
 fi
 
 n0=`namegen`
@@ -17,6 +17,8 @@ n1=`namegen`
 
 expect 0 symlink ${n0} ${n1}
 expect 0 symlink ${n1} ${n0}
+expect ELOOP chmod ${n0} 0644
+expect ELOOP chmod ${n1} 0644
 expect ELOOP chmod ${n0}/test 0644
 expect ELOOP chmod ${n1}/test 0644
 if supported lchmod; then

Modified: head/tools/regression/pjdfstest/tests/chown/01.t
==
--- head/tools/regression/pjdfstest/tests/chown/01.tWed Aug 18 21:51:05 
2010(r211473)
+++ head/tools/regression/pjdfstest/tests/chown/01.tWed Aug 18 22:06:43 
2010(r211474)
@@ -6,14 +6,16 @@ desc="chown returns ENOTDIR if a compone
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..6"
+echo "1..22"
 
 n0=`namegen`
 n1=`namegen`
 
 expect 0 mkdir ${n0} 0755
-expect 0 create ${n0}/${n1} 0644
-expect ENOTDIR chown ${n0}/${n1}/test 65534 65534
-expect ENOTDIR lchown ${n0}/${n1}/test 65534 65534
-expect 0 unlink ${n0}/${n1}
+for type in regular fifo block char socket; do
+   create_file ${type} ${n0}/${n1}
+   expect ENOTDIR chown ${n0}/${n1}/test 65534 65534
+   expect ENOTDIR lchown ${n0}/${n1}/test 65534 65534
+   expect 0 unlink ${n0}/${n1}
+done
 expect 0 rmdir ${n0}

Modified: head/tools/regression/pjdfstest/tests/link/01.t
==
--- head/tools/regression/pjdfstest/tests/link/01.t Wed Aug 18 21:51:05 
2010(r211473)
+++ head/tools/regression/pjdfstest/tests/link/01.t Wed Aug 18 22:06:43 
2010(r211474)
@@ -6,17 +6,19 @@ desc="link returns ENOTDIR if a componen
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..8"
+echo "1..32"
 
 n0=`namegen`
 n1=`namegen`
 n2=`namegen`
 
 expect 0 mkdir ${n0} 0755
-expect 0 create ${n0}/${n1} 0644
-expect ENOTDIR link ${n0}/${n1}/test ${n0}/${n2}
-expect 0 create ${n0}/${n2} 0644
-expect ENOTDIR link ${n0}/${n2} ${n0}/${n1}/tes

svn commit: r211452 - head/sbin/hastd

2010-08-18 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Aug 18 12:09:27 2010
New Revision: 211452
URL: http://svn.freebsd.org/changeset/base/211452

Log:
  For some setups sending data in 128kB chunks makes communication very slow. No
  idea why. 32kB on the other hand seems to work properly everywhere.
  
  Reported by:  Thomas Steen Rasmussen 
  MFC after:3 weeks

Modified:
  head/sbin/hastd/proto_common.c

Modified: head/sbin/hastd/proto_common.c
==
--- head/sbin/hastd/proto_common.c  Wed Aug 18 09:28:12 2010
(r211451)
+++ head/sbin/hastd/proto_common.c  Wed Aug 18 12:09:27 2010
(r211452)
@@ -42,8 +42,7 @@ __FBSDID("$FreeBSD$");
 
 /* Maximum size of packet we want to use when sending data. */
 #ifndef MAX_SEND_SIZE
-//#define  MAX_SEND_SIZE   32768
-#defineMAX_SEND_SIZE   131072
+#defineMAX_SEND_SIZE   32768
 #endif
 
 int
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211410 - head/tools/regression/pjdfstest/tests/chown

2010-08-16 Thread Pawel Jakub Dawidek
Author: pjd
Date: Tue Aug 17 06:08:09 2010
New Revision: 211410
URL: http://svn.freebsd.org/changeset/base/211410

Log:
  More tests, especially for lchown(2).

Modified:
  head/tools/regression/pjdfstest/tests/chown/01.t
  head/tools/regression/pjdfstest/tests/chown/04.t
  head/tools/regression/pjdfstest/tests/chown/05.t
  head/tools/regression/pjdfstest/tests/chown/06.t
  head/tools/regression/pjdfstest/tests/chown/07.t
  head/tools/regression/pjdfstest/tests/chown/10.t

Modified: head/tools/regression/pjdfstest/tests/chown/01.t
==
--- head/tools/regression/pjdfstest/tests/chown/01.tTue Aug 17 02:50:12 
2010(r211409)
+++ head/tools/regression/pjdfstest/tests/chown/01.tTue Aug 17 06:08:09 
2010(r211410)
@@ -6,7 +6,7 @@ desc="chown returns ENOTDIR if a compone
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..5"
+echo "1..6"
 
 n0=`namegen`
 n1=`namegen`
@@ -14,5 +14,6 @@ n1=`namegen`
 expect 0 mkdir ${n0} 0755
 expect 0 create ${n0}/${n1} 0644
 expect ENOTDIR chown ${n0}/${n1}/test 65534 65534
+expect ENOTDIR lchown ${n0}/${n1}/test 65534 65534
 expect 0 unlink ${n0}/${n1}
 expect 0 rmdir ${n0}

Modified: head/tools/regression/pjdfstest/tests/chown/04.t
==
--- head/tools/regression/pjdfstest/tests/chown/04.tTue Aug 17 02:50:12 
2010(r211409)
+++ head/tools/regression/pjdfstest/tests/chown/04.tTue Aug 17 06:08:09 
2010(r211410)
@@ -6,12 +6,18 @@ desc="chown returns ENOENT if the named 
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..4"
+echo "1..9"
 
 n0=`namegen`
 n1=`namegen`
+n2=`namegen`
 
 expect 0 mkdir ${n0} 0755
 expect ENOENT chown ${n0}/${n1}/test 65534 65534
 expect ENOENT chown ${n0}/${n1} 65534 65534
+expect ENOENT lchown ${n0}/${n1}/test 65534 65534
+expect ENOENT lchown ${n0}/${n1} 65534 65534
+expect 0 symlink ${n2} ${n0}/${n1}
+expect ENOENT chown ${n0}/${n1} 65534 65534
+expect 0 unlink ${n0}/${n1}
 expect 0 rmdir ${n0}

Modified: head/tools/regression/pjdfstest/tests/chown/05.t
==
--- head/tools/regression/pjdfstest/tests/chown/05.tTue Aug 17 02:50:12 
2010(r211409)
+++ head/tools/regression/pjdfstest/tests/chown/05.tTue Aug 17 06:08:09 
2010(r211410)
@@ -6,7 +6,7 @@ desc="chown returns EACCES when search p
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..15"
+echo "1..18"
 
 n0=`namegen`
 n1=`namegen`
@@ -22,11 +22,14 @@ expect 0 -u 65534 -g 65533,65534 -- chow
 expect 65534,65533 -u 65534 -g 65534 stat ${n1}/${n2} uid,gid
 expect 0 chmod ${n1} 0644
 expect EACCES -u 65534 -g 65533,65534 -- chown ${n1}/${n2} -1 65534
+expect EACCES -u 65534 -g 65533,65534 -- lchown ${n1}/${n2} -1 65534
 expect 0 chmod ${n1} 0755
 expect 65534,65533 -u 65534 -g 65534 stat ${n1}/${n2} uid,gid
 expect 0 -u 65534 -g 65533,65534 -- chown ${n1}/${n2} -1 65534
 expect 65534,65534 -u 65534 -g 65534 stat ${n1}/${n2} uid,gid
-expect 0 -u 65534 -g 65534 unlink ${n1}/${n2}
+expect 0 -u 65534 -g 65533,65534 -- lchown ${n1}/${n2} -1 65533
+expect 65534,65533 -u 65534 -g 65533 stat ${n1}/${n2} uid,gid
+expect 0 unlink ${n1}/${n2}
 expect 0 rmdir ${n1}
 cd ${cdir}
 expect 0 rmdir ${n0}

Modified: head/tools/regression/pjdfstest/tests/chown/06.t
==
--- head/tools/regression/pjdfstest/tests/chown/06.tTue Aug 17 02:50:12 
2010(r211409)
+++ head/tools/regression/pjdfstest/tests/chown/06.tTue Aug 17 06:08:09 
2010(r211410)
@@ -6,14 +6,18 @@ desc="chown returns ELOOP if too many sy
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..6"
+echo "1..10"
 
 n0=`namegen`
 n1=`namegen`
 
 expect 0 symlink ${n0} ${n1}
 expect 0 symlink ${n1} ${n0}
+expect ELOOP chown ${n0} 65534 65534
+expect ELOOP chown ${n1} 65534 65534
 expect ELOOP chown ${n0}/test 65534 65534
 expect ELOOP chown ${n1}/test 65534 65534
+expect ELOOP lchown ${n0}/test 65534 65534
+expect ELOOP lchown ${n1}/test 65534 65534
 expect 0 unlink ${n0}
 expect 0 unlink ${n1}

Modified: head/tools/regression/pjdfstest/tests/chown/07.t
==
--- head/tools/regression/pjdfstest/tests/chown/07.tTue Aug 17 02:50:12 
2010(r211409)
+++ head/tools/regression/pjdfstest/tests/chown/07.tTue Aug 17 06:08:09 
2010(r211410)
@@ -6,23 +6,48 @@ desc="chown returns EPERM if the operati
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..11"
+echo "1..132"
 
 n0=`namegen`
 n1=`namegen`
 n2=`namegen`
+n3=`namegen`
 
 expect 0 mkdir ${n0} 0755
 cdir=`pwd`
 cd ${n0}
 expect 0 mkdir ${n1} 0755
 expect 0 chown ${n1} 65534 65534
-expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
-expect EPERM -u 65534 -g 65534 chown ${n1}/${n2} 65533 65533
-expect EPERM -u 65533 -g 65533 chown ${n1}/${n2} 65534 65534
-

svn commit: r211407 - head/sbin/hastd

2010-08-16 Thread Pawel Jakub Dawidek
Author: pjd
Date: Mon Aug 16 21:59:56 2010
New Revision: 211407
URL: http://svn.freebsd.org/changeset/base/211407

Log:
  The 'size' variable is there to limit how many bytes we want to copy from
  'addr'. It is very likely that size of 'addr' is larger than 'size', so 
checking
  strlcpy() return value is bogus.
  
  MFC after:3 weeks

Modified:
  head/sbin/hastd/proto_tcp4.c

Modified: head/sbin/hastd/proto_tcp4.c
==
--- head/sbin/hastd/proto_tcp4.cMon Aug 16 21:26:47 2010
(r211406)
+++ head/sbin/hastd/proto_tcp4.cMon Aug 16 21:59:56 2010
(r211407)
@@ -156,8 +156,7 @@ tcp4_addr(const char *addr, struct socka
size = (size_t)(pp - addr + 1);
if (size > sizeof(iporhost))
return (ENAMETOOLONG);
-   if (strlcpy(iporhost, addr, size) >= size)
-   return (ENAMETOOLONG);
+   (void)strlcpy(iporhost, addr, size);
}
/* Convert string (IP address or host name) to in_addr_t. */
ip = str2ip(iporhost);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211354 - in head/tools/regression/pjdfstest: . tests

2010-08-15 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Aug 15 21:29:03 2010
New Revision: 211354
URL: http://svn.freebsd.org/changeset/base/211354

Log:
  Finish renaming fstest to pjdfstest.

Added:
  head/tools/regression/pjdfstest/pjdfstest.c
 - copied, changed from r211352, head/tools/regression/pjdfstest/fstest.c
Deleted:
  head/tools/regression/pjdfstest/fstest.c
Modified:
  head/tools/regression/pjdfstest/LICENSE
  head/tools/regression/pjdfstest/Makefile
  head/tools/regression/pjdfstest/README
  head/tools/regression/pjdfstest/tests/conf
  head/tools/regression/pjdfstest/tests/misc.sh

Modified: head/tools/regression/pjdfstest/LICENSE
==
--- head/tools/regression/pjdfstest/LICENSE Sun Aug 15 21:25:52 2010
(r211353)
+++ head/tools/regression/pjdfstest/LICENSE Sun Aug 15 21:29:03 2010
(r211354)
@@ -1,6 +1,6 @@
 $FreeBSD$
 
-License for all regression tests available with fstest:
+License for all regression tests available with pjdfstest:
 
 Copyright (c) 2006-2010 Pawel Jakub Dawidek 
 All rights reserved.

Modified: head/tools/regression/pjdfstest/Makefile
==
--- head/tools/regression/pjdfstest/MakefileSun Aug 15 21:25:52 2010
(r211353)
+++ head/tools/regression/pjdfstest/MakefileSun Aug 15 21:29:03 2010
(r211354)
@@ -1,6 +1,6 @@
 # $FreeBSD$
 
-PROG=  fstest
+PROG=  pjdfstest
 
 ${PROG}:   ${PROG}.c
@OSTYPE=`uname`; \

Modified: head/tools/regression/pjdfstest/README
==
--- head/tools/regression/pjdfstest/README  Sun Aug 15 21:25:52 2010
(r211353)
+++ head/tools/regression/pjdfstest/README  Sun Aug 15 21:29:03 2010
(r211354)
@@ -1,17 +1,17 @@
 $FreeBSD$
 
-Few notes on how to use fstest in short steps:
+Few notes on how to use pjdfstest in short steps:
 
-   # cd fstest
+   # cd pjdfstest
# vi tests/conf
Change 'fs' to file system type you want to test (UFS or ZFS).
# vi Makefile
You need to manually tweak few things by editing CFLAGS lines
at the top of the file.
# make
-   It will compile fstest utility which is used by regression tests.
+   It will compile pjdfstest utility which is used by regression tests.
# cd /path/to/file/system/you/want/to/test/
-   # prove -r /path/to/fstest/
+   # prove -r /path/to/pjdfstest/tests
 
 That's all. Enjoy.
 

Copied and modified: head/tools/regression/pjdfstest/pjdfstest.c (from r211352, 
head/tools/regression/pjdfstest/fstest.c)
==
--- head/tools/regression/pjdfstest/fstest.cSun Aug 15 21:24:17 2010
(r211352, copy source)
+++ head/tools/regression/pjdfstest/pjdfstest.c Sun Aug 15 21:29:03 2010
(r211354)
@@ -264,7 +264,7 @@ static void
 usage(void)
 {
 
-   fprintf(stderr, "usage: fstest [-U umask] [-u uid] [-g 
gid1[,gid2[...]]] syscall args ...\n");
+   fprintf(stderr, "usage: pjdfstest [-U umask] [-u uid] [-g 
gid1[,gid2[...]]] syscall args ...\n");
exit(1);
 }
 

Modified: head/tools/regression/pjdfstest/tests/conf
==
--- head/tools/regression/pjdfstest/tests/conf  Sun Aug 15 21:25:52 2010
(r211353)
+++ head/tools/regression/pjdfstest/tests/conf  Sun Aug 15 21:29:03 2010
(r211354)
@@ -1,5 +1,5 @@
 # $FreeBSD$
-# fstest configuration file
+# pjdfstest configuration file
 
 # Supported operating systems: FreeBSD, Darwin, SunOS, Linux
 os=`uname`

Modified: head/tools/regression/pjdfstest/tests/misc.sh
==
--- head/tools/regression/pjdfstest/tests/misc.sh   Sun Aug 15 21:25:52 
2010(r211353)
+++ head/tools/regression/pjdfstest/tests/misc.sh   Sun Aug 15 21:29:03 
2010(r211354)
@@ -10,7 +10,7 @@ case "${dir}" in
maindir="`pwd`/${dir}/../.."
;;
 esac
-fstest="${maindir}/fstest"
+fstest="${maindir}/pjdfstest"
 . ${maindir}/tests/conf
 
 expect()
@@ -42,7 +42,7 @@ jexpect()
d="${2}"
e="${3}"
shift 3
-   r=`jail -s ${s} / fstest 127.0.0.1 /bin/sh -c "cd ${d} && ${fstest} $* 
2>/dev/null" | tail -1`
+   r=`jail -s ${s} / pjdfstest 127.0.0.1 /bin/sh -c "cd ${d} && ${fstest} 
$* 2>/dev/null" | tail -1`
echo "${r}" | ${GREP} -Eq '^'${e}'$'
if [ $? -eq 0 ]; then
if [ -z "${todomsg}" ]; then
@@ -89,7 +89,7 @@ todo()
 
 namegen()
 {
-   echo "fstest_`dd if=/dev/urandom bs=1k count=1 2>/dev/null | openssl 
md5`"
+   echo "pjdfstest_`dd i

svn commit: r211352 - in head/tools/regression: fstest pjdfstest

2010-08-15 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Aug 15 21:24:17 2010
New Revision: 211352
URL: http://svn.freebsd.org/changeset/base/211352

Log:
  Give fstest a more unique name: pjdfstest.
  It is released from time to time and used outside FreeBSD, so it is good to
  have a name one can google.

Added:
  head/tools/regression/pjdfstest/
 - copied from r211351, head/tools/regression/fstest/
Deleted:
  head/tools/regression/fstest/
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211351 - head/tools/regression/fstest

2010-08-15 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Aug 15 21:20:40 2010
New Revision: 211351
URL: http://svn.freebsd.org/changeset/base/211351

Log:
  Update copyright years.

Modified:
  head/tools/regression/fstest/LICENSE
  head/tools/regression/fstest/fstest.c

Modified: head/tools/regression/fstest/LICENSE
==
--- head/tools/regression/fstest/LICENSESun Aug 15 21:19:42 2010
(r211350)
+++ head/tools/regression/fstest/LICENSESun Aug 15 21:20:40 2010
(r211351)
@@ -2,7 +2,7 @@ $FreeBSD$
 
 License for all regression tests available with fstest:
 
-Copyright (c) 2006-2007 Pawel Jakub Dawidek 
+Copyright (c) 2006-2010 Pawel Jakub Dawidek 
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without

Modified: head/tools/regression/fstest/fstest.c
==
--- head/tools/regression/fstest/fstest.c   Sun Aug 15 21:19:42 2010
(r211350)
+++ head/tools/regression/fstest/fstest.c   Sun Aug 15 21:20:40 2010
(r211351)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2006-2007 Pawel Jakub Dawidek 
+ * Copyright (c) 2006-2010 Pawel Jakub Dawidek 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211350 - head/tools/regression/fstest/tests/chown

2010-08-15 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Aug 15 21:19:42 2010
New Revision: 211350
URL: http://svn.freebsd.org/changeset/base/211350

Log:
  More tests.

Modified:
  head/tools/regression/fstest/tests/chown/00.t

Modified: head/tools/regression/fstest/tests/chown/00.t
==
--- head/tools/regression/fstest/tests/chown/00.t   Sun Aug 15 21:06:53 
2010(r211349)
+++ head/tools/regression/fstest/tests/chown/00.t   Sun Aug 15 21:19:42 
2010(r211350)
@@ -7,9 +7,9 @@ dir=`dirname $0`
 . ${dir}/../misc.sh
 
 if supported lchmod; then
-   echo "1..264"
+   echo "1..1349"
 else
-   echo "1..249"
+   echo "1..1323"
 fi
 
 n0=`namegen`
@@ -21,419 +21,438 @@ cdir=`pwd`
 cd ${n2}
 
 # super-user can always modify ownership
-
-expect 0 create ${n0} 0644
-expect 0 chown ${n0} 123 456
-expect 123,456 lstat ${n0} uid,gid
-expect 0 chown ${n0} 0 0
-expect 0,0 lstat ${n0} uid,gid
-expect 0 unlink ${n0}
-
-expect 0 mkfifo ${n0} 0644
-expect 0 chown ${n0} 123 456
-expect 123,456 lstat ${n0} uid,gid
-expect 0 chown ${n0} 0 0
-expect 0,0 lstat ${n0} uid,gid
-expect 0 unlink ${n0}
-
-expect 0 mknod ${n0} b 0644 1 2
-expect 0 chown ${n0} 123 456
-expect 123,456 lstat ${n0} uid,gid
-expect 0 chown ${n0} 0 0
-expect 0,0 lstat ${n0} uid,gid
-expect 0 unlink ${n0}
-
-expect 0 mknod ${n0} c 0644 1 2
-expect 0 chown ${n0} 123 456
-expect 123,456 lstat ${n0} uid,gid
-expect 0 chown ${n0} 0 0
-expect 0,0 lstat ${n0} uid,gid
-expect 0 unlink ${n0}
-
-expect 0 bind ${n0}
-expect 0 chown ${n0} 123 456
-expect 123,456 lstat ${n0} uid,gid
-expect 0 chown ${n0} 0 0
-expect 0,0 lstat ${n0} uid,gid
-expect 0 unlink ${n0}
-
-expect 0 mkdir ${n0} 0755
-expect 0 chown ${n0} 123 456
-expect 123,456 lstat ${n0} uid,gid
-expect 0 chown ${n0} 0 0
-expect 0,0 lstat ${n0} uid,gid
-expect 0 rmdir ${n0}
-
-expect 0 create ${n0} 0644
-expect 0 symlink ${n0} ${n1}
-expect 0 chown ${n1} 123 456
-expect 123,456 stat ${n1} uid,gid
-expect 123,456 stat ${n0} uid,gid
-expect 0 lchown ${n1} 135 579
-expect 135,579 lstat ${n1} uid,gid
-expect 123,456 stat ${n1} uid,gid
-expect 123,456 stat ${n0} uid,gid
-expect 0 unlink ${n0}
-expect 0 unlink ${n1}
+for type in regular dir fifo block char socket symlink; do
+   if [ "${type}" != "symlink" ]; then
+   create_file ${type} ${n0}
+
+   expect 0 chown ${n0} 123 456
+   expect 123,456 lstat ${n0} uid,gid
+   expect 0 chown ${n0} 0 0
+   expect 0,0 lstat ${n0} uid,gid
+
+   expect 0 symlink ${n0} ${n1}
+   uidgid=`${fstest} lstat ${n1} uid,gid`
+   expect 0 chown ${n1} 123 456
+   expect 123,456 stat ${n1} uid,gid
+   expect 123,456 stat ${n0} uid,gid
+   expect ${uidgid} lstat ${n1} uid,gid
+   expect 0 unlink ${n1}
+
+   if [ "${type}" = "dir" ]; then
+   expect 0 rmdir ${n0}
+   else
+   expect 0 unlink ${n0}
+   fi
+   fi
+
+   create_file ${type} ${n0}
+   expect 0 lchown ${n0} 123 456
+   expect 123,456 lstat ${n0} uid,gid
+   if [ "${type}" = "dir" ]; then
+   expect 0 rmdir ${n0}
+   else
+   expect 0 unlink ${n0}
+   fi
+done
 
 # non-super-user can modify file group if he is owner of a file and
 # gid he is setting is in his groups list.
+for type in regular dir fifo block char socket symlink; do
+   if [ "${type}" != "symlink" ]; then
+   create_file ${type} ${n0}
+
+   expect 0 chown ${n0} 65534 65533
+   expect 65534,65533 lstat ${n0} uid,gid
+   expect 0 -u 65534 -g 65532,65531 -- chown ${n0} -1 65532
+   expect 65534,65532 lstat ${n0} uid,gid
+   expect 0 -u 65534 -g 65532,65531 chown ${n0} 65534 65531
+   expect 65534,65531 lstat ${n0} uid,gid
+
+   expect 0 symlink ${n0} ${n1}
+   uidgid=`${fstest} lstat ${n1} uid,gid`
+   expect 0 chown ${n1} 65534 65533
+   expect 65534,65533 stat ${n0} uid,gid
+   expect 65534,65533 stat ${n1} uid,gid
+   expect ${uidgid} lstat ${n1} uid,gid
+   expect 0 -u 65534 -g 65532,65531 -- chown ${n1} -1 65532
+   expect 65534,65532 stat ${n0} uid,gid
+   expect 65534,65532 stat ${n1} uid,gid
+   expect ${uidgid} lstat ${n1} uid,gid
+   expect 0 -u 65534 -g 65532,65531 chown ${n1} 65534 65531
+   expect 65534,65531 stat ${n0} uid,gid
+   expect 65534,65531 stat ${n1} uid,gid
+   expect ${uidgid} lstat ${n1} uid,gid
+   expect 0 unlink ${n1}
+
+   if [ "${type}" = "dir" ]; then
+   expect 0 rmdir ${n0}
+   else
+   expect 0 unlink ${n0}
+   fi
+   fi
 
-expect 0 create ${n0} 0

svn commit: r211336 - head/tools/regression/fstest/tests/chmod

2010-08-15 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sun Aug 15 14:44:48 2010
New Revision: 211336
URL: http://svn.freebsd.org/changeset/base/211336

Log:
  More tests (especially for lchmod(2)), less code duplication.

Modified:
  head/tools/regression/fstest/tests/chmod/00.t
  head/tools/regression/fstest/tests/chmod/04.t
  head/tools/regression/fstest/tests/chmod/05.t
  head/tools/regression/fstest/tests/chmod/06.t
  head/tools/regression/fstest/tests/chmod/07.t
  head/tools/regression/fstest/tests/chmod/08.t
  head/tools/regression/fstest/tests/chmod/09.t
  head/tools/regression/fstest/tests/chmod/10.t
  head/tools/regression/fstest/tests/chmod/11.t

Modified: head/tools/regression/fstest/tests/chmod/00.t
==
--- head/tools/regression/fstest/tests/chmod/00.t   Sun Aug 15 14:38:01 
2010(r211335)
+++ head/tools/regression/fstest/tests/chmod/00.t   Sun Aug 15 14:44:48 
2010(r211336)
@@ -7,9 +7,9 @@ dir=`dirname $0`
 . ${dir}/../misc.sh
 
 if supported lchmod; then
-   echo "1..77"
+   echo "1..203"
 else
-   echo "1..58"
+   echo "1..119"
 fi
 
 n0=`namegen`
@@ -20,116 +20,100 @@ expect 0 mkdir ${n2} 0755
 cdir=`pwd`
 cd ${n2}
 
-expect 0 create ${n0} 0644
-expect 0644 stat ${n0} mode
-expect 0 chmod ${n0} 0111
-expect 0111 stat ${n0} mode
-expect 0 unlink ${n0}
-
-expect 0 mkdir ${n0} 0755
-expect 0755 stat ${n0} mode
-expect 0 chmod ${n0} 0753
-expect 0753 stat ${n0} mode
-expect 0 rmdir ${n0}
-
-expect 0 mkfifo ${n0} 0644
-expect 0644 stat ${n0} mode
-expect 0 chmod ${n0} 0310
-expect 0310 stat ${n0} mode
-expect 0 unlink ${n0}
-
-expect 0 create ${n0} 0644
-expect 0 symlink ${n0} ${n1}
-expect 0644 stat ${n1} mode
-expect 0 chmod ${n1} 0321
-expect 0321 stat ${n1} mode
-expect 0321 lstat ${n0} mode
-expect 0 unlink ${n0}
-expect 0 unlink ${n1}
-
-if supported lchmod; then
-   expect 0 create ${n0} 0644
-   expect 0 symlink ${n0} ${n1}
-   expect 0644 stat ${n1} mode
-   expect 0 lchmod ${n1} 0321
-   expect 0321 lstat ${n1} mode
-   expect 0 lchmod ${n1} 0531
-   expect 0531 lstat ${n1} mode
-   expect 0644 stat ${n0} mode
-   expect 0644 stat ${n1} mode
-   expect 0 unlink ${n0}
-   expect 0 unlink ${n1}
-fi
+for type in regular dir fifo block char socket symlink; do
+   if [ "${type}" != "symlink" ]; then
+   create_file ${type} ${n0}
+   expect 0 chmod ${n0} 0111
+   expect 0111 stat ${n0} mode
+
+   expect 0 symlink ${n0} ${n1}
+   mode=`${fstest} lstat ${n1} mode`
+   expect 0 chmod ${n1} 0222
+   expect 0222 stat ${n1} mode
+   expect 0222 stat ${n0} mode
+   expect ${mode} lstat ${n1} mode
+   expect 0 unlink ${n1}
+
+   if [ "${type}" = "dir" ]; then
+   expect 0 rmdir ${n0}
+   else
+   expect 0 unlink ${n0}
+   fi
+   fi
+
+   if supported lchmod; then
+   create_file ${type} ${n0}
+   expect 0 lchmod ${n0} 0111
+   expect 0111 lstat ${n0} mode
+   if [ "${type}" = "dir" ]; then
+   expect 0 rmdir ${n0}
+   else
+   expect 0 unlink ${n0}
+   fi
+   fi
+done
 
 # successful chmod(2) updates ctime.
-expect 0 create ${n0} 0644
-ctime1=`${fstest} stat ${n0} ctime`
-sleep 1
-expect 0 chmod ${n0} 0111
-ctime2=`${fstest} stat ${n0} ctime`
-test_check $ctime1 -lt $ctime2
-expect 0 unlink ${n0}
-
-expect 0 mkdir ${n0} 0755
-ctime1=`${fstest} stat ${n0} ctime`
-sleep 1
-expect 0 chmod ${n0} 0753
-ctime2=`${fstest} stat ${n0} ctime`
-test_check $ctime1 -lt $ctime2
-expect 0 rmdir ${n0}
-
-expect 0 mkfifo ${n0} 0644
-ctime1=`${fstest} stat ${n0} ctime`
-sleep 1
-expect 0 chmod ${n0} 0310
-ctime2=`${fstest} stat ${n0} ctime`
-test_check $ctime1 -lt $ctime2
-expect 0 unlink ${n0}
-
-if supported lchmod; then
-   expect 0 symlink ${n1} ${n0}
-   ctime1=`${fstest} lstat ${n0} ctime`
-   sleep 1
-   expect 0 lchmod ${n0} 0321
-   ctime2=`${fstest} lstat ${n0} ctime`
-   test_check $ctime1 -lt $ctime2
-   expect 0 unlink ${n0}
-fi
+for type in regular dir fifo block char socket symlink; do
+   if [ "${type}" != "symlink" ]; then
+   create_file ${type} ${n0}
+   ctime1=`${fstest} stat ${n0} ctime`
+   sleep 1
+   expect 0 chmod ${n0} 0111
+   ctime2=`${fstest} stat ${n0} ctime`
+   test_check $ctime1 -lt $ctime2
+   if [ "${type}" = "dir" ]; then
+   expect 0 rmdir ${n0}
+   else
+   expect 0 unlink ${n0}
+   fi
+   fi
+
+   if supported lchmod; then
+   create_file ${type} ${n0}
+   ctime1=`${fstest} lstat ${n0} ctime`
+   sleep 1
+   ex

svn commit: r211290 - head/tools/regression/fstest/tests/chflags

2010-08-13 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 13 21:17:59 2010
New Revision: 211290
URL: http://svn.freebsd.org/changeset/base/211290

Log:
  - Use loops to avoid code duplication.
  - More tests.

Modified:
  head/tools/regression/fstest/tests/chflags/07.t
  head/tools/regression/fstest/tests/chflags/08.t
  head/tools/regression/fstest/tests/chflags/09.t

Modified: head/tools/regression/fstest/tests/chflags/07.t
==
--- head/tools/regression/fstest/tests/chflags/07.t Fri Aug 13 21:04:43 
2010(r211289)
+++ head/tools/regression/fstest/tests/chflags/07.t Fri Aug 13 21:17:59 
2010(r211290)
@@ -8,7 +8,7 @@ dir=`dirname $0`
 
 require chflags
 
-echo "1..30"
+echo "1..93"
 
 n0=`namegen`
 n1=`namegen`
@@ -18,37 +18,33 @@ expect 0 mkdir ${n0} 0755
 cdir=`pwd`
 cd ${n0}
 
-expect 0 create ${n1} 0644
-expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP
-expect none stat ${n1} flags
-expect 0 chown ${n1} 65534 65534
-expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP
-expect none stat ${n1} flags
-expect 0 unlink ${n1}
-
-expect 0 mkdir ${n1} 0755
-expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP
-expect none stat ${n1} flags
-expect 0 chown ${n1} 65534 65534
-expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP
-expect none stat ${n1} flags
-expect 0 rmdir ${n1}
-
-expect 0 mkfifo ${n1} 0644
-expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP
-expect none stat ${n1} flags
-expect 0 chown ${n1} 65534 65534
-expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP
-expect none stat ${n1} flags
-expect 0 unlink ${n1}
-
-expect 0 symlink ${n2} ${n1}
-expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP
-expect none lstat ${n1} flags
-expect 0 lchown ${n1} 65534 65534
-expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP
-expect none lstat ${n1} flags
-expect 0 unlink ${n1}
+for type in regular dir fifo block char socket symlink; do
+   if [ "${type}" != "symlink" ]; then
+   create_file ${type} ${n1}
+   expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP
+   expect none stat ${n1} flags
+   expect 0 chown ${n1} 65534 65534
+   expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP
+   expect none stat ${n1} flags
+   if [ "${type}" = "dir" ]; then
+   expect 0 rmdir ${n1}
+   else
+   expect 0 unlink ${n1}
+   fi
+   fi
+
+   create_file ${type} ${n1}
+   expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP
+   expect none lstat ${n1} flags
+   expect 0 lchown ${n1} 65534 65534
+   expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP
+   expect none lstat ${n1} flags
+   if [ "${type}" = "dir" ]; then
+   expect 0 rmdir ${n1}
+   else
+   expect 0 unlink ${n1}
+   fi
+done
 
 cd ${cdir}
 expect 0 rmdir ${n0}

Modified: head/tools/regression/fstest/tests/chflags/08.t
==
--- head/tools/regression/fstest/tests/chflags/08.t Fri Aug 13 21:04:43 
2010(r211289)
+++ head/tools/regression/fstest/tests/chflags/08.t Fri Aug 13 21:17:59 
2010(r211290)
@@ -8,7 +8,7 @@ dir=`dirname $0`
 
 require chflags
 
-echo "1..78"
+echo "1..249"
 
 n0=`namegen`
 n1=`namegen`
@@ -18,53 +18,41 @@ expect 0 mkdir ${n0} 0755
 cdir=`pwd`
 cd ${n0}
 
-expect 0 create ${n1} 0644
-expect 0 chown ${n1} 65534 65534
-for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
-   expect 0 chflags ${n1} ${flag}
-   expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP
-   expect ${flag} stat ${n1} flags
-   expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP
-   expect ${flag} stat ${n1} flags
+for type in regular dir fifo block char socket symlink; do
+   if [ "${type}" != "symlink" ]; then
+   create_file ${type} ${n1}
+   expect 0 chown ${n1} 65534 65534
+   for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
+   expect 0 chflags ${n1} ${flag}
+   expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP
+   expect ${flag} stat ${n1} flags
+   expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP
+   expect ${flag} stat ${n1} flags
+   done
+   expect 0 chflags ${n1} none
+   if [ "${type}" = "dir" ]; then
+   expect 0 rmdir ${n1}
+   else
+   expect 0 unlink ${n1}
+   fi
+   fi
+
+   create_file ${type} ${n1}
+   expect 0 lchown ${n1} 65534 65534
+   for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
+   expect 0 lchflags ${n1} ${flag}
+   expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP
+   expect ${flag} lstat ${n1} flags
+

svn commit: r211284 - head/sys/kern

2010-08-13 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug 13 19:20:35 2010
New Revision: 211284
URL: http://svn.freebsd.org/changeset/base/211284

Log:
  Simplify taskqueue_drain() by using proved macros.

Modified:
  head/sys/kern/subr_taskqueue.c

Modified: head/sys/kern/subr_taskqueue.c
==
--- head/sys/kern/subr_taskqueue.c  Fri Aug 13 18:17:32 2010
(r211283)
+++ head/sys/kern/subr_taskqueue.c  Fri Aug 13 19:20:35 2010
(r211284)
@@ -248,23 +248,16 @@ taskqueue_run(struct taskqueue *queue, s
 void
 taskqueue_drain(struct taskqueue *queue, struct task *task)
 {
-   if (queue->tq_spin) {   /* XXX */
-   mtx_lock_spin(&queue->tq_mutex);
-   while (task->ta_pending != 0 ||
-   (task->ta_running != NULL && task == *task->ta_running)) {
-   msleep_spin(task, &queue->tq_mutex, "-", 0);
-   }
-   mtx_unlock_spin(&queue->tq_mutex);
-   } else {
+
+   if (!queue->tq_spin)
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__);
 
-   mtx_lock(&queue->tq_mutex);
-   while (task->ta_pending != 0 ||
-   (task->ta_running != NULL && task == *task->ta_running)) {
-   msleep(task, &queue->tq_mutex, PWAIT, "-", 0);
-   }
-   mtx_unlock(&queue->tq_mutex);
+   TQ_LOCK(queue);
+   while (task->ta_pending != 0 ||
+   (task->ta_running != NULL && task == *task->ta_running)) {
+   TQ_SLEEP(queue, task, &queue->tq_mutex, PWAIT, "-", 0);
}
+   TQ_UNLOCK(queue);
 }
 
 static void
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r211201 - in head: share/man/man4 sys/conf sys/dev/tpm sys/modules sys/modules/tpm

2010-08-12 Thread Pawel Jakub Dawidek
On Thu, Aug 12, 2010 at 12:16:18AM +, Takanori Watanabe wrote:
> Author: takawata
> Date: Thu Aug 12 00:16:18 2010
> New Revision: 211201
> URL: http://svn.freebsd.org/changeset/base/211201
> 
> Log:
>   Add tpm(4) driver for Trusted Platform Module.
>   You may want to look at http://bsssd.sourceforge.net/ .
>   
>   Submitted by: Hans-Joerg Hoexer 

Yay!

PS. Any reason manual page is not enabled in man4/Makefile?

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgpIHdjRyXEPg.pgp
Description: PGP signature


svn commit: r211242 - in head/tools/regression/fstest/tests: rmdir unlink

2010-08-12 Thread Pawel Jakub Dawidek
Author: pjd
Date: Thu Aug 12 20:35:14 2010
New Revision: 211242
URL: http://svn.freebsd.org/changeset/base/211242

Log:
  More tests.

Modified:
  head/tools/regression/fstest/tests/rmdir/11.t
  head/tools/regression/fstest/tests/unlink/11.t

Modified: head/tools/regression/fstest/tests/rmdir/11.t
==
--- head/tools/regression/fstest/tests/rmdir/11.t   Thu Aug 12 20:18:06 
2010(r211241)
+++ head/tools/regression/fstest/tests/rmdir/11.t   Thu Aug 12 20:35:14 
2010(r211242)
@@ -6,7 +6,7 @@ desc="rmdir returns EACCES or EPERM if t
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..15"
+echo "1..47"
 
 n0=`namegen`
 n1=`namegen`
@@ -22,17 +22,34 @@ expect 0 chmod ${n0} 01777
 
 # User owns both: the sticky directory and the directory to be removed.
 expect 0 -u 65534 -g 65534 mkdir ${n0}/${n1} 0755
+expect dir,65534,65534 lstat ${n0}/${n1} type,uid,gid
 expect 0 -u 65534 -g 65534 rmdir ${n0}/${n1}
+expect ENOENT lstat ${n0}/${n1} type
 # User owns the directory to be removed, but doesn't own the sticky directory.
-expect 0 -u 65533 -g 65533 mkdir ${n0}/${n1} 0755
-expect 0 -u 65533 -g 65533 rmdir ${n0}/${n1}
+for id in 0 65533; do
+   expect 0 chown ${n0} ${id} ${id}
+   create_file dir ${n0}/${n1} 65534 65534
+   expect dir,65534,65534 lstat ${n0}/${n1} type,uid,gid
+   expect 0 -u 65534 -g 65534 rmdir ${n0}/${n1}
+   expect ENOENT lstat ${n0}/${n1} type
+done
 # User owns the sticky directory, but doesn't own the directory to be removed.
-expect 0 -u 65533 -g 65533 mkdir ${n0}/${n1} 0755
-expect 0 -u 65534 -g 65534 rmdir ${n0}/${n1}
+expect 0 chown ${n0} 65534 65534
+for id in 0 65533; do
+   create_file dir ${n0}/${n1} ${id} ${id}
+   expect dir,${id},${id} lstat ${n0}/${n1} type,uid,gid
+   expect 0 -u 65534 -g 65534 rmdir ${n0}/${n1}
+   expect ENOENT lstat ${n0}/${n1} type
+done
 # User doesn't own the sticky directory nor the directory to be removed.
-expect 0 -u 65534 -g 65534 mkdir ${n0}/${n1} 0755
-expect "EACCES|EPERM" -u 65533 -g 65533 rmdir ${n0}/${n1}
-expect 0 rmdir ${n0}/${n1}
+for id in 0 65533; do
+   expect 0 chown ${n0} ${id} ${id}
+   create_file dir ${n0}/${n1} ${id} ${id}
+   expect dir,${id},${id} lstat ${n0}/${n1} type,uid,gid
+   expect "EACCES|EPERM" -u 65534 -g 65534 rmdir ${n0}/${n1}
+   expect dir,${id},${id} lstat ${n0}/${n1} type,uid,gid
+   expect 0 rmdir ${n0}/${n1}
+done
 
 expect 0 rmdir ${n0}
 

Modified: head/tools/regression/fstest/tests/unlink/11.t
==
--- head/tools/regression/fstest/tests/unlink/11.t  Thu Aug 12 20:18:06 
2010(r211241)
+++ head/tools/regression/fstest/tests/unlink/11.t  Thu Aug 12 20:35:14 
2010(r211242)
@@ -6,7 +6,7 @@ desc="unlink returns EACCES or EPERM if 
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..68"
+echo "1..270"
 
 n0=`namegen`
 n1=`namegen`
@@ -17,100 +17,45 @@ cdir=`pwd`
 cd ${n2}
 
 expect 0 mkdir ${n0} 0755
-expect 0 chown ${n0} 65534 65534
 expect 0 chmod ${n0} 01777
+expect 0 chown ${n0} 65534 65534
 
-# User owns both: the sticky directory and the file to be removed.
-expect 0 -u 65534 -g 65534 create ${n0}/${n1} 0644
-expect 0 -u 65534 -g 65534 unlink ${n0}/${n1}
-# User owns the file to be removed, but doesn't own the sticky directory.
-expect 0 -u 65533 -g 65533 create ${n0}/${n1} 0644
-expect 0 -u 65533 -g 65533 unlink ${n0}/${n1}
-# User owns the sticky directory, but doesn't own the file to be removed.
-expect 0 -u 65533 -g 65533 create ${n0}/${n1} 0644
-expect 0 -u 65534 -g 65534 unlink ${n0}/${n1}
-# User doesn't own the sticky directory nor the file to be removed.
-expect 0 -u 65534 -g 65534 create ${n0}/${n1} 0644
-expect "EACCES|EPERM" -u 65533 -g 65533 unlink ${n0}/${n1}
-expect 0 unlink ${n0}/${n1}
-
-# User owns both: the sticky directory and the fifo to be removed.
-expect 0 -u 65534 -g 65534 mkfifo ${n0}/${n1} 0644
-expect 0 -u 65534 -g 65534 unlink ${n0}/${n1}
-# User owns the fifo to be removed, but doesn't own the sticky directory.
-expect 0 -u 65533 -g 65533 mkfifo ${n0}/${n1} 0644
-expect 0 -u 65533 -g 65533 unlink ${n0}/${n1}
-# User owns the sticky directory, but doesn't own the fifo to be removed.
-expect 0 -u 65533 -g 65533 mkfifo ${n0}/${n1} 0644
-expect 0 -u 65534 -g 65534 unlink ${n0}/${n1}
-# User doesn't own the sticky directory nor the fifo to be removed.
-expect 0 -u 65534 -g 65534 mkfifo ${n0}/${n1} 0644
-expect "EACCES|EPERM" -u 65533 -g 65533 unlink ${n0}/${n1}
-expect 0 unlink ${n0}/${n1}
-
-# User owns both: the sticky directory and the block device to be removed.
-expect 0 mknod ${n0}/${n1} b 0644 1 2
-expect 0 chown ${n0}/${n1} 65534 65534
-expect 0 -u 65534 -g 65534 unlink ${n0}/${n1}
-# User owns the block device to be removed, but doesn't own the sticky 
directory.
-expect 0 mknod ${n0}/${n1} b 0644 1 2
-expect 0 chown ${n0}/${n1} 655

svn commit: r211235 - head/tools/regression/fstest

2010-08-12 Thread Pawel Jakub Dawidek
Author: pjd
Date: Thu Aug 12 19:45:27 2010
New Revision: 211235
URL: http://svn.freebsd.org/changeset/base/211235

Log:
  Portable Makefile.

Modified:
  head/tools/regression/fstest/Makefile

Modified: head/tools/regression/fstest/Makefile
==
--- head/tools/regression/fstest/Makefile   Thu Aug 12 19:43:40 2010
(r211234)
+++ head/tools/regression/fstest/Makefile   Thu Aug 12 19:45:27 2010
(r211235)
@@ -1,25 +1,26 @@
 # $FreeBSD$
 
 PROG=  fstest
-NO_MAN=
 
-OSTYPE!= uname
+${PROG}:   ${PROG}.c
+   @OSTYPE=`uname`; \
+   CFLAGS=-D__OS_$${OSTYPE}__; \
+   if [ $$OSTYPE = "FreeBSD" ]; then \
+   CFLAGS="$$CFLAGS -DHAS_LCHMOD -DHAS_CHFLAGS -DHAS_LCHFLAGS 
-DHAS_FREEBSD_ACL"; \
+   elif [ $$OSTYPE = "SunOS" ]; then \
+   CFLAGS="$$CFLAGS -DHAS_TRUNCATE64 -DHAS_STAT64"; \
+   CFLAGS="$$CFLAGS -lsocket"; \
+   elif [ $$OSTYPE = "Darwin" ]; then \
+   CFLAGS="$$CFLAGS -DHAS_LCHMOD -DHAS_CHFLAGS -DHAS_LCHFLAGS"; \
+   elif [ $$OSTYPE == "Linux" ]; then \
+   CFLAGS="$$CFLAGS -D_GNU_SOURCE"; \
+   else \
+   echo "Unsupported operating system: ${OSTYPE}."; \
+   exit 1; \
+   fi; \
+   cmd="gcc -Wall $$CFLAGS ${PROG}.c -o ${PROG}"; \
+   echo $$cmd; \
+   $$cmd
 
-.if ${OSTYPE} == "FreeBSD"
-CFLAGS+= -D__OS_FreeBSD__
-CFLAGS+= -DHAS_LCHMOD -DHAS_CHFLAGS -DHAS_LCHFLAGS -DHAS_FREEBSD_ACL
-
-.elif ${OSTYPE} == "SunOS"
-CFLAGS+= -D__OS_Solaris__
-CFLAGS+= -DHAS_TRUNCATE64 -DHAS_STAT64
-
-.elif ${OSTYPE} == "Darwin"
-CFLAGS+= -D__OS_Darwin__
-CFLAGS+= -DHAS_LCHMOD -DHAS_CHFLAGS -DHAS_LCHFLAGS
-
-.elif ${OSTYPE} == "Linux"
-CFLAGS+= -D__OS_Linux__
-CFLAGS+= -D_GNU_SOURCE
-.endif
-
-.include 
+clean:
+   rm -f ${PROG}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211234 - head/tools/regression/fstest/tests/unlink

2010-08-12 Thread Pawel Jakub Dawidek
Author: pjd
Date: Thu Aug 12 19:43:40 2010
New Revision: 211234
URL: http://svn.freebsd.org/changeset/base/211234

Log:
  Fix copy&pasted code - we want to create character device here.

Modified:
  head/tools/regression/fstest/tests/unlink/11.t

Modified: head/tools/regression/fstest/tests/unlink/11.t
==
--- head/tools/regression/fstest/tests/unlink/11.t  Thu Aug 12 19:40:49 
2010(r211233)
+++ head/tools/regression/fstest/tests/unlink/11.t  Thu Aug 12 19:43:40 
2010(r211234)
@@ -67,19 +67,19 @@ expect "EACCES|EPERM" -u 65533 -g 65533 
 expect 0 unlink ${n0}/${n1}
 
 # User owns both: the sticky directory and the character device to be removed.
-expect 0 mknod ${n0}/${n1} b 0644 1 2
+expect 0 mknod ${n0}/${n1} c 0644 1 2
 expect 0 chown ${n0}/${n1} 65534 65534
 expect 0 -u 65534 -g 65534 unlink ${n0}/${n1}
 # User owns the character device to be removed, but doesn't own the sticky 
directory.
-expect 0 mknod ${n0}/${n1} b 0644 1 2
+expect 0 mknod ${n0}/${n1} c 0644 1 2
 expect 0 chown ${n0}/${n1} 65533 65533
 expect 0 -u 65533 -g 65533 unlink ${n0}/${n1}
 # User owns the sticky directory, but doesn't own the character device to be 
removed.
-expect 0 mknod ${n0}/${n1} b 0644 1 2
+expect 0 mknod ${n0}/${n1} c 0644 1 2
 expect 0 chown ${n0}/${n1} 65533 65533
 expect 0 -u 65534 -g 65534 unlink ${n0}/${n1}
 # User doesn't own the sticky directory nor the character directory to be 
removed.
-expect 0 mknod ${n0}/${n1} b 0644 1 2
+expect 0 mknod ${n0}/${n1} c 0644 1 2
 expect 0 chown ${n0}/${n1} 65534 65534
 expect "EACCES|EPERM" -u 65533 -g 65533 unlink ${n0}/${n1}
 expect 0 unlink ${n0}/${n1}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211186 - in head/tools/regression/fstest/tests: chflags link mkdir open rename

2010-08-11 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Aug 11 17:34:58 2010
New Revision: 211186
URL: http://svn.freebsd.org/changeset/base/211186

Log:
  - Use loops where possible to avoid code duplication.
  - Don't pass uid and gid to create_file() if not needed.
  - More tests.

Modified:
  head/tools/regression/fstest/tests/chflags/00.t
  head/tools/regression/fstest/tests/chflags/10.t
  head/tools/regression/fstest/tests/chflags/11.t
  head/tools/regression/fstest/tests/link/00.t
  head/tools/regression/fstest/tests/mkdir/10.t
  head/tools/regression/fstest/tests/open/22.t
  head/tools/regression/fstest/tests/rename/00.t
  head/tools/regression/fstest/tests/rename/06.t
  head/tools/regression/fstest/tests/rename/07.t
  head/tools/regression/fstest/tests/rename/08.t
  head/tools/regression/fstest/tests/rename/13.t
  head/tools/regression/fstest/tests/rename/14.t
  head/tools/regression/fstest/tests/rename/15.t
  head/tools/regression/fstest/tests/rename/20.t

Modified: head/tools/regression/fstest/tests/chflags/00.t
==
--- head/tools/regression/fstest/tests/chflags/00.t Wed Aug 11 17:33:32 
2010(r211185)
+++ head/tools/regression/fstest/tests/chflags/00.t Wed Aug 11 17:34:58 
2010(r211186)
@@ -14,14 +14,14 @@ FreeBSD:UFS)
userflags="UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE"
systemflags="SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK"
 
-   echo "1..780"
+   echo "1..742"
;;
 FreeBSD:ZFS)
allflags="UF_NODUMP,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK"
userflags="UF_NODUMP"
systemflags="SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK"
 
-   echo "1..520"
+   echo "1..482"
;;
 *)
quick_exit
@@ -37,7 +37,7 @@ cdir=`pwd`
 cd ${n2}
 
 for type in regular dir fifo block char socket; do
-   create_file ${type} ${n0} 0 0
+   create_file ${type} ${n0}
expect none stat ${n0} flags
expect 0 chflags ${n0} ${allflags}
expect ${allflags} stat ${n0} flags
@@ -53,7 +53,7 @@ for type in regular dir fifo block char 
expect 0 unlink ${n0}
fi
 
-   create_file ${type} ${n0} 0 0
+   create_file ${type} ${n0}
expect none stat ${n0} flags
expect 0 lchflags ${n0} ${allflags}
expect ${allflags} stat ${n0} flags
@@ -111,7 +111,7 @@ expect 0 unlink ${n0}
 # successful chflags(2) updates ctime.
 for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
-   create_file ${type} ${n0} 0 0
+   create_file ${type} ${n0}
for flag in `echo ${allflags},none | tr ',' ' '`; do
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
@@ -126,7 +126,7 @@ for type in regular dir fifo block char 
fi
fi
 
-   create_file ${type} ${n0} 0 0
+   create_file ${type} ${n0}
for flag in `echo ${allflags},none | tr ',' ' '`; do
ctime1=`${fstest} lstat ${n0} ctime`
sleep 1
@@ -144,7 +144,7 @@ done
 # unsuccessful chflags(2) does not update ctime.
 for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
-   create_file ${type} ${n0} 0 0
+   create_file ${type} ${n0}
for flag in `echo ${allflags},none | tr ',' ' '`; do
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
@@ -159,7 +159,7 @@ for type in regular dir fifo block char 
fi
fi
 
-   create_file ${type} ${n0} 0 0
+   create_file ${type} ${n0}
for flag in `echo ${allflags},none | tr ',' ' '`; do
ctime1=`${fstest} lstat ${n0} ctime`
sleep 1

Modified: head/tools/regression/fstest/tests/chflags/10.t
==
--- head/tools/regression/fstest/tests/chflags/10.t Wed Aug 11 17:33:32 
2010(r211185)
+++ head/tools/regression/fstest/tests/chflags/10.t Wed Aug 11 17:34:58 
2010(r211186)
@@ -8,7 +8,7 @@ dir=`dirname $0`
 
 require chflags
 
-echo "1..210"
+echo "1..197"
 
 n0=`namegen`
 n1=`namegen`
@@ -20,7 +20,7 @@ cd ${n0}
 
 for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
-   create_file ${type} ${n1} 0 0
+   create_file ${type} ${n1}
expect 0 chown ${n1} 65534 65534
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
expect EPERM -u 65533 -g 65533 chflags ${n1} ${flag}
@@ -35,7 +35,7 @@ for type in regular dir fifo block char 
fi
fi
 
-   create_file ${type} ${n1} 0 0
+   create_file ${type} ${n1}
expect 0 lchown ${n1} 65534 65534
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
expect EPERM -u 65533 -g 6553

svn commit: r211185 - head/tools/regression/fstest/tests

2010-08-11 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Aug 11 17:33:32 2010
New Revision: 211185
URL: http://svn.freebsd.org/changeset/base/211185

Log:
  Allow to specify uid, gid and mode for create_file().

Modified:
  head/tools/regression/fstest/tests/misc.sh

Modified: head/tools/regression/fstest/tests/misc.sh
==
--- head/tools/regression/fstest/tests/misc.sh  Wed Aug 11 17:33:26 2010
(r211184)
+++ head/tools/regression/fstest/tests/misc.sh  Wed Aug 11 17:33:32 2010
(r211185)
@@ -175,11 +175,14 @@ require()
quick_exit
 }
 
+# usage:
+#  create_file  
+#  create_file   
+#  create_file
+#  create_file 
 create_file() {
type="${1}"
name="${2}"
-   uid="${3}"
-   gid="${4}"
 
case "${type}" in
none)
@@ -207,5 +210,12 @@ create_file() {
expect 0 symlink test ${name}
;;
esac
-   expect 0 lchown ${name} ${uid} ${gid}
+   if [ -n "${3}" -a -n "${4}" -a -n "${5}" ]; then
+   expect 0 lchmod ${name} ${3}
+   expect 0 lchown ${name} ${4} ${5}
+   elif [ -n "${3}" -a -n "${4}" ]; then
+   expect 0 lchown ${name} ${3} ${4}
+   elif [ -n "${3}" ]; then
+   expect 0 lchmod ${name} ${3}
+   fi
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211180 - in head/tools/regression/fstest/tests: chflags chown link rename

2010-08-11 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Aug 11 16:34:44 2010
New Revision: 211180
URL: http://svn.freebsd.org/changeset/base/211180

Log:
  More and more tests.

Modified:
  head/tools/regression/fstest/tests/chflags/00.t
  head/tools/regression/fstest/tests/chflags/10.t
  head/tools/regression/fstest/tests/chflags/11.t
  head/tools/regression/fstest/tests/chown/00.t
  head/tools/regression/fstest/tests/link/00.t
  head/tools/regression/fstest/tests/rename/09.t
  head/tools/regression/fstest/tests/rename/10.t
  head/tools/regression/fstest/tests/rename/21.t

Modified: head/tools/regression/fstest/tests/chflags/00.t
==
--- head/tools/regression/fstest/tests/chflags/00.t Wed Aug 11 16:34:26 
2010(r211179)
+++ head/tools/regression/fstest/tests/chflags/00.t Wed Aug 11 16:34:44 
2010(r211180)
@@ -14,14 +14,14 @@ FreeBSD:UFS)
userflags="UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE"
systemflags="SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK"
 
-   echo "1..247"
+   echo "1..780"
;;
 FreeBSD:ZFS)
allflags="UF_NODUMP,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK"
userflags="UF_NODUMP"
systemflags="SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK"
 
-   echo "1..167"
+   echo "1..520"
;;
 *)
quick_exit
@@ -36,41 +36,39 @@ expect 0 mkdir ${n2} 0755
 cdir=`pwd`
 cd ${n2}
 
-expect 0 create ${n0} 0644
-expect none stat ${n0} flags
-expect 0 chflags ${n0} ${allflags}
-expect ${allflags} stat ${n0} flags
-expect 0 chflags ${n0} ${userflags}
-expect ${userflags} stat ${n0} flags
-expect 0 chflags ${n0} ${systemflags}
-expect ${systemflags} stat ${n0} flags
-expect 0 chflags ${n0} none
-expect none stat ${n0} flags
-expect 0 unlink ${n0}
-
-expect 0 mkdir ${n0} 0644
-expect none stat ${n0} flags
-expect 0 chflags ${n0} ${allflags}
-expect ${allflags} stat ${n0} flags
-expect 0 chflags ${n0} ${userflags}
-expect ${userflags} stat ${n0} flags
-expect 0 chflags ${n0} ${systemflags}
-expect ${systemflags} stat ${n0} flags
-expect 0 chflags ${n0} none
-expect none stat ${n0} flags
-expect 0 rmdir ${n0}
-
-expect 0 mkfifo ${n0} 0644
-expect none stat ${n0} flags
-expect 0 chflags ${n0} ${allflags}
-expect ${allflags} stat ${n0} flags
-expect 0 chflags ${n0} ${userflags}
-expect ${userflags} stat ${n0} flags
-expect 0 chflags ${n0} ${systemflags}
-expect ${systemflags} stat ${n0} flags
-expect 0 chflags ${n0} none
-expect none stat ${n0} flags
-expect 0 unlink ${n0}
+for type in regular dir fifo block char socket; do
+   create_file ${type} ${n0} 0 0
+   expect none stat ${n0} flags
+   expect 0 chflags ${n0} ${allflags}
+   expect ${allflags} stat ${n0} flags
+   expect 0 chflags ${n0} ${userflags}
+   expect ${userflags} stat ${n0} flags
+   expect 0 chflags ${n0} ${systemflags}
+   expect ${systemflags} stat ${n0} flags
+   expect 0 chflags ${n0} none
+   expect none stat ${n0} flags
+   if [ "${type}" = "dir" ]; then
+   expect 0 rmdir ${n0}
+   else
+   expect 0 unlink ${n0}
+   fi
+
+   create_file ${type} ${n0} 0 0
+   expect none stat ${n0} flags
+   expect 0 lchflags ${n0} ${allflags}
+   expect ${allflags} stat ${n0} flags
+   expect 0 lchflags ${n0} ${userflags}
+   expect ${userflags} stat ${n0} flags
+   expect 0 lchflags ${n0} ${systemflags}
+   expect ${systemflags} stat ${n0} flags
+   expect 0 lchflags ${n0} none
+   expect none stat ${n0} flags
+   if [ "${type}" = "dir" ]; then
+   expect 0 rmdir ${n0}
+   else
+   expect 0 unlink ${n0}
+   fi
+done
 
 expect 0 create ${n0} 0644
 expect 0 symlink ${n0} ${n1}
@@ -111,86 +109,70 @@ expect 0 unlink ${n1}
 expect 0 unlink ${n0}
 
 # successful chflags(2) updates ctime.
-expect 0 create ${n0} 0644
-for flag in `echo ${allflags},none | tr ',' ' '`; do
-   ctime1=`${fstest} stat ${n0} ctime`
-   sleep 1
-   expect 0 chflags ${n0} ${flag}
-   ctime2=`${fstest} stat ${n0} ctime`
-   test_check $ctime1 -lt $ctime2
+for type in regular dir fifo block char socket symlink; do
+   if [ "${type}" != "symlink" ]; then
+   create_file ${type} ${n0} 0 0
+   for flag in `echo ${allflags},none | tr ',' ' '`; do
+   ctime1=`${fstest} stat ${n0} ctime`
+   sleep 1
+   expect 0 chflags ${n0} ${flag}
+   ctime2=`${fstest} stat ${n0} ctime`
+   test_check $ctime1 -lt $ctime2
+   done
+   if [ "${type}" = "dir" ]; then
+   expect 0 rmdir ${n0}
+   else
+   expect 0 unlink ${n0}
+   fi
+   fi
+
+   create_file ${type} ${n0} 0 0
+   for flag in `echo ${allflags},none | tr ',' ' '`; do
+   ctime1=`${fstest} lstat ${n0} ctime`
+

svn commit: r211179 - head/tools/regression/fstest/tests

2010-08-11 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Aug 11 16:34:26 2010
New Revision: 211179
URL: http://svn.freebsd.org/changeset/base/211179

Log:
  Move create_file() to misc.sh, as it is going to be used in more places.

Modified:
  head/tools/regression/fstest/tests/misc.sh

Modified: head/tools/regression/fstest/tests/misc.sh
==
--- head/tools/regression/fstest/tests/misc.sh  Wed Aug 11 16:33:17 2010
(r211178)
+++ head/tools/regression/fstest/tests/misc.sh  Wed Aug 11 16:34:26 2010
(r211179)
@@ -174,3 +174,38 @@ require()
fi
quick_exit
 }
+
+create_file() {
+   type="${1}"
+   name="${2}"
+   uid="${3}"
+   gid="${4}"
+
+   case "${type}" in
+   none)
+   return
+   ;;
+   regular)
+   expect 0 create ${name} 0644
+   ;;
+   dir)
+   expect 0 mkdir ${name} 0755
+   ;;
+   fifo)
+   expect 0 mkfifo ${name} 0644
+   ;;
+   block)
+   expect 0 mknod ${name} b 0644 1 2
+   ;;
+   char)
+   expect 0 mknod ${name} c 0644 1 2
+   ;;
+   socket)
+   expect 0 bind ${name}
+   ;;
+   symlink)
+   expect 0 symlink test ${name}
+   ;;
+   esac
+   expect 0 lchown ${name} ${uid} ${gid}
+}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211178 - in head/tools/regression/fstest/tests: chflags chmod chown link mkdir mkfifo mknod open rename rmdir symlink truncate unlink

2010-08-11 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Aug 11 16:33:17 2010
New Revision: 211178
URL: http://svn.freebsd.org/changeset/base/211178

Log:
  Make use of recently added dirgen_max() and namegen_max() to implement
  ENAMETOOLONG checks.

Modified:
  head/tools/regression/fstest/tests/chflags/02.t
  head/tools/regression/fstest/tests/chflags/03.t
  head/tools/regression/fstest/tests/chmod/02.t
  head/tools/regression/fstest/tests/chmod/03.t
  head/tools/regression/fstest/tests/chown/02.t
  head/tools/regression/fstest/tests/chown/03.t
  head/tools/regression/fstest/tests/link/02.t
  head/tools/regression/fstest/tests/link/03.t
  head/tools/regression/fstest/tests/mkdir/02.t
  head/tools/regression/fstest/tests/mkdir/03.t
  head/tools/regression/fstest/tests/mkfifo/02.t
  head/tools/regression/fstest/tests/mkfifo/03.t
  head/tools/regression/fstest/tests/mknod/02.t
  head/tools/regression/fstest/tests/mknod/03.t
  head/tools/regression/fstest/tests/open/02.t
  head/tools/regression/fstest/tests/open/03.t
  head/tools/regression/fstest/tests/rename/01.t
  head/tools/regression/fstest/tests/rename/02.t
  head/tools/regression/fstest/tests/rmdir/02.t
  head/tools/regression/fstest/tests/rmdir/03.t
  head/tools/regression/fstest/tests/symlink/02.t
  head/tools/regression/fstest/tests/symlink/03.t
  head/tools/regression/fstest/tests/truncate/02.t
  head/tools/regression/fstest/tests/truncate/03.t
  head/tools/regression/fstest/tests/unlink/02.t
  head/tools/regression/fstest/tests/unlink/03.t

Modified: head/tools/regression/fstest/tests/chflags/02.t
==
--- head/tools/regression/fstest/tests/chflags/02.t Wed Aug 11 16:29:12 
2010(r211177)
+++ head/tools/regression/fstest/tests/chflags/02.t Wed Aug 11 16:33:17 
2010(r211178)
@@ -1,18 +1,28 @@
 #!/bin/sh
 # $FreeBSD$
 
-desc="chflags returns ENAMETOOLONG if a component of a pathname exceeded 255 
characters"
+desc="chflags returns ENAMETOOLONG if a component of a pathname exceeded 
{NAME_MAX} characters"
 
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
 require chflags
 
-echo "1..6"
+echo "1..12"
 
-expect 0 create ${name255} 0644
-expect 0 chflags ${name255} SF_IMMUTABLE
-expect SF_IMMUTABLE stat ${name255} flags
-expect 0 chflags ${name255} none
-expect 0 unlink ${name255}
-expect ENAMETOOLONG chflags ${name256} SF_IMMUTABLE
+nx=`namegen_max`
+nxx="${nx}x"
+
+expect 0 create ${nx} 0644
+expect 0 chflags ${nx} SF_IMMUTABLE
+expect SF_IMMUTABLE stat ${nx} flags
+expect 0 chflags ${nx} none
+expect 0 unlink ${nx}
+expect ENAMETOOLONG chflags ${nxx} SF_IMMUTABLE
+
+expect 0 create ${nx} 0644
+expect 0 lchflags ${nx} SF_IMMUTABLE
+expect SF_IMMUTABLE stat ${nx} flags
+expect 0 lchflags ${nx} none
+expect 0 unlink ${nx}
+expect ENAMETOOLONG lchflags ${nxx} SF_IMMUTABLE

Modified: head/tools/regression/fstest/tests/chflags/03.t
==
--- head/tools/regression/fstest/tests/chflags/03.t Wed Aug 11 16:29:12 
2010(r211177)
+++ head/tools/regression/fstest/tests/chflags/03.t Wed Aug 11 16:33:17 
2010(r211178)
@@ -1,25 +1,32 @@
 #!/bin/sh
 # $FreeBSD$
 
-desc="chflags returns ENAMETOOLONG if an entire path name exceeded 1023 
characters"
+desc="chflags returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} 
characters"
 
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
 require chflags
 
-echo "1..13"
+echo "1..12"
 
-expect 0 mkdir ${name255} 0755
-expect 0 mkdir ${name255}/${name255} 0755
-expect 0 mkdir ${name255}/${name255}/${name255} 0755
-expect 0 mkdir ${path1021} 0755
-expect 0 create ${path1023} 0644
-expect 0 chflags ${path1023} SF_IMMUTABLE
-expect 0 chflags ${path1023} none
-expect 0 unlink ${path1023}
-expect ENAMETOOLONG chflags ${path1024} SF_IMMUTABLE
-expect 0 rmdir ${path1021}
-expect 0 rmdir ${name255}/${name255}/${name255}
-expect 0 rmdir ${name255}/${name255}
-expect 0 rmdir ${name255}
+nx=`dirgen_max`
+nxx="${nx}x"
+
+mkdir -p "${nx%/*}"
+
+expect 0 create ${nx} 0644
+expect 0 chflags ${nx} SF_IMMUTABLE
+expect SF_IMMUTABLE stat ${nx} flags
+expect 0 chflags ${nx} none
+expect 0 unlink ${nx}
+expect ENAMETOOLONG chflags ${nxx} SF_IMMUTABLE
+
+expect 0 create ${nx} 0644
+expect 0 lchflags ${nx} SF_IMMUTABLE
+expect SF_IMMUTABLE stat ${nx} flags
+expect 0 lchflags ${nx} none
+expect 0 unlink ${nx}
+expect ENAMETOOLONG lchflags ${nxx} SF_IMMUTABLE
+
+rm -rf "${nx%%/*}"

Modified: head/tools/regression/fstest/tests/chmod/02.t
==
--- head/tools/regression/fstest/tests/chmod/02.t   Wed Aug 11 16:29:12 
2010(r211177)
+++ head/tools/regression/fstest/tests/chmod/02.t   Wed Aug 11 16:33:17 
2010(r211178)
@@ -1,15 +1,24 @@
 #!/bin/sh
 # $FreeBSD$
 
-desc="chmod returns ENAMETOOLONG if a component of a pathname exceeded 255 
characters"
+desc="chmod returns ENAMETOOLONG if a component of a pathnam

svn commit: r211177 - head/tools/regression/fstest/tests

2010-08-11 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Aug 11 16:29:12 2010
New Revision: 211177
URL: http://svn.freebsd.org/changeset/base/211177

Log:
  Instead of hardcoding {NAME_MAX} as 255 and {PATH_MAX} as 1024 obtain those 
from
  pathconf(2) and properly generate too long file names.
  This should fix ENAMETOOLONG checks on Linux.

Modified:
  head/tools/regression/fstest/tests/misc.sh

Modified: head/tools/regression/fstest/tests/misc.sh
==
--- head/tools/regression/fstest/tests/misc.sh  Wed Aug 11 10:51:27 2010
(r211176)
+++ head/tools/regression/fstest/tests/misc.sh  Wed Aug 11 16:29:12 2010
(r211177)
@@ -2,13 +2,6 @@
 
 ntest=1
 
-name253="_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_12"
-name255="${name253}34"
-name256="${name255}5"
-path1021="${name255}/${name255}/${name255}/${name253}"
-path1023="${path1021}/x"
-path1024="${path1023}x"
-
 case "${dir}" in
 /*)
maindir="${dir}/../.."
@@ -99,6 +92,52 @@ namegen()
echo "fstest_`dd if=/dev/urandom bs=1k count=1 2>/dev/null | openssl 
md5`"
 }
 
+namegen_len()
+{
+   len="${1}"
+
+   name=""
+   while :; do
+   namepart="`dd if=/dev/urandom bs=64 count=1 2>/dev/null | 
openssl md5`"
+   name="${name}${namepart}"
+   curlen=`printf "%s" "${name}" | wc -c`
+   [ ${curlen} -lt ${len} ] || break
+   done
+   name=`echo "${name}" | cut -b -${len}`
+   printf "%s" "${name}"
+}
+
+# POSIX:
+# {NAME_MAX}
+# Maximum number of bytes in a filename (not including terminating null).
+namegen_max()
+{
+   name_max=`${fstest} pathconf . _PC_NAME_MAX`
+   namegen_len ${name_max}
+}
+
+# POSIX:
+# {PATH_MAX}
+# Maximum number of bytes in a pathname, including the terminating null 
character.
+dirgen_max()
+{
+   name_max=`${fstest} pathconf . _PC_NAME_MAX`
+   complen=$((name_max/2))
+   path_max=`${fstest} pathconf . _PC_PATH_MAX`
+   # "...including the terminating null character."
+   path_max=$((path_max-1))
+
+   name=""
+   while :; do
+   name="${name}`namegen_len ${complen}`/"
+   curlen=`printf "%s" "${name}" | wc -c`
+   [ ${curlen} -lt ${path_max} ] || break
+   done
+   name=`echo "${name}" | cut -b -${path_max}`
+   name=`echo "${name}" | sed -E 's@/$...@x@'`
+   printf "%s" "${name}"
+}
+
 quick_exit()
 {
echo "1..1"
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r211157 - in head/sys: modules modules/if_carp net netinet netinet6

2010-08-11 Thread Pawel Jakub Dawidek
On Wed, Aug 11, 2010 at 12:51:51AM +, Will Andrews wrote:
> Author: will
> Date: Wed Aug 11 00:51:50 2010
> New Revision: 211157
> URL: http://svn.freebsd.org/changeset/base/211157
> 
> Log:
>   Allow carp(4) to be loaded as a kernel module.  Follow precedent set by
>   bridge(4), lagg(4) etc. and make use of function pointers and
>   pf_proto_register() to hook carp into the network stack.
>   
>   Currently, because of the uncertainty about whether the unload path is free
>   of race condition panics, unloads are disallowed by default.  Compiling with
>   CARPMOD_CAN_UNLOAD in CFLAGS removes this anti foot shooting measure.

Wouldn't it be better to allow unload only if there are no carp(4)
interfaces? I'd be glad to destroy my carp interfaces before unloading
the module, but recompiling the kernel to unload it? Not so much.

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgp5qhokYFKRK.pgp
Description: PGP signature


svn commit: r211156 - in head/tools/regression/fstest/tests: mkdir open rename unlink

2010-08-10 Thread Pawel Jakub Dawidek
Author: pjd
Date: Tue Aug 10 22:57:43 2010
New Revision: 211156
URL: http://svn.freebsd.org/changeset/base/211156

Log:
  More tests, mostly related to devices and sockets.

Modified:
  head/tools/regression/fstest/tests/mkdir/10.t
  head/tools/regression/fstest/tests/open/22.t
  head/tools/regression/fstest/tests/rename/00.t
  head/tools/regression/fstest/tests/rename/06.t
  head/tools/regression/fstest/tests/rename/07.t
  head/tools/regression/fstest/tests/rename/10.t
  head/tools/regression/fstest/tests/rename/13.t
  head/tools/regression/fstest/tests/rename/14.t
  head/tools/regression/fstest/tests/rename/15.t
  head/tools/regression/fstest/tests/rename/20.t
  head/tools/regression/fstest/tests/unlink/00.t
  head/tools/regression/fstest/tests/unlink/11.t

Modified: head/tools/regression/fstest/tests/mkdir/10.t
==
--- head/tools/regression/fstest/tests/mkdir/10.t   Tue Aug 10 22:45:59 
2010(r211155)
+++ head/tools/regression/fstest/tests/mkdir/10.t   Tue Aug 10 22:57:43 
2010(r211156)
@@ -6,7 +6,7 @@ desc="mkdir returns EEXIST if the named 
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..12"
+echo "1..21"
 
 n0=`namegen`
 
@@ -25,3 +25,15 @@ expect 0 unlink ${n0}
 expect 0 mkfifo ${n0} 0644
 expect EEXIST mkdir ${n0} 0755
 expect 0 unlink ${n0}
+
+expect 0 mknod ${n0} b 0644 1 2
+expect EEXIST mkdir ${n0} 0755
+expect 0 unlink ${n0}
+
+expect 0 mknod ${n0} c 0644 1 2
+expect EEXIST mkdir ${n0} 0755
+expect 0 unlink ${n0}
+
+expect 0 bind ${n0}
+expect EEXIST mkdir ${n0} 0755
+expect 0 unlink ${n0}

Modified: head/tools/regression/fstest/tests/open/22.t
==
--- head/tools/regression/fstest/tests/open/22.tTue Aug 10 22:45:59 
2010(r211155)
+++ head/tools/regression/fstest/tests/open/22.tTue Aug 10 22:57:43 
2010(r211156)
@@ -6,7 +6,7 @@ desc="open returns EEXIST when O_CREAT a
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..12"
+echo "1..21"
 
 n0=`namegen`
 
@@ -25,3 +25,15 @@ expect 0 unlink ${n0}
 expect 0 symlink test ${n0}
 expect EEXIST open ${n0} O_CREAT,O_EXCL 0644
 expect 0 unlink ${n0}
+
+expect 0 mknod ${n0} b 0644 1 2
+expect EEXIST open ${n0} O_CREAT,O_EXCL 0644
+expect 0 unlink ${n0}
+
+expect 0 mknod ${n0} c 0644 1 2
+expect EEXIST open ${n0} O_CREAT,O_EXCL 0644
+expect 0 unlink ${n0}
+
+expect 0 bind ${n0}
+expect EEXIST open ${n0} O_CREAT,O_EXCL 0644
+expect 0 unlink ${n0}

Modified: head/tools/regression/fstest/tests/rename/00.t
==
--- head/tools/regression/fstest/tests/rename/00.t  Tue Aug 10 22:45:59 
2010(r211155)
+++ head/tools/regression/fstest/tests/rename/00.t  Tue Aug 10 22:57:43 
2010(r211156)
@@ -6,7 +6,7 @@ desc="rename changes file name"
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..79"
+echo "1..145"
 
 n0=`namegen`
 n1=`namegen`
@@ -57,6 +57,54 @@ expect fifo,${inode},0644,2 lstat ${n2} 
 expect 0 unlink ${n0}
 expect 0 unlink ${n2}
 
+expect 0 mknod ${n0} b 0644 1 2
+expect block,0644,1 lstat ${n0} type,mode,nlink
+inode=`${fstest} lstat ${n0} inode`
+expect 0 rename ${n0} ${n1}
+expect ENOENT lstat ${n0} type,mode,nlink
+expect block,${inode},0644,1 lstat ${n1} type,inode,mode,nlink
+expect 0 link ${n1} ${n0}
+expect block,${inode},0644,2 lstat ${n0} type,inode,mode,nlink
+expect block,${inode},0644,2 lstat ${n1} type,inode,mode,nlink
+expect 0 rename ${n1} ${n2}
+expect block,${inode},0644,2 lstat ${n0} type,inode,mode,nlink
+expect ENOENT lstat ${n1} type,mode,nlink
+expect block,${inode},0644,2 lstat ${n2} type,inode,mode,nlink
+expect 0 unlink ${n0}
+expect 0 unlink ${n2}
+
+expect 0 mknod ${n0} c 0644 1 2
+expect char,0644,1 lstat ${n0} type,mode,nlink
+inode=`${fstest} lstat ${n0} inode`
+expect 0 rename ${n0} ${n1}
+expect ENOENT lstat ${n0} type,mode,nlink
+expect char,${inode},0644,1 lstat ${n1} type,inode,mode,nlink
+expect 0 link ${n1} ${n0}
+expect char,${inode},0644,2 lstat ${n0} type,inode,mode,nlink
+expect char,${inode},0644,2 lstat ${n1} type,inode,mode,nlink
+expect 0 rename ${n1} ${n2}
+expect char,${inode},0644,2 lstat ${n0} type,inode,mode,nlink
+expect ENOENT lstat ${n1} type,mode,nlink
+expect char,${inode},0644,2 lstat ${n2} type,inode,mode,nlink
+expect 0 unlink ${n0}
+expect 0 unlink ${n2}
+
+expect 0 -U 0133 bind ${n0}
+expect socket,0644,1 lstat ${n0} type,mode,nlink
+inode=`${fstest} lstat ${n0} inode`
+expect 0 rename ${n0} ${n1}
+expect ENOENT lstat ${n0} type,mode,nlink
+expect socket,${inode},0644,1 lstat ${n1} type,inode,mode,nlink
+expect 0 link ${n1} ${n0}
+expect socket,${inode},0644,2 lstat ${n0} type,inode,mode,nlink
+expect socket,${inode},0644,2 lstat ${n1} type,inode,mode,nlink
+expect 0 rename ${n1} ${n2}
+expect socket,${inode},0644,2 lstat ${n0} type,inode,mode,nlink
+expect ENOENT lstat ${n1} type,mode,nlink
+expec

svn commit: r211116 - head/tools/regression/fstest

2010-08-09 Thread Pawel Jakub Dawidek
Author: pjd
Date: Mon Aug  9 20:16:52 2010
New Revision: 26
URL: http://svn.freebsd.org/changeset/base/26

Log:
  Linux has no strlcpy().

Modified:
  head/tools/regression/fstest/fstest.c

Modified: head/tools/regression/fstest/fstest.c
==
--- head/tools/regression/fstest/fstest.c   Mon Aug  9 19:53:24 2010
(r25)
+++ head/tools/regression/fstest/fstest.c   Mon Aug  9 20:16:52 2010
(r26)
@@ -541,7 +541,8 @@ call_syscall(struct syscall_desc *scall,
struct sockaddr_un sunx;
 
sunx.sun_family = AF_UNIX;
-   strlcpy(sunx.sun_path, STR(0), sizeof(sunx.sun_path));
+   strncpy(sunx.sun_path, STR(0), sizeof(sunx.sun_path) - 1);
+   sunx.sun_path[sizeof(sunx.sun_path) - 1] = '\0';
rval = socket(AF_UNIX, SOCK_STREAM, 0);
if (rval < 0)
break;
@@ -553,7 +554,8 @@ call_syscall(struct syscall_desc *scall,
struct sockaddr_un sunx;
 
sunx.sun_family = AF_UNIX;
-   strlcpy(sunx.sun_path, STR(0), sizeof(sunx.sun_path));
+   strncpy(sunx.sun_path, STR(0), sizeof(sunx.sun_path) - 1);
+   sunx.sun_path[sizeof(sunx.sun_path) - 1] = '\0';
rval = socket(AF_UNIX, SOCK_STREAM, 0);
if (rval < 0)
break;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211110 - head/tools/regression/fstest

2010-08-09 Thread Pawel Jakub Dawidek
Author: pjd
Date: Mon Aug  9 17:42:04 2010
New Revision: 20
URL: http://svn.freebsd.org/changeset/base/20

Log:
  Fix bind(2) and connect(2) support on Solaris.

Modified:
  head/tools/regression/fstest/fstest.c

Modified: head/tools/regression/fstest/fstest.c
==
--- head/tools/regression/fstest/fstest.c   Mon Aug  9 17:40:59 2010
(r211109)
+++ head/tools/regression/fstest/fstest.c   Mon Aug  9 17:42:04 2010
(r20)
@@ -538,28 +538,26 @@ call_syscall(struct syscall_desc *scall,
}
case ACTION_BIND:
{
-   struct sockaddr_un sun;
+   struct sockaddr_un sunx;
 
-   sun.sun_family = AF_UNIX;
-   strlcpy(sun.sun_path, STR(0), sizeof(sun.sun_path));
-   sun.sun_len = SUN_LEN(&sun);
+   sunx.sun_family = AF_UNIX;
+   strlcpy(sunx.sun_path, STR(0), sizeof(sunx.sun_path));
rval = socket(AF_UNIX, SOCK_STREAM, 0);
if (rval < 0)
break;
-   rval = bind(rval, (struct sockaddr *)&sun, sizeof(sun));
+   rval = bind(rval, (struct sockaddr *)&sunx, sizeof(sunx));
break;
}
case ACTION_CONNECT:
{
-   struct sockaddr_un sun;
+   struct sockaddr_un sunx;
 
-   sun.sun_family = AF_UNIX;
-   strlcpy(sun.sun_path, STR(0), sizeof(sun.sun_path));
-   sun.sun_len = SUN_LEN(&sun);
+   sunx.sun_family = AF_UNIX;
+   strlcpy(sunx.sun_path, STR(0), sizeof(sunx.sun_path));
rval = socket(AF_UNIX, SOCK_STREAM, 0);
if (rval < 0)
break;
-   rval = connect(rval, (struct sockaddr *)&sun, sizeof(sun));
+   rval = connect(rval, (struct sockaddr *)&sunx, sizeof(sunx));
break;
}
case ACTION_CHMOD:
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211109 - head/tools/regression/fstest/tests

2010-08-09 Thread Pawel Jakub Dawidek
Author: pjd
Date: Mon Aug  9 17:40:59 2010
New Revision: 211109
URL: http://svn.freebsd.org/changeset/base/211109

Log:
  Fix file system type detection on Solaris.

Modified:
  head/tools/regression/fstest/tests/conf

Modified: head/tools/regression/fstest/tests/conf
==
--- head/tools/regression/fstest/tests/conf Mon Aug  9 17:37:29 2010
(r211108)
+++ head/tools/regression/fstest/tests/conf Mon Aug  9 17:40:59 2010
(r211109)
@@ -13,7 +13,7 @@ FreeBSD|Darwin)
;;
 Solaris|SunOS)
GREP=ggrep
-   pattern=`df -k . | tail -1 | awk '{printf("%s on %s \n", $1, $6)}'`
+   pattern=`df -Pk . | tail -1 | awk '{printf("%s on %s \n", $1, $6)}'`
fs=`mount -v | ${GREP} -E "^${pattern}" | awk '{print $5}' | \
tr -s '[:lower:]' '[:upper:]'`
;;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211108 - head/tools/regression/fstest/tests

2010-08-09 Thread Pawel Jakub Dawidek
Author: pjd
Date: Mon Aug  9 17:37:29 2010
New Revision: 211108
URL: http://svn.freebsd.org/changeset/base/211108

Log:
  Small tweaks.

Modified:
  head/tools/regression/fstest/tests/conf
  head/tools/regression/fstest/tests/misc.sh

Modified: head/tools/regression/fstest/tests/conf
==
--- head/tools/regression/fstest/tests/conf Mon Aug  9 17:34:57 2010
(r211107)
+++ head/tools/regression/fstest/tests/conf Mon Aug  9 17:37:29 2010
(r211108)
@@ -1,7 +1,7 @@
 # $FreeBSD$
 # fstest configuration file
 
-# Known operating systems: FreeBSD, SunOS, Linux
+# Supported operating systems: FreeBSD, Darwin, SunOS, Linux
 os=`uname`
 
 case "${os}" in
@@ -9,12 +9,12 @@ FreeBSD|Darwin)
GREP=grep
#fs=`df -T . | tail -1 | awk '{print $2}'`
pattern="`df . | tail -1 | awk '{printf("%s on %s \n", $1, $6)}'`"
-   fs=`mount | egrep "^${pattern}" | awk -F '[(,]' '{print toupper($2)}'`
+   fs=`mount | ${GREP} -E "^${pattern}" | awk -F '[(,]' '{print 
toupper($2)}'`
;;
 Solaris|SunOS)
GREP=ggrep
pattern=`df -k . | tail -1 | awk '{printf("%s on %s \n", $1, $6)}'`
-   fs=`mount -v | egrep "^${pattern}" | awk '{print $5}' | \
+   fs=`mount -v | ${GREP} -E "^${pattern}" | awk '{print $5}' | \
tr -s '[:lower:]' '[:upper:]'`
;;
 Linux)

Modified: head/tools/regression/fstest/tests/misc.sh
==
--- head/tools/regression/fstest/tests/misc.sh  Mon Aug  9 17:34:57 2010
(r211107)
+++ head/tools/regression/fstest/tests/misc.sh  Mon Aug  9 17:37:29 2010
(r211108)
@@ -25,7 +25,7 @@ expect()
e="${1}"
shift
r=`${fstest} $* 2>/dev/null | tail -1`
-   echo "${r}" | ${GREP} -E '^'${e}'$' >/dev/null 2>&1
+   echo "${r}" | ${GREP} -Eq '^'${e}'$'
if [ $? -eq 0 ]; then
if [ -z "${todomsg}" ]; then
echo "ok ${ntest}"
@@ -40,7 +40,7 @@ expect()
fi
fi
todomsg=""
-   ntest=`expr $ntest + 1`
+   ntest=$((ntest+1))
 }
 
 jexpect()
@@ -50,7 +50,7 @@ jexpect()
e="${3}"
shift 3
r=`jail -s ${s} / fstest 127.0.0.1 /bin/sh -c "cd ${d} && ${fstest} $* 
2>/dev/null" | tail -1`
-   echo "${r}" | ${GREP} -E '^'${e}'$' >/dev/null 2>&1
+   echo "${r}" | ${GREP} -Eq '^'${e}'$'
if [ $? -eq 0 ]; then
if [ -z "${todomsg}" ]; then
echo "ok ${ntest}"
@@ -65,7 +65,7 @@ jexpect()
fi
fi
todomsg=""
-   ntest=`expr $ntest + 1`
+   ntest=$((ntest+1))
 }
 
 test_check()
@@ -84,7 +84,7 @@ test_check()
fi
fi
todomsg=""
-   ntest=`expr $ntest + 1`
+   ntest=$((ntest+1))
 }
 
 todo()
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r211107 - head/tools/regression/fstest/tests

2010-08-09 Thread Pawel Jakub Dawidek
Author: pjd
Date: Mon Aug  9 17:34:57 2010
New Revision: 211107
URL: http://svn.freebsd.org/changeset/base/211107

Log:
  No need to use grep to check if path start with /.
  
  Suggested by: ed

Modified:
  head/tools/regression/fstest/tests/misc.sh

Modified: head/tools/regression/fstest/tests/misc.sh
==
--- head/tools/regression/fstest/tests/misc.sh  Mon Aug  9 17:33:03 2010
(r211106)
+++ head/tools/regression/fstest/tests/misc.sh  Mon Aug  9 17:34:57 2010
(r211107)
@@ -9,12 +9,14 @@ path1021="${name255}/${name255}/${name25
 path1023="${path1021}/x"
 path1024="${path1023}x"
 
-echo ${dir} | grep '^/' >/dev/null 2>&1
-if [ $? -eq 0 ]; then
+case "${dir}" in
+/*)
maindir="${dir}/../.."
-else
+   ;;
+*)
maindir="`pwd`/${dir}/../.."
-fi
+   ;;
+esac
 fstest="${maindir}/fstest"
 . ${maindir}/tests/conf
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r210999 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2010-08-07 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sat Aug  7 10:23:54 2010
New Revision: 210999
URL: http://svn.freebsd.org/changeset/base/210999

Log:
  In FreeBSD we use 'jailed' property.
  
  MFC after:2 weeks

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Sat Aug 
 7 08:31:32 2010(r210998)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Sat Aug 
 7 10:23:54 2010(r210999)
@@ -357,7 +357,7 @@ zfs_secpolicy_setprop(const char *name, 
 * quota on things *under* (ie. contained by)
 * the thing they own.
 */
-   if (dsl_prop_get_integer(name, "zoned", &zoned,
+   if (dsl_prop_get_integer(name, "jailed", &zoned,
setpoint))
return (EPERM);
if (!zoned || strlen(name) <= strlen(setpoint))
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r210984 - in head/tools/regression/fstest/tests: chmod chown granular link mkdir mkfifo open rename rmdir symlink truncate unlink

2010-08-06 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug  6 23:58:54 2010
New Revision: 210984
URL: http://svn.freebsd.org/changeset/base/210984

Log:
  Various cleanups, mostly to make the test work on FreeBSD/ZFS.

Modified:
  head/tools/regression/fstest/tests/chmod/08.t
  head/tools/regression/fstest/tests/chmod/09.t
  head/tools/regression/fstest/tests/chown/08.t
  head/tools/regression/fstest/tests/chown/09.t
  head/tools/regression/fstest/tests/granular/00.t
  head/tools/regression/fstest/tests/granular/01.t
  head/tools/regression/fstest/tests/granular/02.t
  head/tools/regression/fstest/tests/granular/03.t
  head/tools/regression/fstest/tests/granular/04.t
  head/tools/regression/fstest/tests/granular/05.t
  head/tools/regression/fstest/tests/link/05.t
  head/tools/regression/fstest/tests/link/12.t
  head/tools/regression/fstest/tests/link/13.t
  head/tools/regression/fstest/tests/link/14.t
  head/tools/regression/fstest/tests/link/15.t
  head/tools/regression/fstest/tests/link/16.t
  head/tools/regression/fstest/tests/mkdir/08.t
  head/tools/regression/fstest/tests/mkdir/09.t
  head/tools/regression/fstest/tests/mkdir/11.t
  head/tools/regression/fstest/tests/mkfifo/08.t
  head/tools/regression/fstest/tests/mkfifo/10.t
  head/tools/regression/fstest/tests/mkfifo/11.t
  head/tools/regression/fstest/tests/open/09.t
  head/tools/regression/fstest/tests/open/10.t
  head/tools/regression/fstest/tests/open/11.t
  head/tools/regression/fstest/tests/open/14.t
  head/tools/regression/fstest/tests/open/15.t
  head/tools/regression/fstest/tests/open/18.t
  head/tools/regression/fstest/tests/open/19.t
  head/tools/regression/fstest/tests/open/20.t
  head/tools/regression/fstest/tests/rename/06.t
  head/tools/regression/fstest/tests/rename/07.t
  head/tools/regression/fstest/tests/rename/08.t
  head/tools/regression/fstest/tests/rename/15.t
  head/tools/regression/fstest/tests/rename/16.t
  head/tools/regression/fstest/tests/rmdir/09.t
  head/tools/regression/fstest/tests/rmdir/10.t
  head/tools/regression/fstest/tests/rmdir/13.t
  head/tools/regression/fstest/tests/rmdir/14.t
  head/tools/regression/fstest/tests/symlink/09.t
  head/tools/regression/fstest/tests/symlink/10.t
  head/tools/regression/fstest/tests/symlink/11.t
  head/tools/regression/fstest/tests/truncate/08.t
  head/tools/regression/fstest/tests/truncate/10.t
  head/tools/regression/fstest/tests/truncate/11.t
  head/tools/regression/fstest/tests/unlink/09.t
  head/tools/regression/fstest/tests/unlink/10.t
  head/tools/regression/fstest/tests/unlink/12.t

Modified: head/tools/regression/fstest/tests/chmod/08.t
==
--- head/tools/regression/fstest/tests/chmod/08.t   Fri Aug  6 23:52:16 
2010(r210983)
+++ head/tools/regression/fstest/tests/chmod/08.t   Fri Aug  6 23:58:54 
2010(r210984)
@@ -8,7 +8,16 @@ dir=`dirname $0`
 
 require chflags
 
-echo "1..40"
+case "${os}:${fs}" in
+FreeBSD:ZFS)
+   echo "1..22"
+   ;;
+FreeBSD:UFS)
+   echo "1..44"
+   ;;
+*)
+   quick_exit
+esac
 
 n0=`namegen`
 
@@ -18,30 +27,7 @@ expect EPERM chmod ${n0} 0600
 expect 0644 stat ${n0} mode
 expect 0 chflags ${n0} none
 expect 0 chmod ${n0} 0600
-expect 0 unlink ${n0}
-
-expect 0 create ${n0} 0644
-expect 0 chflags ${n0} UF_IMMUTABLE
-expect EPERM chmod ${n0} 0600
-expect 0644 stat ${n0} mode
-expect 0 chflags ${n0} none
-expect 0 chmod ${n0} 0600
-expect 0 unlink ${n0}
-
-expect 0 create ${n0} 0644
-expect 0 chflags ${n0} SF_APPEND
-expect EPERM chmod ${n0} 0600
-expect 0644 stat ${n0} mode
-expect 0 chflags ${n0} none
-expect 0 chmod ${n0} 0600
-expect 0 unlink ${n0}
-
-expect 0 create ${n0} 0644
-expect 0 chflags ${n0} UF_APPEND
-expect EPERM chmod ${n0} 0600
-expect 0644 stat ${n0} mode
-expect 0 chflags ${n0} none
-expect 0 chmod ${n0} 0600
+expect 0600 stat ${n0} mode
 expect 0 unlink ${n0}
 
 expect 0 create ${n0} 0644
@@ -51,9 +37,50 @@ expect 0600 stat ${n0} mode
 expect 0 chflags ${n0} none
 expect 0 unlink ${n0}
 
-expect 0 create ${n0} 0644
-expect 0 chflags ${n0} UF_NOUNLINK
-expect 0 chmod ${n0} 0600
-expect 0600 stat ${n0} mode
-expect 0 chflags ${n0} none
-expect 0 unlink ${n0}
+case "${os}:${fs}" in
+FreeBSD:ZFS)
+   expect 0 create ${n0} 0644
+   expect 0 chflags ${n0} SF_APPEND
+   expect 0 chmod ${n0} 0600
+   expect 0600 stat ${n0} mode
+   expect 0 chflags ${n0} none
+   expect 0 chmod ${n0} 0600
+   expect 0600 stat ${n0} mode
+   expect 0 unlink ${n0}
+   ;;
+FreeBSD:UFS)
+   expect 0 create ${n0} 0644
+   expect 0 chflags ${n0} SF_APPEND
+   expect EPERM chmod ${n0} 0600
+   expect 0644 stat ${n0} mode
+   expect 0 chflags ${n0} none
+   expect 0 chmod ${n0} 0600
+   expect 0600 stat ${n0} mode
+   expect 0 unlink ${n0}
+
+   expect 0 create ${n0} 0644
+   expect 0 chflags ${n0} UF_IMMUTABLE
+   expect EPERM chmod ${n0} 0600
+   expect 0644 stat ${n0} mode
+   expect 0 c

Re: svn commit: r210969 - head/tools/regression/fstest/tests

2010-08-06 Thread Pawel Jakub Dawidek
On Fri, Aug 06, 2010 at 11:06:04PM +0200, Ed Schouten wrote:
> Hi Pawel,
> 
> * Pawel Jakub Dawidek  wrote:
> > +   fs=`mount | egrep "^${pattern}" | awk -F '[(,]' '{print $2}' | tr 
> > '[:lower:]' '[:upper:]'`
> > ...
> > +   fs=`df -PT . | tail -1 | awk '{print $2}' | tr '[:lower:]' '[:upper:]'`
> 
> Maybe this can be solved using '{ print toupper($2) }'?

Indeed, thanks.

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgpPkXiYbAp3P.pgp
Description: PGP signature


svn commit: r210973 - head/tools/regression/fstest/tests

2010-08-06 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug  6 21:58:53 2010
New Revision: 210973
URL: http://svn.freebsd.org/changeset/base/210973

Log:
  ${GREP} can only be used after loading 'conf'.

Modified:
  head/tools/regression/fstest/tests/misc.sh

Modified: head/tools/regression/fstest/tests/misc.sh
==
--- head/tools/regression/fstest/tests/misc.sh  Fri Aug  6 21:57:11 2010
(r210972)
+++ head/tools/regression/fstest/tests/misc.sh  Fri Aug  6 21:58:53 2010
(r210973)
@@ -9,7 +9,7 @@ path1021="${name255}/${name255}/${name25
 path1023="${path1021}/x"
 path1024="${path1023}x"
 
-echo ${dir} | ${GREP} -E '^/' >/dev/null 2>&1
+echo ${dir} | grep '^/' >/dev/null 2>&1
 if [ $? -eq 0 ]; then
maindir="${dir}/../.."
 else
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r210972 - head/tools/regression/fstest/tests

2010-08-06 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug  6 21:57:11 2010
New Revision: 210972
URL: http://svn.freebsd.org/changeset/base/210972

Log:
  Don't use egrep directly - use ${GREP}.

Modified:
  head/tools/regression/fstest/tests/misc.sh

Modified: head/tools/regression/fstest/tests/misc.sh
==
--- head/tools/regression/fstest/tests/misc.sh  Fri Aug  6 21:56:32 2010
(r210971)
+++ head/tools/regression/fstest/tests/misc.sh  Fri Aug  6 21:57:11 2010
(r210972)
@@ -9,7 +9,7 @@ path1021="${name255}/${name255}/${name25
 path1023="${path1021}/x"
 path1024="${path1023}x"
 
-echo ${dir} | egrep '^/' >/dev/null 2>&1
+echo ${dir} | ${GREP} -E '^/' >/dev/null 2>&1
 if [ $? -eq 0 ]; then
maindir="${dir}/../.."
 else
@@ -23,7 +23,7 @@ expect()
e="${1}"
shift
r=`${fstest} $* 2>/dev/null | tail -1`
-   echo "${r}" | egrep '^'${e}'$' >/dev/null 2>&1
+   echo "${r}" | ${GREP} -E '^'${e}'$' >/dev/null 2>&1
if [ $? -eq 0 ]; then
if [ -z "${todomsg}" ]; then
echo "ok ${ntest}"
@@ -48,7 +48,7 @@ jexpect()
e="${3}"
shift 3
r=`jail -s ${s} / fstest 127.0.0.1 /bin/sh -c "cd ${d} && ${fstest} $* 
2>/dev/null" | tail -1`
-   echo "${r}" | egrep '^'${e}'$' >/dev/null 2>&1
+   echo "${r}" | ${GREP} -E '^'${e}'$' >/dev/null 2>&1
if [ $? -eq 0 ]; then
if [ -z "${todomsg}" ]; then
echo "ok ${ntest}"
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r210971 - head/tools/regression/fstest/tests

2010-08-06 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug  6 21:56:32 2010
New Revision: 210971
URL: http://svn.freebsd.org/changeset/base/210971

Log:
  Check first todo() argument against operating system name and operating system
  name plus file system name.

Modified:
  head/tools/regression/fstest/tests/misc.sh

Modified: head/tools/regression/fstest/tests/misc.sh
==
--- head/tools/regression/fstest/tests/misc.sh  Fri Aug  6 21:53:50 2010
(r210970)
+++ head/tools/regression/fstest/tests/misc.sh  Fri Aug  6 21:56:32 2010
(r210971)
@@ -87,8 +87,7 @@ test_check()
 
 todo()
 {
-   echo "${os}" | $GREP -iq "${1}"
-   if [ $? -eq 0 ]; then
+   if [ "${os}" = "${1}" -o "${os}:${fs}" = "${1}" ]; then
todomsg="${2}"
fi
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r210970 - head/tools/regression/fstest/tests

2010-08-06 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug  6 21:53:50 2010
New Revision: 210970
URL: http://svn.freebsd.org/changeset/base/210970

Log:
  For FreeBSD and Linux use awk's toupper() function.
  
  Suggested by: ed

Modified:
  head/tools/regression/fstest/tests/conf

Modified: head/tools/regression/fstest/tests/conf
==
--- head/tools/regression/fstest/tests/conf Fri Aug  6 21:02:53 2010
(r210969)
+++ head/tools/regression/fstest/tests/conf Fri Aug  6 21:53:50 2010
(r210970)
@@ -9,7 +9,7 @@ FreeBSD|Darwin)
GREP=grep
#fs=`df -T . | tail -1 | awk '{print $2}'`
pattern="`df . | tail -1 | awk '{printf("%s on %s \n", $1, $6)}'`"
-   fs=`mount | egrep "^${pattern}" | awk -F '[(,]' '{print $2}' | tr 
'[:lower:]' '[:upper:]'`
+   fs=`mount | egrep "^${pattern}" | awk -F '[(,]' '{print toupper($2)}'`
;;
 Solaris|SunOS)
GREP=ggrep
@@ -19,7 +19,7 @@ Solaris|SunOS)
;;
 Linux)
GREP=grep
-   fs=`df -PT . | tail -1 | awk '{print $2}' | tr '[:lower:]' '[:upper:]'`
+   fs=`df -PT . | tail -1 | awk '{print toupper($2)}'`
;;
 *)
echo "Unsupported operating system ${os}." >/dev/stderr
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r210969 - head/tools/regression/fstest/tests

2010-08-06 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug  6 21:02:53 2010
New Revision: 210969
URL: http://svn.freebsd.org/changeset/base/210969

Log:
  Convert file system type to upper case.

Modified:
  head/tools/regression/fstest/tests/conf

Modified: head/tools/regression/fstest/tests/conf
==
--- head/tools/regression/fstest/tests/conf Fri Aug  6 20:55:49 2010
(r210968)
+++ head/tools/regression/fstest/tests/conf Fri Aug  6 21:02:53 2010
(r210969)
@@ -9,7 +9,7 @@ FreeBSD|Darwin)
GREP=grep
#fs=`df -T . | tail -1 | awk '{print $2}'`
pattern="`df . | tail -1 | awk '{printf("%s on %s \n", $1, $6)}'`"
-   fs=`mount | egrep "^${pattern}" | awk -F '[(,]' '{print $2}'`
+   fs=`mount | egrep "^${pattern}" | awk -F '[(,]' '{print $2}' | tr 
'[:lower:]' '[:upper:]'`
;;
 Solaris|SunOS)
GREP=ggrep
@@ -19,7 +19,7 @@ Solaris|SunOS)
;;
 Linux)
GREP=grep
-   fs=`df -PT . | tail -1 | awk '{print $2}'`
+   fs=`df -PT . | tail -1 | awk '{print $2}' | tr '[:lower:]' '[:upper:]'`
;;
 *)
echo "Unsupported operating system ${os}." >/dev/stderr
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r210967 - head/tools/regression/fstest/tests/mknod

2010-08-06 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug  6 20:51:39 2010
New Revision: 210967
URL: http://svn.freebsd.org/changeset/base/210967

Log:
  Add tests for mknod(2).
  
  Submitted by: Jan Senolt 
  Submitted by: Milan Cermak 
  Polished by:  pjd

Added:
  head/tools/regression/fstest/tests/mknod/
  head/tools/regression/fstest/tests/mknod/00.t   (contents, props changed)
  head/tools/regression/fstest/tests/mknod/01.t   (contents, props changed)
  head/tools/regression/fstest/tests/mknod/02.t   (contents, props changed)
  head/tools/regression/fstest/tests/mknod/03.t   (contents, props changed)
  head/tools/regression/fstest/tests/mknod/04.t   (contents, props changed)
  head/tools/regression/fstest/tests/mknod/05.t   (contents, props changed)
  head/tools/regression/fstest/tests/mknod/06.t   (contents, props changed)
  head/tools/regression/fstest/tests/mknod/07.t   (contents, props changed)
  head/tools/regression/fstest/tests/mknod/08.t   (contents, props changed)
  head/tools/regression/fstest/tests/mknod/09.t   (contents, props changed)
  head/tools/regression/fstest/tests/mknod/10.t   (contents, props changed)
  head/tools/regression/fstest/tests/mknod/11.t   (contents, props changed)

Added: head/tools/regression/fstest/tests/mknod/00.t
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/fstest/tests/mknod/00.t   Fri Aug  6 20:51:39 
2010(r210967)
@@ -0,0 +1,73 @@
+#!/bin/sh
+# $FreeBSD$
+
+desc="mknod creates fifo files"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+echo "1..36"
+
+n0=`namegen`
+n1=`namegen`
+
+expect 0 mkdir ${n1} 0755
+cdir=`pwd`
+cd ${n1}
+
+# POSIX: The file permission bits of the new FIFO shall be initialized from
+# mode. The file permission bits of the mode argument shall be modified by the
+# process' file creation mask.
+expect 0 mknod ${n0} f 0755 0 0
+expect fifo,0755 lstat ${n0} type,mode
+expect 0 unlink ${n0}
+expect 0 mknod ${n0} f 0151 0 0
+expect fifo,0151 lstat ${n0} type,mode
+expect 0 unlink ${n0}
+expect 0 -U 077 mknod ${n0} f 0151 0 0
+expect fifo,0100 lstat ${n0} type,mode
+expect 0 unlink ${n0}
+expect 0 -U 070 mknod ${n0} f 0345 0 0
+expect fifo,0305 lstat ${n0} type,mode
+expect 0 unlink ${n0}
+expect 0 -U 0501 mknod ${n0} f 0345 0 0
+expect fifo,0244 lstat ${n0} type,mode
+expect 0 unlink ${n0}
+
+# POSIX: The FIFO's user ID shall be set to the process' effective user ID.
+# The FIFO's group ID shall be set to the group ID of the parent directory or 
to
+# the effective group ID of the process.
+expect 0 chown . 65535 65535
+expect 0 -u 65535 -g 65535 mknod ${n0} f 0755 0 0
+expect 65535,65535 lstat ${n0} uid,gid
+expect 0 unlink ${n0}
+expect 0 -u 65535 -g 65534 mknod ${n0} f 0755 0 0
+expect "65535,6553[45]" lstat ${n0} uid,gid
+expect 0 unlink ${n0}
+expect 0 chmod . 0777
+expect 0 -u 65534 -g 65533 mknod ${n0} f 0755 0 0
+expect "65534,6553[35]" lstat ${n0} uid,gid
+expect 0 unlink ${n0}
+
+# POSIX: Upon successful completion, mkfifo() shall mark for update the
+# st_atime, st_ctime, and st_mtime fields of the file. Also, the st_ctime and
+# st_mtime fields of the directory that contains the new entry shall be marked
+# for update.
+expect 0 chown . 0 0
+time=`${fstest} stat . ctime`
+sleep 1
+expect 0 mknod ${n0} f 0755 0 0
+atime=`${fstest} stat ${n0} atime`
+test_check $time -lt $atime
+mtime=`${fstest} stat ${n0} mtime`
+test_check $time -lt $mtime
+ctime=`${fstest} stat ${n0} ctime`
+test_check $time -lt $ctime
+mtime=`${fstest} stat . mtime`
+test_check $time -lt $mtime
+ctime=`${fstest} stat . ctime`
+test_check $time -lt $ctime
+expect 0 unlink ${n0}
+
+cd ${cdir}
+expect 0 rmdir ${n1}

Added: head/tools/regression/fstest/tests/mknod/01.t
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/fstest/tests/mknod/01.t   Fri Aug  6 20:51:39 
2010(r210967)
@@ -0,0 +1,18 @@
+#!/bin/sh
+# $FreeBSD$
+
+desc="mknod returns ENOTDIR if a component of the path prefix is not a 
directory"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+echo "1..5"
+
+n0=`namegen`
+n1=`namegen`
+
+expect 0 mkdir ${n0} 0755
+expect 0 create ${n0}/${n1} 0644
+expect ENOTDIR mknod ${n0}/${n1}/test f 0644 0 0
+expect 0 unlink ${n0}/${n1}
+expect 0 rmdir ${n0}

Added: head/tools/regression/fstest/tests/mknod/02.t
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/fstest/tests/mknod/02.t   Fri Aug  6 20:51:39 
2010(r210967)
@@ -0,0 +1,13 @@
+#!/bin/sh
+# $FreeBSD$
+
+desc="mknod returns ENAMETOOLONG if a component of a pathname exceeded 255 
characters"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+echo "1..3"
+
+expect 0 mknod ${name255} f 0644 0 0
+expect 0 unlink ${name255}
+expect ENAMETOOLONG mknod ${name256

svn commit: r210965 - head/tools/regression/fstest

2010-08-06 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug  6 20:48:10 2010
New Revision: 210965
URL: http://svn.freebsd.org/changeset/base/210965

Log:
  Add mknod(2) support.
  
  Submitted by: Jan Senolt 
  Submitted by: Milan Cermak 

Modified:
  head/tools/regression/fstest/fstest.c

Modified: head/tools/regression/fstest/fstest.c
==
--- head/tools/regression/fstest/fstest.c   Fri Aug  6 20:46:26 2010
(r210964)
+++ head/tools/regression/fstest/fstest.c   Fri Aug  6 20:48:10 2010
(r210965)
@@ -27,9 +27,13 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
+#ifndef makedev
+#include 
+#endif
 
 #include 
 #include 
@@ -66,6 +70,7 @@ enum action {
ACTION_SYMLINK,
ACTION_RENAME,
ACTION_MKFIFO,
+   ACTION_MKNOD,
ACTION_BIND,
ACTION_CONNECT,
ACTION_CHMOD,
@@ -115,6 +120,7 @@ static struct syscall_desc syscalls[] = 
{ "symlink", ACTION_SYMLINK, { TYPE_STRING, TYPE_STRING, TYPE_NONE } },
{ "rename", ACTION_RENAME, { TYPE_STRING, TYPE_STRING, TYPE_NONE } },
{ "mkfifo", ACTION_MKFIFO, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } },
+   { "mknod", ACTION_MKNOD, { TYPE_STRING, TYPE_STRING, TYPE_NUMBER, 
TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE} },
{ "bind", ACTION_BIND, { TYPE_STRING, TYPE_NONE } },
{ "connect", ACTION_CONNECT, { TYPE_STRING, TYPE_NONE } },
{ "chmod", ACTION_CHMOD, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } },
@@ -359,6 +365,10 @@ show_stat(struct stat64 *sp, const char 
else if (strcmp(what, "flags") == 0)
printf("%s", flags2str(chflags_flags, (long long)sp->st_flags));
 #endif
+   else if (strcmp(what, "major") == 0)
+   printf("%u", (unsigned int)major(sp->st_rdev));
+   else if (strcmp(what, "minor") == 0)
+   printf("%u", (unsigned int)minor(sp->st_rdev));
else if (strcmp(what, "type") == 0) {
switch (sp->st_mode & S_IFMT) {
case S_IFIFO:
@@ -503,6 +513,29 @@ call_syscall(struct syscall_desc *scall,
case ACTION_MKFIFO:
rval = mkfifo(STR(0), (mode_t)NUM(1));
break;
+   case ACTION_MKNOD:
+   {
+   mode_t ntype;
+   dev_t dev;
+
+   dev = makedev(NUM(3), NUM(4));
+   if (strcmp(STR(1), "c") == 0)   /* character device */
+   ntype = S_IFCHR;
+   else if (strcmp(STR(1), "b") == 0)  /* block device */
+   ntype = S_IFBLK;
+   else if (strcmp(STR(1), "f") == 0)  /* fifo special */
+   ntype = S_IFIFO;
+   else if (strcmp(STR(1), "d") == 0)  /* directory */
+   ntype = S_IFDIR;
+   else if (strcmp(STR(1), "o") == 0)  /* regular file */
+   ntype = S_IFREG;
+   else {
+   fprintf(stderr, "wrong argument 1\n");
+   exit(1);
+   }
+   rval = mknod(STR(0), ntype | NUM(2), dev);
+   break;
+   }
case ACTION_BIND:
{
struct sockaddr_un sun;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r210964 - head/tools/regression/fstest

2010-08-06 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug  6 20:46:26 2010
New Revision: 210964
URL: http://svn.freebsd.org/changeset/base/210964

Log:
  Sort includes.

Modified:
  head/tools/regression/fstest/fstest.c

Modified: head/tools/regression/fstest/fstest.c
==
--- head/tools/regression/fstest/fstest.c   Fri Aug  6 20:46:06 2010
(r210963)
+++ head/tools/regression/fstest/fstest.c   Fri Aug  6 20:46:26 2010
(r210964)
@@ -30,15 +30,16 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
+
+#include 
+#include 
+#include 
 #include 
 #include 
+#include 
+#include 
 #include 
-#include 
-#include 
-#include 
+#include 
 
 #ifndef HAS_TRUNCATE64
 #definetruncate64  truncate
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r210956 - head/tools/regression/fstest/tests/open

2010-08-06 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug  6 19:22:42 2010
New Revision: 210956
URL: http://svn.freebsd.org/changeset/base/210956

Log:
  open(2) returns EOPNOTSUPP when trying to open a socket.

Added:
  head/tools/regression/fstest/tests/open/24.t   (contents, props changed)

Added: head/tools/regression/fstest/tests/open/24.t
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/fstest/tests/open/24.tFri Aug  6 19:22:42 
2010(r210956)
@@ -0,0 +1,17 @@
+#!/bin/sh
+# $FreeBSD$
+
+desc="open returns EOPNOTSUPP when trying to open UNIX domain socket"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+echo "1..5"
+
+n0=`namegen`
+
+expect 0 bind ${n0}
+expect "EOPNOTSUPP" open ${n0} O_RDONLY
+expect "EOPNOTSUPP" open ${n0} O_WRONLY
+expect "EOPNOTSUPP" open ${n0} O_RDWR
+expect 0 unlink ${n0}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r210955 - head/tools/regression/fstest/tests/open

2010-08-06 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug  6 19:20:35 2010
New Revision: 210955
URL: http://svn.freebsd.org/changeset/base/210955

Log:
  Test for EACCES also when opening FIFO or directory.

Modified:
  head/tools/regression/fstest/tests/open/06.t

Modified: head/tools/regression/fstest/tests/open/06.t
==
--- head/tools/regression/fstest/tests/open/06.tFri Aug  6 19:19:14 
2010(r210954)
+++ head/tools/regression/fstest/tests/open/06.tFri Aug  6 19:20:35 
2010(r210955)
@@ -6,7 +6,7 @@ desc="open returns EACCES when the requi
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..65"
+echo "1..144"
 
 n0=`namegen`
 n1=`namegen`
@@ -16,47 +16,104 @@ expect 0 chown ${n0} 65534 65534
 cdir=`pwd`
 cd ${n0}
 
+# Regular file.
+
 expect 0 -u 65534 -g 65534 create ${n1} 0644
 
 expect 0 -u 65534 -g 65534 chmod ${n1} 0600
-expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY
-expect 0 -u 65534 -g 65534 open ${n1} O_WRONLY
-expect 0 -u 65534 -g 65534 open ${n1} O_RDWR
+expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY,
+expect 0 -u 65534 -g 65534 open ${n1} O_WRONLY,
+expect 0 -u 65534 -g 65534 open ${n1} O_RDWR,
 expect 0 -u 65534 -g 65534 chmod ${n1} 0060
-expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY
-expect 0 -u 65533 -g 65534 open ${n1} O_WRONLY
-expect 0 -u 65533 -g 65534 open ${n1} O_RDWR
+expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY,
+expect 0 -u 65533 -g 65534 open ${n1} O_WRONLY,
+expect 0 -u 65533 -g 65534 open ${n1} O_RDWR,
 expect 0 -u 65534 -g 65534 chmod ${n1} 0006
-expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY
-expect 0 -u 65533 -g 65533 open ${n1} O_WRONLY
-expect 0 -u 65533 -g 65533 open ${n1} O_RDWR
+expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY,
+expect 0 -u 65533 -g 65533 open ${n1} O_WRONLY,
+expect 0 -u 65533 -g 65533 open ${n1} O_RDWR,
 
 expect 0 -u 65534 -g 65534 chmod ${n1} 0477
-expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY
+expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY,
+expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY,
+expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR,
+expect 0 -u 65534 -g 65534 chmod ${n1} 0747
+expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY,
+expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY,
+expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR,
+expect 0 -u 65534 -g 65534 chmod ${n1} 0774
+expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY,
+expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY,
+expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR,
+
+expect 0 -u 65534 -g 65534 chmod ${n1} 0277
+expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,
+expect 0 -u 65534 -g 65534 open ${n1} O_WRONLY,
+expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR,
+expect 0 -u 65534 -g 65534 chmod ${n1} 0727
+expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,
+expect 0 -u 65533 -g 65534 open ${n1} O_WRONLY,
+expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR,
+expect 0 -u 65534 -g 65534 chmod ${n1} 0772
+expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,
+expect 0 -u 65533 -g 65533 open ${n1} O_WRONLY,
+expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR,
+
+expect 0 -u 65534 -g 65534 chmod ${n1} 0177
+expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,
+expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY,
+expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR,
+expect 0 -u 65534 -g 65534 chmod ${n1} 0717
+expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,
+expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY,
+expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR,
+expect 0 -u 65534 -g 65534 chmod ${n1} 0771
+expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,
+expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY,
+expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR,
+
+expect 0 -u 65534 -g 65534 chmod ${n1} 0077
+expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,
+expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY,
+expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR,
+expect 0 -u 65534 -g 65534 chmod ${n1} 0707
+expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,
+expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY,
+expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR,
+expect 0 -u 65534 -g 65534 chmod ${n1} 0770
+expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,
+expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY,
+expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR,
+
+expect 0 -u 65534 -g 65534 unlink ${n1}
+
+# FIFO.
+
+expect 0 -u 65534 -g 65534 mkfifo ${n1} 0644
+
+expect 0 -u 65534 -g 65534 chmod ${n1} 0600
+expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK
+expect 0 -u 65534 -g 65534 open ${n1} O_RDWR,O_NONBLOCK
+expect 0 -u 65534 -g 65534 chmod ${n1} 0060
+expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK
+expect 0 -u 65533 -g 65534 open ${n1} O_RDWR,O_NONBLOCK
+expect 0 -u 65534 -g 65534 chmod ${n1} 0006
+expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY,O_NONBLOCK
+expect 0 -u 65533 -g 65533 open ${n1} O_RDWR,O_NONBLOCK
+
+expect 0 -u 65534 -g 65534 chmod ${n1} 0477
+expect 0 -u 65

svn commit: r210954 - head/tools/regression/fstest/tests/open

2010-08-06 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug  6 19:19:14 2010
New Revision: 210954
URL: http://svn.freebsd.org/changeset/base/210954

Log:
  Test O_RDONLY|O_RDWR flags as potentially invalid.

Modified:
  head/tools/regression/fstest/tests/open/23.t

Modified: head/tools/regression/fstest/tests/open/23.t
==
--- head/tools/regression/fstest/tests/open/23.tFri Aug  6 19:18:19 
2010(r210953)
+++ head/tools/regression/fstest/tests/open/23.tFri Aug  6 19:19:14 
2010(r210954)
@@ -6,11 +6,12 @@ desc="open may return EINVAL when an att
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..4"
+echo "1..5"
 
 n0=`namegen`
 
 expect 0 create ${n0} 0644
+expect "0|EINVAL" open ${n0} O_RDONLY,O_RDWR
 expect "0|EINVAL" open ${n0} O_WRONLY,O_RDWR
 expect "0|EINVAL" open ${n0} O_RDONLY,O_WRONLY,O_RDWR
 expect 0 unlink ${n0}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r210953 - head/tools/regression/fstest/tests/open

2010-08-06 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug  6 19:18:19 2010
New Revision: 210953
URL: http://svn.freebsd.org/changeset/base/210953

Log:
  Make description readable.

Modified:
  head/tools/regression/fstest/tests/open/13.t

Modified: head/tools/regression/fstest/tests/open/13.t
==
--- head/tools/regression/fstest/tests/open/13.tFri Aug  6 19:16:48 
2010(r210952)
+++ head/tools/regression/fstest/tests/open/13.tFri Aug  6 19:18:19 
2010(r210953)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # $FreeBSD$
 
-desc="open returns EISDIR when he named file is a directory, and the arguments 
specify it is to be modified"
+desc="open returns EISDIR when trying to open a directory for writing"
 
 dir=`dirname $0`
 . ${dir}/../misc.sh
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r210952 - head/tools/regression/fstest

2010-08-06 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Aug  6 19:16:48 2010
New Revision: 210952
URL: http://svn.freebsd.org/changeset/base/210952

Log:
  Add missing -U argument to usage.

Modified:
  head/tools/regression/fstest/fstest.c

Modified: head/tools/regression/fstest/fstest.c
==
--- head/tools/regression/fstest/fstest.c   Fri Aug  6 19:16:20 2010
(r210951)
+++ head/tools/regression/fstest/fstest.c   Fri Aug  6 19:16:48 2010
(r210952)
@@ -257,7 +257,7 @@ static void
 usage(void)
 {
 
-   fprintf(stderr, "usage: fstest [-u uid] [-g gid1[,gid2[...]]] syscall 
args ...\n");
+   fprintf(stderr, "usage: fstest [-U umask] [-u uid] [-g 
gid1[,gid2[...]]] syscall args ...\n");
exit(1);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


<    8   9   10   11   12   13   14   15   16   17   >