1

(2 replies, posted in OpenBSD)

Sorry, it took so long to get back to you.

dmesg:

Loading...                                           
probing: pc0 com0 com1 pci mem[639K 63M a20=on] 
disk: hd0+
>> OpenBSD/i386 BOOT 3.02
>> OpenBSD/i386 BOOT 3.02
boot> 
booting hd0a:/bsd: 6238560+1041588 [52+319712+302630]=0x7896c4
entry point at 0x200120

[ using 622768 bytes of bsd ELF symbol table ]
Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2008 OpenBSD. All rights reserved.  http://www.OpenBSD.org   
                                                                                
OpenBSD 4.4 (GENERIC) #1021: Tue Aug 12 17:16:55 MDT 2008                       
    deraadt@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC             
cpu0: AMD Am486DX4 W/B or Am5x86 W/B 150 ("AuthenticAMD" 486-class)             
cpu0: FPU                                                                       
real mem  = 66678784 (63MB)                                                     
avail mem = 55017472 (52MB)                                                     
mainbus0 at root                                                                
bios0 at mainbus0: AT/286+ BIOS, date 20/50/27, BIOS32 rev. 0 @ 0xf7840         
pcibios0 at bios0: rev 2.0 @ 0xf0000/0x10000                                    
pcibios0: pcibios_get_intr_routing - function not supported                     
pcibios0: PCI IRQ Routing information unavailable.                              
pcibios0: PCI bus #0 is the last bus                                            
bios0: ROM list: 0xc8000/0x9000                                                 
cpu0 at mainbus0                                                                
pci0 at mainbus0 bus 0: configuration mode 1 (bios)                             
elansc0 at pci0 dev 0 function 0 "AMD ElanSC520 PCI" rev 0x00: product 0 steppi0
gpio0 at elansc0: 32 pins                                                       
ral0 at pci0 dev 16 function 0 "Ralink RT2561S" rev 0x00: irq 10, address 00:1d9
ral0: MAC/BBP RT2561C, RF RT2527                                                
sis0 at pci0 dev 18 function 0 "NS DP83815 10/100" rev 0x00, DP83816A: irq 11, c
nsphyter0 at sis0 phy 0: DP83815 10/100 PHY, rev. 1                             
sis1 at pci0 dev 19 function 0 "NS DP83815 10/100" rev 0x00, DP83816A: irq 5, ad
nsphyter1 at sis1 phy 0: DP83815 10/100 PHY, rev. 1                             
sis2 at pci0 dev 20 function 0 "NS DP83815 10/100" rev 0x00, DP83816A: irq 9, ae
nsphyter2 at sis2 phy 0: DP83815 10/100 PHY, rev. 1                             
isa0 at mainbus0                                                                
isadma0 at isa0                                                                 
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo                         
com0: console                                                                   
com1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo                         
pckbc0 at isa0 port 0x60/5                                                      
pckbd0 at pckbc0 (kbd slot)                                                     
pckbc0: using irq 1 for kbd slot                                                
wskbd0 at pckbd0: console keyboard                                              
wdc0 at isa0 port 0x1f0/8 irq 14                                                
wd0 at wdc0 channel 0 drive 0: <SanDisk SDCFH2-004G>                            
wd0: 4-sector PIO, LBA, 3919MB, 8027712 sectors                                 
wd0(wdc0:0:0): using BIOS timings                                               
pcppi0 at isa0 port 0x61                                                        
midi0 at pcppi0: <PC speaker>                                                   
spkr0 at pcppi0                                                                 
npx0 at isa0 port 0xf0/16: reported by CPUID; using exception 16                
biomask f1c5 netmask ffe5 ttymask ffff                                          
softraid0 at root                                                               
root on wd0a swap on wd0b dump on wd0b                                          
Automatic boot in progress: starting file system checks.                        
/dev/rwd0a: file system is clean; not checking                                  
setting tty flags                                                               
starting network                                                                
ral0: no link ............. sleeping                                            
sis0: no link ............. sleeping                                            
starting system logger                                                          
starting initial daemons:.                                                      
savecore: no core dump                                                          
checking quotas: done.                                                          
building ps databases: kvm dev.                                                 
clearing /tmp                                                                   
starting pre-securelevel daemons:.                                              
setting kernel security level: kern.securelevel: 0 -> 1                         
creating runtime link editor directory cache.                                   
preserving editor files.                                                        
starting network daemons: sendmail inetd sshd.                                  
starting local daemons:.                                                        
standard daemons: cron.                                                         
Sat Aug 16 14:12:40 PDT 2008                                                    
                                                                                
