Re: unsigned >= 0 comparisons

2012-07-09 Thread David Coppa
On Mon, Jun 25, 2012 at 10:53 PM, Arto Jonsson  wrote:
> On Mon, Jun 25, 2012 at 01:47:18PM -0600, Theo de Raadt wrote:
>> Like, who cares about about commit id's.
>>
>> Projects are just people working together.  A project didn't come up
>> with that diff.  A person did.
>>
>> When we say where something came from, we do it by giving credit, not
>> by referencing some thing which will go away.
>
> Agreed, updated:


Can this go in?

cheers,
david


> Remove >= 0 comparisons on unsigned integers.
>
> Diff by oga at nicotinebsd org
>
> Index: sys/arch/amd64/amd64/machdep.c
> ===
> RCS file: /cvs/src/sys/arch/amd64/amd64/machdep.c,v
> retrieving revision 1.155
> diff -u -r1.155 machdep.c
> --- sys/arch/amd64/amd64/machdep.c  4 Jun 2012 15:19:47 -   1.155
> +++ sys/arch/amd64/amd64/machdep.c  25 Jun 2012 18:38:30 -
> @@ -1652,7 +1652,7 @@
> return 1;
>
> /* Low memory used for various bootstrap things */
> -   if (addr >= 0 && addr < avail_start)
> +   if (addr < avail_start)
> return 1;
>
> /*
> Index: sys/dev/ic/malo.c
> ===
> RCS file: /cvs/src/sys/dev/ic/malo.c,v
> retrieving revision 1.93
> diff -u -r1.93 malo.c
> --- sys/dev/ic/malo.c   3 Jul 2011 21:35:38 -   1.93
> +++ sys/dev/ic/malo.c   25 Jun 2012 18:38:31 -
> @@ -2216,9 +2216,9 @@
>
> bzero(body, sizeof(*body));
> body->action = htole16(1);
> -   if (powerlevel >= 0 && powerlevel < 30)
> +   if (powerlevel < 30)
> body->supportpowerlvl = htole16(5); /* LOW */
> -   else if (powerlevel >= 30 && powerlevel < 60)
> +   else if (powerlevel < 60)
> body->supportpowerlvl = htole16(10);/* MEDIUM */
> else
> body->supportpowerlvl = htole16(15);/* HIGH */



Re: Support keyboards in xf86-input-ws

2012-07-09 Thread Alexandr Shadchin
On Mon, Jul 09, 2012 at 10:35:55PM +0600, Alexandr Shadchin wrote:
> Add functional xf86-input-keyboard in xf86-input-ws (no new features)
> 
> For test add or rewrite xorg.conf:
> 
> Section "InputClass"
>   Identifier "keyboard defaults"
>   MatchIsKeyboard "on"
> 
>   Driver "ws"
>   Option "Device" "/dev/wskbd"
> 
>   Option "XkbModel" "your setting"
>   Option "XkbLayout" "your setting"
>   Option "XkbVariant" "your setting"
>   Option "XKbOptions" "your setting"
> EndSection
> 
> Welcome any feedback.
> 

Fix decode extra keys (ex. multimedia)

-- 
Alexandr Shadchin

Index: man/ws.man
===
RCS file: /cvs/xenocara/driver/xf86-input-ws/man/ws.man,v
retrieving revision 1.13
diff -u -p -w -r1.13 ws.man
--- man/ws.man  12 Jun 2012 17:12:50 -  1.13
+++ man/ws.man  9 Jul 2012 20:36:45 -
@@ -199,6 +199,38 @@ is mapped to the negative W axis motion 
 .I N2
 is mapped to the positive W axis motion.
 Default:\ "6\ 7".
