aue(4) states half-duplex by default ?

2011-09-27 Thread Christopher Zimmermann
Hi,

I just started using a aue(4) device. Now I am a bit confused about
full-duplex / half-duplex operation.


The manpage states:

full-duplex
Force full duplex operation.  The interface will operate in
half duplex mode if this media option is not specified.

But for me ifconfig aue0 says:

aue0: flags=8843UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST mtu 1500
lladdr 00:05:1b:e5:9a:02
priority: 0
groups: egress
media: Ethernet autoselect (100baseTX full-duplex)
status: active
inet6 fe80::205:1bff:fee5:9a02%aue0 prefixlen 64 scopeid 0x6
inet 192.168.1.37 netmask 0xff00 broadcast 192.168.1.255


My hostname.aue0 just says dhcp. Nothing about full-duplex.

Which one is wrong now? Manpage or ifconfig?


Christopher



Re: aue(4) states half-duplex by default ?

2011-09-27 Thread Brad

On 27/09/11 1:59 PM, Christopher Zimmermann wrote:

Hi,

I just started using a aue(4) device. Now I am a bit confused about
full-duplex / half-duplex operation.


The manpage states:

full-duplex
 Force full duplex operation.  The interface will operate in
 half duplex mode if this media option is not specified.

But for me ifconfig aue0 says:

aue0: flags=8843UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST  mtu 1500
 lladdr 00:05:1b:e5:9a:02
 priority: 0
 groups: egress
 media: Ethernet autoselect (100baseTX full-duplex)
 status: active
 inet6 fe80::205:1bff:fee5:9a02%aue0 prefixlen 64 scopeid 0x6
 inet 192.168.1.37 netmask 0xff00 broadcast 192.168.1.255


My hostname.aue0 just says dhcp. Nothing about full-duplex.

Which one is wrong now? Manpage or ifconfig?


Neither. You're not understanding the man page correctly and took that
piece of the page out of context. The manual duplex setting goes along
with the two manual speed selections listed above that in the man page.

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



Re: aue(4) states half-duplex by default ?

2011-09-27 Thread Christopher Zimmermann
On 09/27/11 20:05, Brad wrote:
 On 27/09/11 1:59 PM, Christopher Zimmermann wrote:
 Hi,

 I just started using a aue(4) device. Now I am a bit confused about
 full-duplex / half-duplex operation.


 The manpage states:

 full-duplex
  Force full duplex operation.  The interface will operate in
  half duplex mode if this media option is not specified.

 But for me ifconfig aue0 says:

 aue0: flags=8843UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST  mtu 1500
  lladdr 00:05:1b:e5:9a:02
  priority: 0
  groups: egress
  media: Ethernet autoselect (100baseTX full-duplex)
  status: active
  inet6 fe80::205:1bff:fee5:9a02%aue0 prefixlen 64 scopeid 0x6
  inet 192.168.1.37 netmask 0xff00 broadcast 192.168.1.255


 My hostname.aue0 just says dhcp. Nothing about full-duplex.

 Which one is wrong now? Manpage or ifconfig?
 
 Neither. You're not understanding the man page correctly and took that
 piece of the page out of context. The manual duplex setting goes along
 with the two manual speed selections listed above that in the man page.
 

Thats just ridiculous. the 'media options' section is a section of its
own as well as the 'media types' section. The 'media types' section has
three items. 'autoselect' '10baseT' and '100baseTX'. It would be stupid
to assume that the explanation in the following section 'media options'
only apply to the last two(!) items in the previous section.

I think the manpage is very clear and leaves little room for
interpretation.


What about changing the 'full-duplex' section to:

full-duplex
 Force full duplex operation.

And the 'autoselect' section to:

autoselect
Enable autoselection of the media type and options.  Full
duplex mode will be selected if possible.  The user can
manually override the autoselected mode by adding media
options to the appropriate hostname.if(5) file.



Re: remote dump to file