OpenBSD/i386 (soekris.hsd1.or.comcast.net.) (tty00)                             
                                                                                
login:

2

(2 replies, posted in OpenBSD)

So I finally got a well supported wireless card and I have a rather stupid question regarding configuration:  My router provides an 802.11b/g wireless AP using WPA2 TKIP-AES authentication.  My openbsd box is running obsd-4.4 (i386) and is using ral0.

/etc/hostname.ral0:
dhcp NONE NONE NONE nwid blahrg wpa wpapsk $(wpa-psk blahrg secret_password)

and ifconfig ral0:
ral0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        lladdr 00:1d:7d:46:84:e9
        groups: wlan
        media: IEEE802.11 autoselect (DS1)
        status: no network
        ieee80211: nwid blahrg wpapsk secret_password
f59e76bb61 wpaprotos wpa1,wpa2 wpaakms psk,802.1x wpaciphers tkip wpagroupcipher tkip 100dBm
        inet6 fe80::21d:7dff:fe46:84e9%ral0 prefixlen 64 scopeid 0x1


All the examples in manfile and on the internet seem really simple, but I cannot get my machine to join the network.  Am I missing something really simple?

3

(4 replies, posted in Off-Topic)

Yeah, you're correct. Sorry.  I'm used to doing propositional logic with trees.

4

(4 replies, posted in Off-Topic)

For: "?(p ? q) ? (p ? ?q) ? (q ? ?p)"  haven't you only shown that "~(p ? q) ?  (p ? ?q) ? (q ? ?p)" and not the additional "(p ? ?q) ? (q ? ?p) ? ~(p ? q)" for the biconditional?

5

(3 replies, posted in Programming)

Thanks!  I ended up with this version which in theory is word-size independent.

int any_bit_off(unsigned x) {
    return ~x && 1;
}

6

(3 replies, posted in Programming)

I'm trying to learn to love C and all it's low level goodness.  That means coming to know and love, wait for it...  the bitwise operators.  For the life of me I cannot get this function (returns 1 if any bit in a word is set to 0 ) to work the way I would like it too.

int any_bit_off(unsigned x) {

         unsigned char *t, *e;
         for(t = &x, e = (&x + sizeof(x)); t != e; ++t) {
                 if( (*t & 0) )
                         return 1;
         }

         return 0;
}

What I think this ought to be doing is using byte pointers (unsigned chars, correct?) to walk through the word and comparing each bit of each byte using the & bitwise operator.  If a "off bit" is found it should return one, otherwise the default return value is zero (no off bits where found).  It unfortunately returns zero when I pass it 'unsigned z = 0xFFFFFFFF' which should have no 'off' bits in it.  I think my mask is in the if condition is wrong but I'm not sure how or why.  K&R are unusually terse on this point.  Perhaps someone here can explain.

Thank you.

I dunno, I think Greg Kroah-Hartman has a valid point.  A company the size of Canonical should have pushed more than a hundred patches upstream since it's inception, especially considering the size of their user base.  Granted they have made lots of contributions to the more desktop-y projects like GNOME and hal.

From the Ubuntu "code of conduct":

We chose the name Ubuntu for our distribution because we think it captures perfectly the spirit of the sharing and cooperation that is at the heart of the open source movement. In the Free Software world, we collaborate freely on a volunteer basis to build software for everyone's benefit. We improve on the work of others, which we have been given freely, and then share our improvements on the same basis.

Of course no one can force Canonical to contribute or participate in the community ecosystem.  They are free to contribute nothing if they so wish but they have the resources in terms of developer time and a beta-test user base to contribute a lot to the kernel and it's associated "plumbing" not just desktop-y projects.  Kernel contributions go even further in terms of sharing than contributions to GNOME because more people use the kernel.  It's just unfortunate that Canonical doesn't send as much stuff upstream as they could and it's even more unfortunate that in doing so they seem to be in direct conflict with their own manifesto.