+.TP 4
+.BI "Option \*qXkbRules\*q \*q" rules \*q
+Specifies which XKB rules file to use for interpreting the
+.BR XkbModel ,
+.BR XkbLayout ,
+.BR XkbVariant ,
+and
+.B XkbOptions
+settings.
+Default:\ "base".
+.TP 4
+.BI "Option \*qXkbModel\*q \*q" modelname \*q
+Specifies the XKB keyboard model name.
+Default:\ "pc105".
+.TP 4
+.BI "Option \*qXkbLayout\*q \*q" layoutname \*q
+Specifies the XKB keyboard layout name.
+This is usually the country or language type of the keyboard.
+Default:\ "us".
+.TP 4
+.BI "Option \*qXkbVariant\*q \*q" variants \*q
+Specifies the XKB keyboard variant components.
+These can be used to enhance the keyboard layout details.
+Default:\ not\ set.
+.TP 4
+.BI "Option \*qXkbOptions\*q \*q" options \*q
+Specifies the XKB keyboard option components.
+These can be used to enhance the keyboard behaviour.
+Default:\ not\ set.
+.PP
+For a list of available XKB options, see
+.B xkeyboard-config(__miscmansuffix__).
 .SH "SUPPORTED PROPERTIES"
 The following properties are provided by the
 .B ws
Index: src/ws.c
===
RCS file: /cvs/xenocara/driver/xf86-input-ws/src/ws.c,v
retrieving revision 1.57
diff -u -p -w -r1.57 ws.c
--- src/ws.c8 Jul 2012 14:22:03 -   1.57
+++ src/ws.c9 Jul 2012 20:36:46 -
@@ -23,10 +23,10 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "ws.h"
 
@@ -42,25 +43,45 @@
 #include "ws-properties.h"
 #include 
 
+#define CAPSFLAG   (1 << 0)
+#define NUMFLAG(1 << 1)
+#define SCROLLFLAG (1 << 2)
+#define COMPOSEFLAG(1 << 4)
+
 static MODULESETUPPROTO(SetupProc);
 static MODULETEARDOWNPROTO(TearDownProc);
 
 static int wsPreInit(InputDriverPtr, InputInfoPtr, int);
+static int wsPreInitPointer(InputDriverPtr, InputInfoPtr, int);
+static int wsPreInitKeyboard(InputDriverPtr, InputInfoPtr, int);
 static void wsUnInit(InputDriverPtr, InputInfoPtr, int);
 static int wsProc(DeviceIntPtr, int);
 static int wsDeviceInit(DeviceIntPtr);
+static int wsDeviceInitPointer(DeviceIntPtr);
+static int wsDeviceInitKeyboard(DeviceIntPtr);
 static int wsDeviceOn(DeviceIntPtr);
+static int wsDeviceOnPointer(DeviceIntPtr);
+static int wsDeviceOnKeyboard(DeviceIntPtr);
 static void wsDeviceOff(DeviceIntPtr);
+static void wsDeviceOffPointer(DeviceIntPtr);
+static void wsDeviceOffKeyboard(DeviceIntPtr);
 static void wsReadInput(InputInfoPtr);
+static void ConsoleReadInput(InputInfoPtr);
 static void wsSendButtons(InputInfoPtr, int);
 static int wsSwitchMode(ClientPtr, DeviceIntPtr, int);
-static Bool wsOpen(InputInfoPtr);
-static void wsClose(InputInfoPtr);
+static int wsOpenPointer(InputInfoPtr);
+static int wsOpenKeyboard(InputInfoPtr);
+static void wsClosePointer(InputInfoPtr);
+static void wsCloseKeyboard(InputInfoPtr);
 static void wsControlProc(DeviceIntPtr , PtrCtrl *);
+static void wsKeyboardBell(int, DeviceIntPtr, pointer, int);
+static void wsKeyboardCtrl(DeviceIntPtr, KeybdCtrl *);
 
 static void wsInitCalibProperty(DeviceIntPtr);
 static int wsSetCalibProperty(DeviceIntPtr, Atom, XIPropertyValuePtr, BOOL);
 
+static Bool translate_XT_to_X(InputInfoPtr, int *);
+
 static Atom prop_calibration;
 static Atom prop_swap;
 