2011-09-27 Thread Alexander Hall
On 08/25/11 14:33, Manuel Giraud wrote:
 Hi,
 
 This patch makes the following command working:
 
 $ RSH=ssh dump -0au -f remote:dump.0 /
 
 even if dump.0 doesn't already exists on remote. Note: i cannot test
 this patch on st(4) device.
 
 Index: tape.c
 ===
 RCS file: /cvs/src/sbin/dump/tape.c,v
 retrieving revision 1.31
 diff -u -p -r1.31 tape.c
 --- tape.c  27 Oct 2009 23:59:32 -  1.31
 +++ tape.c  25 Aug 2011 12:31:36 -
 @@ -649,7 +649,7 @@ restore_check_point:
  msg(Dumping volume %d on %s\n, tapeno, tape);
  }
   #ifdef RDUMP
 -   while ((tapefd = (host ? rmtopen(tape, 2) :
 +   while ((tapefd = (host ? rmtopen(tape, O_WRONLY|O_CREAT) :
  pipeout ? 1 : open(tape, O_WRONLY|O_CREAT, 0666)))  
 0)
   #else
  while ((tapefd = (pipeout ? 1 :
 

I like it. I see no reason for using different flags for local vs
remote files, and using magic numbers instead of the defined constants
is just plain wrong.

Updated diff w/ the same reasoning applied on restore(8).

Any OK's or objections?

/Alexander


Index: dump/tape.c
===
RCS file: /cvs/src/sbin/dump/tape.c,v
retrieving revision 1.31
diff -u -p -r1.31 tape.c
--- dump/tape.c 27 Oct 2009 23:59:32 -  1.31
+++ dump/tape.c 27 Sep 2011 20:05:05 -
@@ -649,7 +649,7 @@ restore_check_point:
msg(Dumping volume %d on %s\n, tapeno, tape);
}
 #ifdef RDUMP
-   while ((tapefd = (host ? rmtopen(tape, 2) :
+   while ((tapefd = (host ? rmtopen(tape, O_WRONLY|O_CREAT) :
pipeout ? 1 : open(tape, O_WRONLY|O_CREAT, 0666)))  0)
 #else
while ((tapefd = (pipeout ? 1 :
Index: restore/tape.c
===
RCS file: /cvs/src/sbin/restore/tape.c,v
retrieving revision 1.39
diff -u -p -r1.39 tape.c
--- restore/tape.c  27 Jun 2011 23:40:57 -  1.39
+++ restore/tape.c  27 Sep 2011 20:05:05 -
@@ -195,7 +195,7 @@ setup(void)
Vprintf(stdout, Verify tape and initialize maps\n);
 #ifdef RRESTORE
if (host)
-   mt = rmtopen(magtape, 0);
+   mt = rmtopen(magtape, O_RDONLY);
else
 #endif
if (pipein)
@@ -358,7 +358,7 @@ again:
 
 #ifdef RRESTORE
if (host)
-   mt = rmtopen(magtape, 0);
+   mt = rmtopen(magtape, O_RDONLY);
else
 #endif
mt = open(magtape, O_RDONLY);



fix a seg and minor improvements to config(8)

2011-09-27 Thread Edd Barrett
Evening,

When using `config -e`:
 * Don't print a NULL pointer if binary loaded is not a kernel.
 * Don't segfault of binary loaded is not a kernel.
 * Report non-existent kernel via a preliminary stat().
 * Make a warning look like the rest.

 OK?

Index: exec.c
===
RCS file: /cvs/src/usr.sbin/config/exec.c,v
retrieving revision 1.7
diff -u -r1.7 exec.c
--- exec.c  27 Oct 2009 23:59:51 -  1.7
+++ exec.c  28 Sep 2011 01:19:49 -
@@ -26,6 +26,8 @@
 
 #include err.h
 #include sys/types.h
+#include sys/stat.h
+#include fcntl.h
 #include stdio.h
 
 #ifdef AOUT_SUPPORT
@@ -109,6 +111,11 @@
 void
 loadkernel(char *file)
 {
+   struct stat st;
+
+   if (stat(file, st) == -1)
+   err(1, cannot stat '%s', file);
+
current_exec = -1;
 
 #ifdef AOUT_SUPPORT
Index: ukc.c
===
RCS file: /cvs/src/usr.sbin/config/ukc.c,v
retrieving revision 1.16
diff -u -r1.16 ukc.c
--- ukc.c   10 Dec 2009 22:07:19 -  1.16
+++ ukc.c   28 Sep 2011 01:19:49 -
@@ -114,10 +114,8 @@
}
}
 
-   printf(%s, adjust((caddr_t)nl[P_VERSION].n_value));
-
if (force == 0  outfile == NULL)
-   printf(warning: no output file specified\n);
+   printf(WARNING no output file specified\n);
 
if (nl[IA_EXTRALOC].n_type == 0 || nl[I_NEXTRALOC].n_type == 0 ||
nl[I_UEXTRALOC].n_type == 0 || nl[I_HISTLEN].n_type == 0 ||
@@ -155,6 +153,8 @@
process_history(histlen, history);
}
 
+   printf(%s, adjust((caddr_t)nl[P_VERSION].n_value));
+
if (config()) {
if (force == 0  outfile == NULL) {
fprintf(stderr, not forced\n);
@@ -184,7 +184,9 @@
struct winsize w;
 #endif
 
-   cd = get_cfdata(0); /* get first item */
+   if ((cd = get_cfdata(0)) == NULL)   /* get first item */
+   errx(1, failed to get first cfdata);
+
while (cd-cf_attach != 0) {
maxdev = i;
totdev = i;

-- 
Best Regards
Edd Barrett



Re: file(1): prevent printing unknown magic filename

2011-09-27 Thread Christiano F. Haesbaert
On Thu, Sep 22, 2011 at 03:56:11PM +0100, Edd Barrett wrote:
 Hi,
 
 An upstream of one of the ports I work on (radare2) has imported our file(1)
 implementation and claims to have found bugs. This is the first:
 
 'ms-file' will only be assigned to 'fn' after a call to apprentice_load() and
 ultimately load_1(), so the file_magwarn() at line 274 would report the 
 default
 filename unknown.
 
 We can trigger this behaviour by executing `file -c`:
 unknown, 0: Warning: using regular magic file `/etc/magic'
 
 Is it a bug?
 
 Index: apprentice.c
 ===
 RCS file: /cvs/src/usr.bin/file/apprentice.c,v
 retrieving revision 1.29
 diff -u -r1.29 apprentice.c
 --- apprentice.c  11 Nov 2009 16:21:51 -  1.29
 +++ apprentice.c  22 Sep 2011 14:27:17 -
 @@ -258,6 +258,7 @@
   return -1;
   }
  
 + ms-file = fn;
   if (action == FILE_COMPILE) {
   rv = apprentice_load(ms, magic, nmagic, fn, action);
   if (rv != 0)

Seems correct to me, but this fn seems kinda redundant down the
stack, except for load_1() which really needs a file and not a
directory. 

So I thought we could kill this fn by assigning ms-file right in the
beginning at file_apprentice(). Also tweak load_1() so it won't do the
whole processing in an else. 

Index: apprentice.c
===
RCS file: /cvs/src/usr.bin/file/apprentice.c,v
retrieving revision 1.29
diff -d -u -p -w -r1.29 apprentice.c
--- apprentice.c11 Nov 2009 16:21:51 -  1.29
+++ apprentice.c28 Sep 2011 03:18:29 -
@@ -96,11 +96,11 @@ private int parse(struct magic_set *, st
 private int parse_mime(struct magic_set *, struct magic_entry **, uint32_t *,
 const char *);
 private void eatsize(const char **);
-private int apprentice_1(struct magic_set *, const char *, int, struct mlist 
*);
+private int apprentice_1(struct magic_set *, int, struct mlist *);
 private size_t apprentice_magic_strength(const struct magic *);
 private int apprentice_sort(const void *, const void *);
 private int apprentice_load(struct magic_set *, struct magic **, uint32_t *,
-const char *, int);
+int);
 private void byteswap(struct magic *, uint32_t);
 private void bs1(struct magic *);
 private uint16_t swap2(uint16_t);
@@ -242,7 +242,7 @@ init_file_tables(void)
  * Handle one file or directory.
  */
 private int
-apprentice_1(struct magic_set *ms, const char *fn, int action,
+apprentice_1(struct magic_set *ms, int action,
 struct mlist *mlist)
 {
struct magic *magic = NULL;
@@ -259,19 +259,19 @@ apprentice_1(struct magic_set *ms, const
}
 
if (action == FILE_COMPILE) {
-   rv = apprentice_load(ms, magic, nmagic, fn, action);
+   rv = apprentice_load(ms, magic, nmagic, action);
if (rv != 0)
return -1;
-   rv = apprentice_compile(ms, magic, nmagic, fn);
+   rv = apprentice_compile(ms, magic, nmagic, ms-file);
free(magic);
return rv;
}
 
 #ifndef COMPILE_ONLY
-   if ((rv = apprentice_map(ms, magic, nmagic, fn)) == -1) {
+   if ((rv = apprentice_map(ms, magic, nmagic, ms-file)) == -1) {
if (ms-flags  MAGIC_CHECK)
-   file_magwarn(ms, using regular magic file `%s', fn);
-   rv = apprentice_load(ms, magic, nmagic, fn, action);
+   file_magwarn(ms, using regular magic file `%s', 
ms-file);
+   rv = apprentice_load(ms, magic, nmagic, action);
if (rv != 0)
return -1;
}
@@ -359,7 +359,8 @@ file_apprentice(struct magic_set *ms, co
*p++ = '\0';
if (*fn == '\0')
break;
-   file_err = apprentice_1(ms, fn, action, mlist);
+   ms-file = fn;
+   file_err = apprentice_1(ms, action, mlist);
errs = MAX(errs, file_err);
fn = p;
}
@@ -571,13 +572,15 @@ load_1(struct magic_set *ms, int action,
 {
char line[BUFSIZ];
size_t lineno = 0;
-   FILE *f = fopen(ms-file = fn, r);
-   if (f == NULL) {
+   FILE *f;
+   
+   if ((f = fopen(fn, r)) == NULL) {
if (errno != ENOENT)
file_error(ms, errno, cannot read magic file `%s',
   fn);
(*errs)++;
-   } else {
+   return;
+   } 
/* read and parse this file */
for (ms-line = 1; fgets(line, sizeof(line), f) != NULL; 
ms-line++) {
size_t len;
@@ -606,7 +609,6 @@ load_1(struct magic_set *ms, int action,
 
(void)fclose(f);
}
-}
 
 /*
  * parse a file or directory of files
@@ -614,7 +616,7 @@ load_1(struct magic_set *ms, int action,
  */