The devs could indeed just go through the kernel source but the point is they shouldn't have to.  It's inefficient and it should be unnecessary.

It's pretty hard to argue with the success of Canonical (Ubuntu).  They managed to win over a huge user base in a relatively short amount of time.  They have contributed (in my opinion) greatly to the conversion of end-users interested in an alternative desktop operating system.  It seems however that Canonical doesn't play nice with the upstream developers.  They have a substantial user base but seem to push a disproportional amount of patches upstream.

Here
Rebuttal

I can also confirm that.  Although the hard locks seem to unreproducible.  Sometimes I get it when using WEP, sometimes when trying to force the card into 802.11g mode and occasionally just on an 'up'.  In all cases it's inconsistent.  I tried a snapshot about two weeks ago which generated a kernel panic on an 'up'.  Hopefully support gets better with 4.4 release.

I sent emails to both user-misc and directly to the driver developer about a week and a half ago with no replies.  Since this thread is about the fifth hit for a google search for 'Atheros AR5213 openbsd' I figured I'd better finish it off. The AR5213, as far as I can tell, is NOT supported under the Ath(4) driver as of OpenBSD 4.3.  I can get it to work under 802.11b but that seems to be a fluke of luck and even then it's buggy (I've had a few hard locks).  If you have a choice in the matter I can not recommend the AR5213 chip and would advise people to avoid all the Atheros chipsets  because only a few are actually supported by the ath driver.

This might change in the near future (indeed I hope it does) so if you are stuck with an atheros chipset try current before moving on to a different device.  The difficult part is that the chipsets are different on the same model number for wireless cards.  For example: The Wistron CM9 IS supported with the AR5212 (at least according to ath man file) but the CM9 is NOT supported with the AR5213 chipset.  Even while using decent resellers like netgate I'd recommend you cross-reference the chipset to the model number of the card to make sure you are getting a supported chipset (of which there are currently relatively few).

EDIT:  I understand the AR5213 chipset is supported under Linux and FreeBSD through the madwifi drivers but I haven't tested it so I can't confirm.

I sent a message out to misc this morning.  Apparently a significant amount of work is being done on the ath driver so maybe we'll see support with 4.4.  Stay tuned.  Hopefully I'll be back with good news.

With this as my /etc/hostname.ath0:

inet 10.0.0.1 255.255.255.0 NONE media OFDM54 mediaopt hostap \
nwid stupid_wireless nwkey secret_key123 chan 6

I get these media options from ifconfig.

ath0: flags=8963<UP,BROADCAST,NOTRAILERS,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        lladdr 00:0b:6b:37:a4:20
        groups: wlan
        media: IEEE802.11 OFDM54 hostap (autoselect mode 11a hostap)
        status: active
        ieee80211: nwid stupid_wireless chan 6 bssid 00:0b:6b:37:a4:20 nwkey secret_key123
        inet6 fe80::20b:6bff:fe37:a420%ath0 prefixlen 64 scopeid 0x1
        inet 10.0.0.1 netmask 0xffffff00 broadcast 10.0.0.255

The card defaults to mode 11a.  Immediately after this if I manually issue a 'ifconfig ath0 mode 11g'  none of the media options as reported by ifconfig change and no errors are returned to the terminal or to /var/log/messages.

asemisldkfj: Adding the 'mode 11g' specifications to my hostname.ath0 gets these settings.  Both

inet 10.0.0.1 255.255.255.0 NONE media OFDM54 mediaopt mode 11g hostap  \
nwid stupid_wireless nwkey secret_key123 chan 6

and

inet 10.0.0.1 255.255.255.0 NONE media OFDM54 mediaopt hostap mode 11g  \
nwid stupid_wireless nwkey secret_key123 chan 6
 
give the same error and produce the same settings.

# sh /etc/netstart ath0
ifconfig: SIOCSIFMEDIA: Invalid argument
# ifconfig ath0
ath0: flags=8922<BROADCAST,NOTRAILERS,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        lladdr 00:0b:6b:37:a4:20
        groups: wlan
        media: IEEE802.11 autoselect (DS1)
        status: no network
        ieee80211: nwid stupid_wireless chan 6 nwkey secret_key123

andreig: I'm using OpenBSD 4.3 on a Soekris 4501.  Here's the relevant lines from dmesg:

ath0 at pci0 dev 16 function 0 "Atheros AR5212" rev 0x01: irq 10
ath0: AR5213 5.9 phy 4.3 rf5112a 3.6, FCC2A*, address 00:0b:6b:37:a4:20

It looks like we have identical cards.

Using OFDM54 in my hostname.ath0 I get the following.

#cat /etc/hostname.ath0
inet 10.0.0.1 255.255.255.0 NONE media OFDM54 mediaopt hostap \
nwid stupid_wireless nwkey secret_key123 chan 6
# ifconfig ath0
ath0: flags=8963<UP,BROADCAST,NOTRAILERS,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        lladdr 00:0b:6b:37:a4:20
        groups: wlan
        media: IEEE802.11 OFDM54 hostap (autoselect mode 11a hostap)
        status: active
        ieee80211: nwid stupid_wireless chan 6 bssid 00:0b:6b:37:a4:20 nwkey secret_key123
        inet6 fe80::20b:6bff:fe37:a420%ath0 prefixlen 64 scopeid 0x1
        inet 10.0.0.1 netmask 0xffffff00 broadcast 10.0.0.255

...which is good news... I'm getting the card to use 802.11a/g and WEP.  The bad news is it defaults to 11a mode which is useless to my network of 802.11g clients.  As expected forcing the card to run in 802.11g doesn't work if I manually issue a 'ifconfig ath0 mode 11g'.  I get no error back to the console or /var/log/messages and another 'ifconfig ath0' repeats the above settings(meaning as far as I can tell nothing has changed).  On closer examination of the output of 'ifconfig -m ath0' I cannot find any listing specifying the much needed: media OFDM54 mediaopt hostap mode 11g.  All I can find is mode 11a entries.   There appears to be no mention of 11g at all in the output of available media information.  This leads me to believe that 802.11g support does not exist for the AR5213 chipset with the ath driver.  The card is a Winstron CM9 which is listed as supported in 802.11a/b/g modes in the manfile BUT that's with the AR5212 chipset.  dmesg reports I'm using the AR5213 chipset (I haven't physically confirmed this yet).  It appears that I've been duped by wireless card revision numbers yet again and this time with a rather expensive card.  At this point, to my inexperienced eyes, it looks like 802.11b is going to be the best I can get out of this card unless someone sees some obvious newbie error I'm making.

Thanks, for your help asemisldkfj, it is graciously appreciated.

asemisldkfj:  Here's the output of ifconfig -m ath0.

ifconfig -m ath0
ath0: flags=8963<UP,BROADCAST,NOTRAILERS,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        lladdr 00:0b:6b:37:a4:20
        groups: wlan
        media: IEEE802.11 autoselect mode 11b hostap
        status: active
        ieee80211: nwid soekris chan 6 bssid 00:0b:6b:37:a4:20 nwkey speakmyfriend
        supported media:
                media autoselect
                media autoselect mediaopt ibss
                media autoselect mediaopt hostap
                media autoselect mediaopt monitor
                media autoselect mode 11a
                media autoselect mode 11a mediaopt ibss
                media autoselect mode 11a mediaopt hostap
                media autoselect mode 11a mediaopt monitor
                media OFDM6 mode 11a
                media OFDM6 mode 11a mediaopt ibss
                media OFDM6 mode 11a mediaopt hostap
                media OFDM6 mode 11a mediaopt monitor
                media OFDM9 mode 11a
                media OFDM9 mode 11a mediaopt ibss
                media OFDM9 mode 11a mediaopt hostap
                media OFDM9 mode 11a mediaopt monitor
                media OFDM12 mode 11a
                media OFDM12 mode 11a mediaopt ibss
                media OFDM12 mode 11a mediaopt hostap
                media OFDM12 mode 11a mediaopt monitor
                media OFDM18 mode 11a
                media OFDM18 mode 11a mediaopt ibss
                media OFDM18 mode 11a mediaopt hostap
                media OFDM18 mode 11a mediaopt monitor
                media OFDM24 mode 11a
                media OFDM24 mode 11a mediaopt ibss
                media OFDM24 mode 11a mediaopt hostap
                media OFDM24 mode 11a mediaopt monitor
                media OFDM36 mode 11a
                media OFDM36 mode 11a mediaopt ibss
                media OFDM36 mode 11a mediaopt hostap
                media OFDM36 mode 11a mediaopt monitor
                media OFDM48 mode 11a
                media OFDM48 mode 11a mediaopt ibss
                media OFDM48 mode 11a mediaopt hostap
                media OFDM48 mode 11a mediaopt monitor
                media OFDM54 mode 11a
                media OFDM54 mode 11a mediaopt ibss
                media OFDM54 mode 11a mediaopt hostap
                media OFDM54 mode 11a mediaopt monitor
                media autoselect mode 11b
                media autoselect mode 11b mediaopt ibss
                media autoselect mode 11b mediaopt hostap
                media autoselect mode 11b mediaopt monitor
                media DS1 mode 11b
                media DS1 mode 11b mediaopt ibss
                media DS1 mode 11b mediaopt hostap
                media DS1 mode 11b mediaopt monitor
                media DS2 mode 11b
                media DS2 mode 11b mediaopt ibss
                media DS2 mode 11b mediaopt hostap
                media DS2 mode 11b mediaopt monitor
                media DS5 mode 11b
                media DS5 mode 11b mediaopt ibss
                media DS5 mode 11b mediaopt hostap
                media DS5 mode 11b mediaopt monitor
                media DS11 mode 11b
                media DS11 mode 11b mediaopt ibss
                media DS11 mode 11b mediaopt hostap
                media DS11 mode 11b mediaopt monitor
                media OFDM6
                media OFDM6 mediaopt ibss
                media OFDM6 mediaopt hostap
                media OFDM6 mediaopt monitor
                media OFDM9
                media OFDM9 mediaopt ibss
                media OFDM9 mediaopt hostap
                media OFDM9 mediaopt monitor
                media OFDM12
                media OFDM12 mediaopt ibss
                media OFDM12 mediaopt hostap
                media OFDM12 mediaopt monitor
                media OFDM18
                media OFDM18 mediaopt ibss
                media OFDM18 mediaopt hostap
                media OFDM18 mediaopt monitor
                media OFDM24
                media OFDM24 mediaopt ibss
                media OFDM24 mediaopt hostap
                media OFDM24 mediaopt monitor
                media OFDM36
                media OFDM36 mediaopt ibss
                media OFDM36 mediaopt hostap
                media OFDM36 mediaopt monitor
                media OFDM48
                media OFDM48 mediaopt ibss
                media OFDM48 mediaopt hostap
                media OFDM48 mediaopt monitor
                media OFDM54
                media OFDM54 mediaopt ibss
                media OFDM54 mediaopt hostap
                media OFDM54 mediaopt monitor
                media DS1
                media DS1 mediaopt ibss
                media DS1 mediaopt hostap
                media DS1 mediaopt monitor
                media DS2
                media DS2 mediaopt ibss
                media DS2 mediaopt hostap
                media DS2 mediaopt monitor
                media DS5
                media DS5 mediaopt ibss
                media DS5 mediaopt hostap
                media DS5 mediaopt monitor
                media DS11
                media DS11 mediaopt ibss
                media DS11 mediaopt hostap
                media DS11 mediaopt monitor
        inet6 fe80::20b:6bff:fe37:a420%ath0 prefixlen 64 scopeid 0x1
        inet 10.0.0.1 netmask 0xffffff00 broadcast 10.0.0.255

Thanks!

Just a quick update:

I was able to get WEP support correctly enabled.  The ASCII key I was using was not 13 characters (104 bytes, correct?) long.  Also noteworthy, by default the AR5213 chipset when set to autoselect will use 802.11a mode which makes it's impossible to be detected by 802.11b/g clients.  At this point it is happily bridging 802.11b clients to my network with WEP.

That being said: I still can not force the driver to use 802.11g mode using 'ifconfig ath0 mode 11g' with the settings shown in the previous post.  As far as I can tell, this is not a configuration or syntax problem and is isolated to this driver (although I have no way of testing it otherwise).  I am hoping someone can confirm this before I contact the developer and/or post to the mailing lists.

# cat /etc/hostname.ath0                                                       
inet 10.0.0.1 255.255.255.0 NONE media autoselect mediaopt hostap mode 11b \ 
nwid soekris nwkey speakmyfriend chan 6
# sh /etc/netstart ath0  
# ifconfig ath0
ath0: flags=8963<UP,BROADCAST,NOTRAILERS,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        lladdr 00:0b:6b:37:a4:20
        groups: wlan
        media: IEEE802.11 autoselect mode 11b hostap
        status: active
        ieee80211: nwid soekris chan 6 bssid 00:0b:6b:37:a4:20 nwkey *************
        inet6 fe80::20b:6bff:fe37:a420%ath0 prefixlen 64 scopeid 0x1
        inet 10.0.0.1 netmask 0xffffff00 broadcast 10.0.0.255

     ***these are the default settings which have been tested and are working with two separate clients,
         modifying the 11b to 11g in hostname.ath0 leads to the following error,  and as noted earlier specifying 
         11g manually with ifconfig doesn't work etiher.

# cat /etc/hostname.ath0
inet 10.0.0.1 255.255.255.0 NONE media autoselect mediaopt hostap mode 11g \ 
nwid soekris nwkey speakmyfriend chan 6
# sh /etc/netstart ath0
ifconfig: SIOCSIFMEDIA: Invalid argument

Anyone's advice on either a configuration error I've made or on the best channels to send this question upstream would be gratefully received.  Thanks.

I'm in the process of building a OpenBSD 4.3 based wireless access point for my home network.  I am using an Atheros AR5213 card which is supported by the ath driver.  I am having some issues configuring it properly.  I cannot get it to run in 11g mode or enable WEP.  Ideally I'd like to do both.  Currently I have it configured in 11b mode with no encryption and clients can connect just fine.

ath0: flags=8963<UP,BROADCAST,NOTRAILERS,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        lladdr 00:0b:6b:37:a4:20
        groups: wlan
        media: IEEE802.11 autoselect mode 11b hostap
        status: active
        ieee80211: nwid soekris chan 6 bssid 00:0b:6b:37:a4:20
        inet 10.0.0.1 netmask 0xffffff00 broadcast 10.0.0.255
        inet6 fe80::20b:6bff:fe37:a420%ath0 prefixlen 64 scopeid 0x1

So the card is at least working as a unsecured 802.11b access point.  If I try to force it into 802.11g with a 'ifconfig ath0 mode 11g' nothing changes.  ifconfig returns the exact same results.  I can turn on WEP with ' ifconfig ath0 nwkey secret_key' and ifconfig does indeed show that nwkey secret_key is there but my client (an Ubuntu 8.04 machine) cannot authenticate when providing the key as a WEP passphrase in both open system and shared key modes.  I will try to test WEP support with another client to see it's solely a client related problem.  Does anyone happen to know why I can't force 11g mode or why WEP support is failing?

Thanks in advance.

18

(7 replies, posted in Programming)

Hmm, your snippet does indeed lead to a seg fault.  I was under the impression that dereferencing a null pointer is a no-op and that consequentially it was about the only 'safe' thing you could do with pointers without risking a segfault.  For example, in C++ as long as all my class constructors would at the very least set the pointers to null the destructor could just deallocate them.  If there was memory there it'd be deallocated and if not and the pointer was null it'd be a no-op.  Either this is different in C or as you pointed out it could be entirely implementation dependent (the compiler removes the lines I assume).

The only reason to use a preprocessor macro for memset is for syntactic clarity and to remind myself that if I am defining a pointer I should declare it null.  However if a null pointer deference does indeed segfault there's no reason to do this.

Thanks for your help on this one.  You obviously know your business with code.

19

(7 replies, posted in Programming)

If the pointer is initialized to null first a dereference is a no-op correct?  The following is safe then:

int * ptr;
memset(&ptr, 0, sizeof(ptr));
*ptr;

The idea is to create a macro for setting any pointer to null to prevent dereferencing an uninitialized pointer.  I still don't understand why you need to pass &ptr to memset and not just ptr.  I'm coming from C++ and I'm used to passing pointers by references instead of by pointers-to-pointers.  I assume that memset needs a pointer to a void data type and that's why you have to pass it's address using the & operator.

20

(24 replies, posted in General BSD)

I'm going to just give up on this project and certainly not for lack of help or involvement from the forums.  I was able to get the ext2fs created and mounted with root permissions so I started transferring my files to it from my external hard drive.  This lead to numerous hard-locks.  Even transferring all my .* files from my temporary home directory lead to a hard lock eventually.  Either FreeBSD's support for ext2fs write is buggy, the file system itself is poorly implemented or some combination of both.  Regardless, that's a level of unreliability that I have no interest in trusting my files to so I can say with reluctance that the "shared-FreeBSD-and-Linux-home-partition" dream is dead... I just don't see how it's possible (even with my technical ability aside) to accomplish this with any sense of file stability.  I think ext2 read/write support might work in a pinch but I would highly caution anyone from relying on it.

At this point I have enough time and effort into this install that I'm not quite ready to give up the ghost and go back to the dreaded Ubuntu.  My current slice/partition scheme looks like this:

/dev/ad4s1   - FreeBSD  -  25GB
/dev/ad4s2   - Linux - 60GB

I'd like to 1) merge the two slices together since ad4s1 is already partitioned out and full and then 2) create a home partition out of the new space.  As far as I can tell merging partitions (/dev/ad4s1a...) is possible but I couldn't find anything about slices on google.

Anyways, another thank you for everyone's help.  I have no sensitive data on this machine so at worst I'll just do a reinstall.

21

(7 replies, posted in Programming)

OK, well that worked but my question is why? When you declare a pointer it's value is generally some random memory which you often don't have access to (hence the seg fault) but when you call memset with &ptr you're passing the address of the actual pointer variable not the value of the pointer(which is also a memory address).  If you wanted to change the value of ptr wouldn't you call memset with a dereference like so: memset((*ptr), sizeof(ptr))?

22

(7 replies, posted in Programming)

I'm bored waiting for my ports to upgrade so I'm experimenting with memset but I can't get it to set my pointers to null.  The code is below:

#include <stdio.h>
#include <string.h>

#define memzero(s, n) memset((s), 0, (n))

main()
{
    int * ptr;
    memzero(ptr, sizeof(ptr));

    printf("%p\t%p\n", ptr);
}

Running this program causes a segfault... however it should set the pointer to null and thus dereferencing ought to be a no-op.  Anyways, advice would be helpful.

23

(24 replies, posted in General BSD)

Permissions on /dev/ad4s2 are "crw-rw----  1 root  operator" and I can't find any relevant errors in either dmesg or /var/log/messages.

24

(495 replies, posted in General BSD)

FreeBSD 7.0-amd64 with Gnome... nothing exciting.
here

25

(24 replies, posted in General BSD)

** in /etc/devfs.conf

# Allow members of the operator group to mount and write /dev/ad4s2
own     ad4     root:operator
own     ad4s2   root:operator
perm    ad4     0660
perm    ad4s2   0660

**  after a reboot

$ sysctl vfs.usermount && ls -la /dev/ad4s2
vfs.usermount: 1
crw-rw----  1 root  operator    0,  91 Aug 20 15:16 /dev/ad4s2


** as a normal user

drwxr-xr-x   2 kevine  kevine       512 Aug 20 14:56 storage

$ mount -t ext2fs /dev/ad4s2 storage
mount: /dev/ad4s2 : Operation not supported by device

Which is strange considering that kevine is part of the operator group.  My guess is that just having rw privileges on a device isn't sufficient for that user to mount it.  As root, there's no problem mounting the device and reading/writing to it.

I apologize for my abject lack of knowledge about what devices actually are and how their permissions are handled.  I'm coming from linux-land, where this is all covered up with things like HAL.

Thanks again for everyone's help.