@@ -121,16 +142,10 @@ static int
 wsPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
 {
WSDevicePtr priv;
-   MessageType buttons_from = X_CONFIG;
-   char *s;
-   int i, phy_btn = 1, rc = BadValue;
 
-   priv = (WSDevicePtr)calloc(1, sizeof(WSDeviceRec));
-   if (priv == NULL) {
-   rc = BadAlloc;
-   goto fail;
-   }
-   pInfo->private = priv;
+   pInfo->private = priv = (WSDevicePtr)calloc(1, sizeof(WSDeviceRec));
+   if (priv == NULL)
+   return BadAlloc;
 
 #ifdef DEBUG
ws_debug_level = xf86SetIntOption(pInfo->op

Support keyboards in xf86-input-ws

2012-07-09 Thread Alexandr Shadchin
Add functional xf86-input-keyboard in xf86-input-ws (no new features)

For test add or rewrite xorg.conf:

Section "InputClass"
Identifier "keyboard defaults"
MatchIsKeyboard "on"

Driver "ws"
Option "Device" "/dev/wskbd"

Option "XkbModel" "your setting"
Option "XkbLayout" "your setting"
Option "XkbVariant" "your setting"
Option "XKbOptions" "your setting"
EndSection

Welcome any feedback.

-- 
Alexandr Shadchin

Index: man/ws.man
===
RCS file: /cvs/xenocara/driver/xf86-input-ws/man/ws.man,v
retrieving revision 1.13
diff -u -p -w -r1.13 ws.man
--- man/ws.man  12 Jun 2012 17:12:50 -  1.13
+++ man/ws.man  9 Jul 2012 15:54:25 -
@@ -199,6 +199,38 @@ is mapped to the negative W axis motion 
 .I N2
 is mapped to the positive W axis motion.
 Default:\ "6\ 7".
+.TP 4
+.BI "Option \*qXkbRules\*q \*q" rules \*q
+Specifies which XKB rules file to use for interpreting the
+.BR XkbModel ,
+.BR XkbLayout ,
+.BR XkbVariant ,
+and
+.B XkbOptions
+settings.
+Default:\ "base".
+.TP 4
+.BI "Option \*qXkbModel\*q \*q" modelname \*q
+Specifies the XKB keyboard model name.
+Default:\ "pc105".
+.TP 4
+.BI "Option \*qXkbLayout\*q \*q" layoutname \*q
+Specifies the XKB keyboard layout name.
+This is usually the country or language type of the keyboard.
+Default:\ "us".
+.TP 4
+.BI "Option \*qXkbVariant\*q \*q" variants \*q
+Specifies the XKB keyboard variant components.
+These can be used to enhance the keyboard layout details.
+Default:\ not\ set.
+.TP 4
+.BI "Option \*qXkbOptions\*q \*q" options \*q
+Specifies the XKB keyboard option components.
+These can be used to enhance the keyboard behaviour.
+Default:\ not\ set.
+.PP
+For a list of available XKB options, see
+.B xkeyboard-config(__miscmansuffix__).
 .SH "SUPPORTED PROPERTIES"
 The following properties are provided by the
 .B ws
Index: src/ws.c
===
RCS file: /cvs/xenocara/driver/xf86-input-ws/src/ws.c,v
retrieving revision 1.57
diff -u -p -w -r1.57 ws.c
--- src/ws.c8 Jul 2012 14:22:03 -   1.57
+++ src/ws.c9 Jul 2012 15:54:25 -
@@ -23,10 +23,10 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "ws.h"
 
@@ -42,25 +43,45 @@
 #include "ws-properties.h"
 #include 
 
+#define CAPSFLAG   (1 << 0)
+#define NUMFLAG(1 << 1)
+#define SCROLLFLAG (1 << 2)
+#define COMPOSEFLAG(1 << 4)
+
 static MODULESETUPPROTO(SetupProc);
 static MODULETEARDOWNPROTO(TearDownProc);
 
 static int wsPreInit(InputDriverPtr, InputInfoPtr, int);
+static int wsPreInitPointer(InputDriverPtr, InputInfoPtr, int);
+static int wsPreInitKeyboard(InputDriverPtr, InputInfoPtr, int);
 static void wsUnInit(InputDriverPtr, InputInfoPtr, int);
 static int wsProc(DeviceIntPtr, int);
 static int wsDeviceInit(DeviceIntPtr);
+static int wsDeviceInitPointer(DeviceIntPtr);
+static int wsDeviceInitKeyboard(DeviceIntPtr);
 static int wsDeviceOn(DeviceIntPtr);
+static int wsDeviceOnPointer(DeviceIntPtr);
+static int wsDeviceOnKeyboard(DeviceIntPtr);
 static void wsDeviceOff(DeviceIntPtr);
+static void wsDeviceOffPointer(DeviceIntPtr);
+static void wsDeviceOffKeyboard(DeviceIntPtr);
 static void wsReadInput(InputInfoPtr);
+static void ConsoleReadInput(InputInfoPtr);
 static void wsSendButtons(InputInfoPtr, int);
 static int wsSwitchMode(ClientPtr, DeviceIntPtr, int);
-static Bool wsOpen(InputInfoPtr);
-static void wsClose(InputInfoPtr);
+static int wsOpenPointer(InputInfoPtr);
+static int wsOpenKeyboard(InputInfoPtr);
+static void wsClosePointer(InputInfoPtr);
+static void wsCloseKeyboard(InputInfoPtr);
 static void wsControlProc(DeviceIntPtr , PtrCtrl *);
+static void wsKeyboardBell(int, DeviceIntPtr, pointer, int);
+static void wsKeyboardCtrl(DeviceIntPtr, KeybdCtrl *);
 
 static void wsInitCalibProperty(DeviceIntPtr);
 static int wsSetCalibProperty(DeviceIntPtr, Atom, XIPropertyValuePtr, BOOL);
 
+static Bool translate_XT_to_X(InputInfoPtr, int *);
+
 static Atom prop_calibration;
 static Atom prop_swap;
 
@@ -121,16 +142,10 @@ static int
 wsPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
 {
WSDevicePtr priv;
-   MessageType buttons_from = X_CONFIG;
-   char *s;
-   int i, phy_btn = 1, rc = BadValue;
 
-   priv = (WSDevicePtr)calloc(1, sizeof(WSDeviceRec));
-   if (priv == NULL) {
-   rc = BadAlloc;
-   goto fail;
-   }
-   pInfo->private = priv;
+   pInfo->private = priv = (WSDevicePtr)calloc(1, sizeof(WSDeviceRec));
+   if (priv == NULL)
+   return BadAlloc;
 
 #ifdef DEBUG
ws_debug_level = xf86SetIntOption(pInfo->options, "DebugLevel",
@@ -142,6 +157,59 @@ wsPreInit(InputDriverPtr drv, InputInfoP
xf86IDrvMsg(pInfo, X_ERROR, "No

graceful restart diff

2012-07-09 Thread Claudio Jeker
OK, this is a fixed version of the graceful restart diff I have brewing
for a long long long time. It seems to behave in my bgpd test network but
I would like some wider testing (esp. against routers that do GR).

This implements only the "Restarting Client" bits of the RFC -- in other
words bgpd will keep the FIB when the client restarts but it will not do GR
when restarting itself. The capability is still off by default (you need
"announce restart yes" to enable it) and the best is to test first without
GR and if there are no regressions restest with GR enabled.

Make sure to run this on current -current since this needs some of the
recent bgpd commits.
-- 
:wq Claudio

Index: bgpctl/bgpctl.c
===
RCS file: /cvs/src/usr.sbin/bgpctl/bgpctl.c,v
retrieving revision 1.164
diff -u -p -r1.164 bgpctl.c
--- bgpctl/bgpctl.c 27 May 2012 18:53:50 -  1.164
+++ bgpctl/bgpctl.c 8 Jul 2012 10:48:01 -
@@ -52,6 +52,7 @@ intshow_summary_terse_msg(struct imsg
 int show_neighbor_terse(struct imsg *);
 int show_neighbor_msg(struct imsg *, enum neighbor_views);
 voidprint_neighbor_capa_mp(struct peer *);
+voidprint_neighbor_capa_restart(struct peer *);
 voidprint_neighbor_msgstats(struct peer *);
 voidprint_timer(const char *, time_t);
 static char*fmt_timeframe(time_t t);
@@ -168,7 +169,7 @@ main(int argc, char *argv[])
case NONE:
case IRRFILTER:
usage();
-   /* not reached */
+   /* NOTREACHED */
case SHOW:
case SHOW_SUMMARY:
imsg_compose(ibuf, IMSG_CTL_SHOW_NEIGHBOR, 0, 0, -1, NULL, 0);
@@ -648,7 +649,7 @@ show_neighbor_msg(struct imsg *imsg, enu
if (p->capa.peer.mp[i])
hascapamp = 1;
if (hascapamp || p->capa.peer.refresh ||
-   p->capa.peer.restart || p->capa.peer.as4byte) {
+   p->capa.peer.grestart.restart || p->capa.peer.as4byte) {
printf("  Neighbor capabilities:\n");
if (hascapamp) {
printf("Multiprotocol extensions: ");
@@ -657,8 +658,11 @@ show_neighbor_msg(struct imsg *imsg, enu
}
if (p->capa.peer.refresh)
printf("Route Refresh\n");
-   if (p->capa.peer.restart)
-   printf("Graceful Restart\n");
+   if (p->capa.peer.grestart.restart) {
+   printf("Graceful Restart");
+   print_neighbor_capa_restart(p);
+   printf("\n");
+   }
if (p->capa.peer.as4byte)
printf("4-byte AS numbers\n");
}
@@ -726,6 +730,28 @@ print_neighbor_capa_mp(struct peer *p)
 }
 
 void
+print_neighbor_capa_restart(struct peer *p)
+{
+   int comma;
+   u_int8_ti;
+
+   if (p->capa.peer.grestart.timeout)
+   printf(": Timeout: %d, ", p->capa.peer.grestart.timeout);
+   for (i = 0, comma = 0; i < AID_MAX; i++)
+   if (p->capa.peer.grestart.flags[i] & CAPA_GR_PRESENT) {
+   if (!comma &&
+   p->capa.peer.grestart.flags[i] & CAPA_GR_RESTART)
+   printf("restarted, ");
+   if (comma)
+   printf(", ");
+   printf("%s", aid2str(i));
+   if (p->capa.peer.grestart.flags[i] & CAPA_GR_FORWARD)
+   printf(" (preserved)");
+   comma = 1;
+   }
+}
+
+void
 print_neighbor_msgstats(struct peer *p)
 {
printf("  Message statistics:\n");
@@ -753,6 +779,8 @@ print_neighbor_msgstats(struct peer *p)
p->stats.prefix_sent_update, p->stats.prefix_rcvd_update);
printf("  %-15s %10llu %10llu\n", "Withdraws",
p->stats.prefix_sent_withdraw, p->stats.prefix_rcvd_withdraw);
+   printf("  %-15s %10llu %10llu\n", "End-of-Rib",
+   p->stats.prefix_sent_eor, p->stats.prefix_rcvd_eor);
 }
 
 void
@@ -1107,8 +1135,8 @@ show_interface_msg(struct imsg *imsg)
 void
 show_rib_summary_head(void)
 {
-   printf(
-   "flags: * = Valid, > = Selected, I = via IBGP, A = Announced\n");
+   printf("flags: * = Valid, > = Selected, I = via IBGP, A = Announced, "
+   "S = Stale\n");
printf("origin: i = IGP, e = EGP, ? = Incomplete\n\n");
printf("%-5s %-20s %-15s  %5s %5s %s\n", "flags", "destination",
"gateway", "lpref", "med", "aspath origin");
@@ -1152,6 +1180,8 @@ print_flags(u_int8_t flags, int sum)
*p++ = 'A';

Re: set { tos ..., prio ... }

2012-07-09 Thread Henning Brauer
now with the minimum manpage bits. I'd like to get this in pretty much
now - a) to make sure it's in 5.2 before people start using prio much
and b) because i need to fix sth on top which will cause conflict hell
otherwise... oks?

Index: sbin/pfctl/parse.y
===
RCS file: /cvs/src/sbin/pfctl/parse.y,v
retrieving revision 1.615
diff -u -p -r1.615 parse.y
--- sbin/pfctl/parse.y  7 Jul 2012 18:39:21 -   1.615
+++ sbin/pfctl/parse.y  9 Jul 2012 12:55:21 -
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.614 2012/07/07 16:24:32 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.615 2012/07/07 18:39:21 henning Exp $ */
 
 /*
  * Copyright (c) 2001 Markus Friedl.  All rights reserved.
@@ -508,6 +508,7 @@ int parseport(char *, struct range *r, i
 %type hfscopts_list hfscopts_item hfsc_opts
 %type  bandwidth
 %type   filter_opts filter_opt filter_opts_l
+%type   filter_sets filter_set filter_sets_l
 %typeantispoof_opts antispoof_opt antispoof_opts_l
 %typequeue_opts queue_opt queue_opts_l
 %typescrub_opts scrub_opt scrub_opts_l
@@ -979,7 +980,7 @@ scrub_opt   : NODF  {
scrub_opts.marker |= FOM_MAXMSS;
scrub_opts.maxmss = $2;
}
-   | SETTOS tos {
+   | SETTOS tos {  /* XXX remove in 5.3-current */
if (scrub_opts.marker & FOM_SETTOS) {
yyerror("set-tos cannot be respecified");
YYERROR;
@@ -2379,7 +2380,21 @@ filter_opt   : USER uids {
}
filter_opts.rcv = $2;
}
-   | prio {
+   | ONCE {
+   filter_opts.marker |= FOM_ONCE;
+   }
+   | filter_sets
+   ;
+
+filter_sets: SET '{' filter_sets_l '}' { $$ = filter_opts; }
+   | SET filter_set{ $$ = filter_opts; }
+   ;
+
+filter_sets_l  : filter_sets_l comma filter_set
+   | filter_set
+   ;
+
+filter_set : prio {
if (filter_opts.marker & FOM_SETPRIO) {
yyerror("prio cannot be redefined");
YYERROR;
@@ -2388,8 +2403,13 @@ filter_opt   : USER uids {
filter_opts.set_prio[0] = $1.b1;
filter_opts.set_prio[1] = $1.b2;
}
-   | ONCE {
-   filter_opts.marker |= FOM_ONCE;
+   | TOS tos {
+   if (filter_opts.marker & FOM_SETTOS) {
+   yyerror("tos cannot be respecified");
+   YYERROR;
+   }
+   filter_opts.marker |= FOM_SETTOS;
+   filter_opts.settos = $2;
}
;
 
Index: sbin/pfctl/pfctl_parser.c
===
RCS file: /cvs/src/sbin/pfctl/pfctl_parser.c,v
retrieving revision 1.285
diff -u -p -r1.285 pfctl_parser.c
--- sbin/pfctl/pfctl_parser.c   7 Jul 2012 16:24:32 -   1.285
+++ sbin/pfctl/pfctl_parser.c   7 Jul 2012 17:08:31 -
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_parser.c,v 1.283 2011/11/23 10:24:37 henning Exp $ */
+/* $OpenBSD: pfctl_parser.c,v 1.285 2012/07/07 16:24:32 henning Exp $ */
 
 /*
  * Copyright (c) 2001 Daniel Hartmeier
@@ -843,6 +843,25 @@ print_rule(struct pf_rule *r, const char
if (r->tos)
printf(" tos 0x%2.2x", r->tos);
 
+   if (r->set_prio[0] != PF_PRIO_NOTSET ||
+   r->scrub_flags & PFSTATE_SETTOS) {
+   char *comma = "";
+   printf(" set {");
+   if (r->set_prio[0] != PF_PRIO_NOTSET) {
+   if (r->set_prio[0] == r->set_prio[1])
+   printf("%s prio %u", comma, r->set_prio[0]);
+   else
+   printf("%s prio(%u, %u)", comma, r->set_prio[0],
+   r->set_prio[1]);
+   comma = ",";
+   }
+   if (r->scrub_flags & PFSTATE_SETTOS) {
+   printf("%s tos 0x%2.2x", comma, r->set_tos);
+   comma = ",";
+   }
+   printf(" }");
+   }
+
ropts = 0;
if (r->max_states || r->max_src_nodes || r->max_src_states)
ropts = 1;
@@ -998,12 +1017,6 @@ print_rule(struct pf_rule *r, const char
printf("min-ttl %d", r->min_ttl);
ropts = 0;
}
-   if (r->scrub_flags & PFSTATE_SETTOS) {
-   if (!ropts)
-   printf(" ");
-   printf("set-tos 0x%2.2x", r->set_tos);

Re: ftp mput recursiv upload diff for testing

2012-07-09 Thread Jan Klemkow
On Mon, Jul 09, 2012 at 02:00:11PM +0200, Jan Klemkow wrote:
> Hello,
> 
> this is the same diff, but the mapage part it adaptet, for the current
> version of ftp.1 in cvs.
> 
> bye,
> Jan
> 
> On Thu, Jan 26, 2012 at 09:44:45PM +0100, Jan Klemkow wrote:
> > On Thu, Jan 12, 2012 at 09:40:19PM +0100, Jan Klemkow wrote:
> > > Hello,
> > > 
> > > this is my diff for recursive upload for ftp(1).
> > > It modifies the mput command for doing this.
> > > Please test it and tell me everything that is
> > > wrong with it.
> > > 
> > > bye,
> > > Jan
> > > 
> > 
> > I test this patch on OpenBSD 5.0 sparc64.
> > Man diff is improved by jmc.
> 

this time with diff.

Index: cmds.c
===
RCS file: /cvs/src/usr.bin/ftp/cmds.c,v
retrieving revision 1.70
diff -u -p -r1.70 cmds.c
--- cmds.c  5 May 2009 19:35:30 -   1.70
+++ cmds.c  9 Jul 2012 11:56:54 -
@@ -229,17 +229,30 @@ void
 mput(int argc, char *argv[])
 {
extern int optind, optreset;
-   int ch, i, restartit = 0;
+   int ch, i, restartit = 0, recursiv = 0;
sig_t oldintr;
char *cmd, *tp;
-
+   const char *errstr;
+   static int depth = 0, max_depth = 0;
optind = optreset = 1;
 
-   while ((ch = getopt(argc, argv, "c")) != -1) {
+   while ((ch = getopt(argc, argv, "cd:r")) != -1) {
switch(ch) {
case 'c':
restartit = 1;
break;
+   case 'd':
+   max_depth = strtonum(optarg, 0, INT_MAX, &errstr);
+   if (errstr != NULL) {
+   fprintf(ttyout, "bad depth value, %s: %s",
+   errstr, optarg);
+   code = -1;
+   return;
+   }
+   break;
+   case 'r':
+   depth = 1;
+   break;
default:
goto usage;
}
@@ -247,7 +260,8 @@ mput(int argc, char *argv[])
 
if (argc - optind < 1 && !another(&argc, &argv, "local-files")) {
 usage:
-   fprintf(ttyout, "usage: %s [-c] local-files\n", argv[0]);
+   fprintf(ttyout, "usage: %s [-cr] [-d depth] local-files\n",
+   argv[0]);
code = -1;
return;
}
@@ -318,11 +332,16 @@ usage:
mflag = 0;
return;
}
+
+   if (depth)
+   depth++;
+
for (i = 1; i < argc; i++) {
char **cpp;
glob_t gl;
int flags;
 
+   /* Copy files without word expantion */
if (!doglob) {
if (mflag && confirm(argv[0], argv[i])) {
tp = (ntflag) ? dotrans(argv[i]) : argv[i];
@@ -348,6 +367,7 @@ usage:
continue;
}
 
+   /* expanding file names */
memset(&gl, 0, sizeof(gl));
flags = GLOB_BRACE|GLOB_NOCHECK|GLOB_QUOTE|GLOB_TILDE;
if (glob(argv[i], flags, NULL, &gl) || gl.gl_pathc == 0) {
@@ -355,8 +375,58 @@ usage:
globfree(&gl);
continue;
}
+
+   /* traverse all expanded file names */
for (cpp = gl.gl_pathv; cpp && *cpp != NULL; cpp++) {
+   struct stat filestat;
+
if (mflag && confirm(argv[0], *cpp)) {
+
+   /* 
+* If file is a directory then create a new one
+* at the remote machine.
+*/
+   stat(*cpp, &filestat);
+
+   if (S_ISDIR(filestat.st_mode)) {
+   char* xargv[] = {argv[0], *cpp};
+
+   if (depth == max_depth) {
+   continue;
+   }
+
+   makedir(2, xargv);
+
+   /*
+* Copy the hole directory recursivly.
+*/
+   if (chdir(*cpp) != 0) {
+   warn("local: %s", *cpp);
+   continue;
+   }
+
+   xargv[1] = *cpp;
+   cd(2, xargv);
+   if (dirchange != 1) {
+   mflag = 0;
+   goto out;
+   }
+

Re: ftp mput recursiv upload diff for testing

2012-07-09 Thread Jan Klemkow
Hello,

this is the same diff, but the mapage part it adaptet, for the current
version of ftp.1 in cvs.

bye,
Jan

On Thu, Jan 26, 2012 at 09:44:45PM +0100, Jan Klemkow wrote:
> On Thu, Jan 12, 2012 at 09:40:19PM +0100, Jan Klemkow wrote:
> > Hello,
> > 
> > this is my diff for recursive upload for ftp(1).
> > It modifies the mput command for doing this.
> > Please test it and tell me everything that is
> > wrong with it.
> > 
> > bye,
> > Jan
> > 
> 
> I test this patch on OpenBSD 5.0 sparc64.
> Man diff is improved by jmc.



Re: tedu old comment about cpu affinity.

2012-07-09 Thread Kenneth R Westerback
On Mon, Jul 09, 2012 at 10:47:16AM +0200, Christiano F. Haesbaert wrote:
> This no longer applies, it is probably a leftover from the days when we
> had a global runqueue. Discussed with blambert.
> 
> ok ?
> 
> Index: sched_bsd.c
> ===
> RCS file: /cvs/src/sys/kern/sched_bsd.c,v
> retrieving revision 1.29
> diff -d -u -p -r1.29 sched_bsd.c
> --- sched_bsd.c   23 Mar 2012 15:51:26 -  1.29
> +++ sched_bsd.c   9 Jul 2012 08:45:32 -
> @@ -464,16 +464,7 @@ resched_proc(struct proc *p, u_char pri)
>  
>   /*
>* XXXSMP
> -  * Since p->p_cpu persists across a context switch,
> -  * this gives us *very weak* processor affinity, in
> -  * that we notify the CPU on which the process last
> -  * ran that it should try to switch.
> -  *
> -  * This does not guarantee that the process will run on
> -  * that processor next, because another processor might
> -  * grab it the next time it performs a context switch.
> -  *
> -  * This also does not handle the case where its last
> +  * This does not handle the case where its last
>* CPU is running a higher-priority process, but every
>* other CPU is running a lower-priority process.  There
>* are ways to handle this situation, but they're not
> 

If it doesn't apply it should die. ok krw@

 Ken



tedu old comment about cpu affinity.

2012-07-09 Thread Christiano F. Haesbaert
This no longer applies, it is probably a leftover from the days when we
had a global runqueue. Discussed with blambert.

ok ?

Index: sched_bsd.c
===
RCS file: /cvs/src/sys/kern/sched_bsd.c,v
retrieving revision 1.29
diff -d -u -p -r1.29 sched_bsd.c
--- sched_bsd.c 23 Mar 2012 15:51:26 -  1.29
+++ sched_bsd.c 9 Jul 2012 08:45:32 -
@@ -464,16 +464,7 @@ resched_proc(struct proc *p, u_char pri)
 
/*
 * XXXSMP
-* Since p->p_cpu persists across a context switch,
-* this gives us *very weak* processor affinity, in
-* that we notify the CPU on which the process last
-* ran that it should try to switch.
-*
-* This does not guarantee that the process will run on
-* that processor next, because another processor might
-* grab it the next time it performs a context switch.
-*
-* This also does not handle the case where its last
+* This does not handle the case where its last
 * CPU is running a higher-priority process, but every
 * other CPU is running a lower-priority process.  There
 * are ways to handle this situation, but they're not