Re: /dev/dsp* /dev/audio* devices not present

2009-01-10 Thread Ulrich Spoerlein
I cannot really comment on the devfs(4) design issues, and quite frankly
it hasn't bothered my thus far. Just another little quirk you get to
remember.

On Sat, 10.01.2009 at 04:20:58 -0800, per...@pluto.rain.com wrote:
 That the code faithfully adheres to the design does not guarantee
 that the design is flawless.  IMO it violates POLA, if not POSIX,
 for open(2) to succeed when applied to a name which, according to
 readdir(2), does not exist; and it is suboptimal to have stealth
 drivers whose availability for use cannot be discovered by examining
 /dev.

You forgot directories with --x permissions. You can open many files
inside them, but readdir(2) will get you nowhere. So this is a poor
standard by which to judge devfs(4) device cloning.

Cheers,
Ulrich Spoerlein
-- 
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: /dev/dsp* /dev/audio* devices not present

2009-01-09 Thread Ulrich Spoerlein
On Thu, 08.01.2009 at 21:50:47 -0800, per...@pluto.rain.com wrote:
 Ulrich Spoerlein gmail.com!uspoerl...@agora.rdrop.com wrote:

Ummm, out of curiosity, are your receiving your mail via UUCP? :)

  Please run
  % cat /dev/sndstat
  % ls -l /dev/dsp0 /dev/dsp0.0
 
  The reason you are not seeing them with 'ls /dev/dsp*' is because
  devfs is creating the nodes when they are open(2)'ed. Using shell
  globbing will search the output of readdir(2) for matches to dsp*
  where devfs has no way of dynamically creating nodes (which ones
  should it create anyway?)
 
 In principle, everything that would be successfully created if
 open(2)'ed.  It doesn't necessarily need to actually create them,
 but the results from readdir(2) should be as if they had been
 created.  The whole point of things like ls(1) and readdir(2) is
 to find out what-all is available to be opened, without having to
 already know the answer.

Not according to my understanding, which may be flawed of course.
devfs(4) would have to create all devices, which may be open(2)ed up
front, for dsp that would have to be 32 instances (for my system):

% ll /dev/dsp0.{0,9,11,21,31}
crw-rw-rw-  1 root  wheel0, 142 Jan  9 20:57 /dev/dsp0.0
crw-rw-rw-  1 root  wheel0, 153 Jan  9 20:20 /dev/dsp0.11
crw-rw-rw-  1 root  wheel0, 154 Jan  9 20:20 /dev/dsp0.21
crw-rw-rw-  1 root  wheel0, 151 Jan  9 20:20 /dev/dsp0.31
crw-rw-rw-  1 root  wheel0, 152 Jan  9 20:20 /dev/dsp0.9

It would also cloud the information about devices in-use.

  This is a FAQ really.
 
 It may be an FAQ, but it is also a bug, granted one that may not be
 easy to fix.

You really want all cloneable instances to show up with a readdir, which
would mean that they would have to created upon device attachment? I
really don't think so ... For /dev/dsp0 the semantics are pretty clear:
try to open /dev/dsp0, if it succeeds fine, if not, there is no vchan
available and you're SOL. No need to play the guess-a-free-dsp-device
game.

Cheers,
Ulrich Spoerlein
-- 
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: /dev/dsp* /dev/audio* devices not present

2009-01-08 Thread Ulrich Spoerlein
On Thu, 08.01.2009 at 09:06:45 +0200, Vladimir Terziev wrote:
 Hi Matthias,
 
 i configured Ekiga and during the configuration process it didn't find
 any Audio device, so i think /dev/dsp* devices must be present, isn't
 it ?

Please run
% cat /dev/sndstat
% ls -l /dev/dsp0 /dev/dsp0.0

The reason you are not seeing them with 'ls /dev/dsp*' is because devfs
is creating the nodes when they are open(2)'ed. Using shell globbing will
search the output of readdir(2) for matches to dsp* where devfs has no
way of dynamically creating nodes (which ones should it create anyway?)

This is a FAQ really.

Cheers,
Ulrich Spoerlein
-- 
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Small change to 'ps'

2009-01-07 Thread Ulrich Spoerlein
On Tue, 06.01.2009 at 11:52:39 -0800, Sheldon Givens wrote:
 Hello everyone,
 
 It occurs to me that FreeBSD ps lacks the ability to disable header. This
 seems like a really obvious feature, and I may have simply missed it's
 existence (despite my relentlessly searching the man page) but here is a
 small patch that sets the flag 'n' to disable header output.

You've missed it, probably because it is non-obvious:

% ps -p 1 -o pid,cpu
  PID CPU
1   0
% ps -p 1 -o pid= -o cpu=
1   0
%

Cheers,
Ulrich Spoerlein
-- 
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Small change to 'ps'

2009-01-07 Thread Ulrich Spoerlein
On Wed, 07.01.2009 at 08:54:41 -0600, Sean C. Farley wrote:
 On Wed, 7 Jan 2009, Ulrich Spoerlein wrote:
 
  On Tue, 06.01.2009 at 11:52:39 -0800, Sheldon Givens wrote:
  Hello everyone,
 
  It occurs to me that FreeBSD ps lacks the ability to disable header. 
  This seems like a really obvious feature, and I may have simply 
  missed it's existence (despite my relentlessly searching the man 
  page) but here is a small patch that sets the flag 'n' to disable 
  header output.
 
  You've missed it, probably because it is non-obvious:
 
  % ps -p 1 -o pid,cpu
   PID CPU
 1   0
  % ps -p 1 -o pid= -o cpu=
 1   0
  %
 
 Another way:
 ps | tail +2

I'm not sure about the portability of tail +N, I seem to remember that
AIX doesn't support it. Therefore I'd rather use

% ps | sed 1d

which is way more portable.

Cheers,
Ulrich Spoerlein
-- 
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: looking for something like a union file system

2008-11-15 Thread Ulrich Spoerlein
On Fri, 14.11.2008 at 17:44:39 -0500, Aryeh M. Friedman wrote:
 I am using a dev tool that maintains a split source tree for currently
 worked on files and those in the repo (aegis which is slightly different
 then how svn or cvs does it) and my the default build system assumes it
 is all in one tree thus I want someway of merge the two dirs and
 have a copy on write via a special command for it (i.e. if I start to
 edit foo.c it automatically checks it out for me) any ideas?

mount_unionfs(8) or the FUSE equivalent

Cheers,
Ulrich Spoerlein
-- 
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Extending find(1) to support -printf

2008-09-13 Thread Ulrich Spoerlein
Pretty late to the game, but ...

On Mon, 08.09.2008 at 15:47:20 +0200, Oliver Fromme wrote:
 Jeremy Chadwick wrote:
  Equally as frustrating, mutt's backtick support will only honour the
  first line of input.  If a backticked command returns multiple lines,
  only the first is read; the rest are ignored.
 
 Well, you can convert back and forth between spaces
 and newlines with tr(1):
 
 echo * | tr ' ' '\n' | grep -v whatever | tr '\n' ' '

If your data is not very large, you can also fool xargs(1) into doing
the conversion for you

$ echo * | xargs -n1
and
$ ls -1 | xargs

 It's not pretty, but it should work.  Note that ls(1)
 prints one file name per line, so you can simplify the
 above line like this:
 
 ls | grep -v whatever | tr '\n' ' '
 
 By the way, I often use zsh in such cases.  It supports
 extended globbing, for example, the wildcard expression
 *~*.(gz|bz2) matches all files _except_ the ones that end
 with .gz or .bz2.

Indeed much more useful than fighting with find(1) and passing the file
lists around.

Cheers,
Ulrich Spoerlein
-- 
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: FreeBSD + LDAP + SAMBA + WINDOWS

2008-06-06 Thread Ulrich Spoerlein
On Wed, 28.05.2008 at 19:11:06 -0300, Israel Lehnen Silva wrote:
 Friends,
 
 I have the following scenario:
 
 Server FreeBSD 7.0 Stable authenticating in one basis LDAP through of the
 PAM (pam_ldap and nss_ldap)
 In same server, have running the SAMBA 3.0.28 authenticating too in
 basis LDAP and using the scripts smbldap-tools.
 Tool LDAPAdmin for administration of basis LDAP.
 
 THE PROBLEM:
 
 When chang the pass of user in basis LDAP trhough of LDAPAdmin,
 select th cryptograpy MD5 Crypt for the atribuct userPassword
 This way, I achieve log in the Windows and FreeBSD by terminal, ssh...
 but when chang pass of user by Windows, the cryptograpy of password in
 atribuct userPassword
 is chanded for SSHA and so not conect in FreeBSD, also just conect in
 windows.
 
 FreeBSD and SAMBA authenticating in LDAP,
 and changing the password by own user, not interfering in auth of ssh in
 FreeBSD...
 Someone implemented???

Hi,

I think you have this backwards. At our setup, with active samba
password sync users can change their samba{LM,NT}passwords and have
their userPassword updated accordingly. Samba will not change the used
algorithm, though (we use {CRYPT}, don't ask ...)

The other way round though will only update the userPassword and not
change the samba{Lm,NT}passwords leading to the old password still being
valid for Windows.

We're using a small CGI script where our users can change (both)
passwords in their browser.

Cheers,
Ulrich Spoerlein
-- 
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [Patch] Using sysctl(8) to acquire info from different systems

2008-05-18 Thread Ulrich Spoerlein
On Mon, 12.05.2008 at 13:09:01 -0700, David Wolfskill wrote:
 In my case, I believe it would be useful to provide an ability to tell
 sysctl(8) to report on everything asked for that it does know, and
 ignore the OIDs it doesn't know.
 
 Is this percpetion so radical that I'm way off base?  If so, please
 educate me as to why.
 
 Otherwise, I'll plan on filing a PR with the attached patch, which adds
 -i to sysctl(8)'s flags -- and which appears to work as described above:

Hi David,

I find this functionality very useful, but the addition of another flag
as problematic. First of all, old releases don't have it. Secondly, the
behaviour you describe should be the default anyway (IMHO).

So, when requesting OID a, b, and c, sysctl should print a, a warning
that it cannot find OID b (to STDERR), then print c and exit with a
return code != 0.

At least, that's what I would code it to do.

Cheers,
Ulrich Spoerlein
-- 
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: valgrind or workalike on FreeBSD/amd64 7.0/8.0?

2008-02-18 Thread Ulrich Spoerlein
On Sat, 16.02.2008 at 17:50:01 -0600, Christian S.J. Peron wrote:
 On Tue, Feb 12, 2008 at 11:51:19AM -0800, Xin LI wrote:
 [..]
  
  Hi,
  
  Is there anyone working on valgrind on newer FreeBSD releases, or some
  work-alikes?
  
  Cheers,
 
 Yes, check out the //depot/projects/valgrind/... perforce project.  It
 works pretty well.

When will mere mortals like us get a chance to play with it? I found
valgrind _very_ useful back in the 5.x and 6.x days.

Thanks for the porting!
Ulrich Spoerlein
-- 
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: /dev/dsp disappeared after power outage

2008-02-04 Thread Ulrich Spoerlein
On Mon, 04.02.2008 at 13:00:40 -0700, Bert JW Regeer wrote:
 On Feb 4, 2008, at 08:03 , John Baldwin wrote:
  On Saturday 02 February 2008 06:40:15 pm Aryeh M. Friedman wrote:
  I just had a power outage and when it came back /dev/dsp0.0 was
  missing from the devices.   the kern module loaded fine and detected
  the card correctly (according to dmesg, sysctl and /dev/sndstat) but
  neither the above or /dev/pcm exists.  After rebooting the problem
  remains. Any ideas how to fix it?
  
  Nothing to fix.  This is how devfs device cloning works.
 
 Nothing to fix? The sound card that is correctly detected by the kernel 
 module is not being created in /dev, ONLY after he had a power outage. It is 
 not even coming back when he reboots the machine.
 
 I don't have any suggestions, I just don't believe Nothing to fix is the 
 right answer.

Sigh,

AFAIK dev cloning works by creating the device nodes when open()ed.
Using 'ls /dev/dsp*' will not open() any devices, so nothing is created.
He should use 'ls /dev/dsp0 /dev/dsp0.0' and then the devices should
appear.

Try it for yourself, do 'ls /dev/dsp*' then 'ls /dev/dsp.8'

Not that anything usefull can be done with ls(1) to get sound :)


Cheers,
Ulrich Spoerlein
-- 
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: 'periodic daily' memory usage

2008-02-01 Thread Ulrich Spoerlein
On Sun, 27.01.2008 at 13:55:39 +0100, Dag-Erling Smørgrav wrote:
 --- etc/periodic/security/100.chksetuid   23 Nov 2007 13:00:31 -  
 1.9
 +++ etc/periodic/security/100.chksetuid   27 Jan 2008 12:54:38 -
 @@ -43,22 +43,17 @@
  [Yy][Ee][Ss])
   echo 
   echo 'Checking setuid files and devices:'
 - # XXX Note that there is the possibility of overrunning the args to ls
 - MP=`mount -t ufs,zfs | egrep -v  no(suid|exec) | awk '{ print $3 }' | 
 sort`
 - if [ -n ${MP} ]
 - then
 - set ${MP}
 - while [ $# -ge 1 ]; do
 - mount=$1
 - shift
 - find $mount -xdev -type f \
 - \( -perm -u+x -or -perm -g+x -or -perm -o+x \) \
 - \( -perm -u+s -or -perm -g+s \) -print0
 - done | xargs -0 -n 20 ls -liTd | sed 's/^ *//' | sort -k 11 |
 -   check_diff setuid - ${host} setuid diffs:
 - rc=$?
 - fi;;
 -*)   rc=0;;
 + MP=`mount -t ufs,zfs | awk '$0 !~ /no(suid|exec)/ { print $3 }'`
 + find -sx $MP -type f \
 + \( -perm -u+x -or -perm -g+x -or -perm -o+x \) \
 + \( -perm -u+s -or -perm -g+s \) -print0 |
 + xargs -0 ls -liTd |
 + check_diff setuid - ${host} setuid diffs:
 + rc=$?
 + ;;

Since $MP might be empty (think NFS_ROOT or CD9660_ROOT) you'd still
need the [ -n $MP ] check, AFAICS.

Cheers,
Ulrich Spoerlein
-- 
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: handling pdfs?

2007-11-30 Thread Ulrich Spoerlein
On Tue, 27.11.2007 at 21:27:41 -0500, Chuck Robey wrote:
 Is there some sort of util that will allow me to do cut'n'pasting among 
 different pdfs, or at the very least, only to print certain ranges out of 
 pdf docs, so I could do paper-wise cut'n'paste?  An all-electronic solution 
 would be best, but I'd take whatever offered.

Lots of tools have already been mentioned. I'll just throw in
pdflatex+pdfpages. You can easily zoom, rotate and N'up pages of
different PDF files.

Cheers,
Ulrich Spoerlein
-- 
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: 1000+ day uptime 5.3-RELEASE box

2007-11-12 Thread Ulrich Spoerlein
On Mon, 12.11.2007 at 04:08:45 -0600, Kevin Day wrote:
 ts1# vmstat -m
 
 Type  InUse MemUse HighUse Requests  Size(s)
allocindir12 1K   2623K532365228  64
newblk 1 1K  1K602736113  64,256
 NFSV3 srvdesc 0 0K  2K107739750  16,256
   pcb   32810K 42K176212363  16,32,64,2048
soname42 2K142K5018511311  16,32,128
  mbextcnt20 1K104K191273380  16
   iov 0 0K 12K3784306761  
 16,32,64,128,256,512,1024,2048,4096

Totally nitpicking, but could someone please fix up that format string,
so there is always at least one space between HighUse and Requests
(looks like there are two spaces between Requests and Sizes.)

People might depend on, eg., awk '{print $5}' always printing the right
field.

Thanks,
Ulrich Spoerlein
-- 
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Creating install CD with custom ports - how to massage INDEX file?

2007-10-26 Thread Ulrich Spoerlein
On Sun, 14.10.2007 at 09:38:14 -1000, Clifton Royston wrote:
   I've been building my own install CDs for a planned multi-server
 upgrade to 6.2Rp8 and ran into one last stumbling block this week.  I
 understand the process a lot better now than I did a few years back
 when I was doing it for 4.8, but I'm still having trouble pieceing
 together how I get my own package set onto the CD in a usable form.
 
   I built the release with NO_PORTS=yes, because I'm building the ports
 from my own CVS tree, which is a tightly pared down subset of the
 /usr/ports CVS, plus locally written software in ports format.  I've
 ensured that the tree is closed under the dependency operation (to use
 some math jargon) - essentially that means that my ports subset includes
 all the dependencies of every port I'm including and all of *its*
 run/build dependencies in the tree, even if not being built.  That
 allows the dependency graph to be calculated and the INDEX-6 file to be
 built properly.
 
   However, copying the INDEX-6 file and my private packages hierarchy
 into the CD build area doesn't work; I can read them off the CD
 post-install but sysinstall doesn't see them.  It's not a disaster
 because I can always put the CD back in after booting and install them
 then, but it would would be nice to get them all zapped in with the
 initial install.

I'm doing something similar. I work with a complete ports tree and then build a
subset of interesting packages (plus required packages). The problem with
sysinstall is, that it requires the number of the CD, where the package
resides. Since I make sure, that my ISO never exceeds one volume I decided to
drop the volume number from the sysinstall INDEX altogether

Here's the Makefile targets creating the packages and ISO

packages:
# prepare lots of stuff
# ...
.for pkg in ${PACKAGES}
chroot ${TLR} /create_packages.sh ${pkg}
.endfor
## Build a stripped down INDEX file, usually done by 
/usr/ports/Tools/scripts/release/scrubindex.pl, yet it would
## require manual handling. We assume all dependant packages are there (we just 
built them after all), so we simply
## take all lines where we have a package for it.
## First we grab the name of the indexfile (can be INDEX, INDEX-5, INDEX-6, 
etc.), then we loop over all entries of
## of the global index and test -f if the package was built, if so, we print 
the line.
(INDEX=`sh -c chroot ${TLR} /usr/bin/make -f /usr/ports/Makefile -V 
INDEXFILE`; \
awk -F| '{if (system(test -f ${TLR}/usr/ports/packages/All/ $$1 
.tbz) == 0) print $$0}' \
${TLR}/usr/ports/$$INDEX  ${TFR}/packages/INDEX)
cd ${TFR}  find -d packages | cpio --quiet -dumpl ${TRR}/R/cdrom/disc1

iso:
# Remove CD_VOLUME from the cdrom.inf, we only ship 'disc 0'
echo CD_VERSION = ${RELEASE}  ${TRR}/R/cdrom/disc1/cdrom.inf
mkisofs -r -J -V '${RELEASE}' -publisher 'Distribution made for 
1822direkt' -o ${TFR}.iso \
-b boot/cdboot -no-emul-boot ${TRR}/R/cdrom/disc1
md5 ${TFR}.iso  ${TFR}.iso.md5

hth,
Ulrich Spoerlein
-- 
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: A more tenuously package-related question

2007-10-26 Thread Ulrich Spoerlein
On Tue, 23.10.2007 at 15:47:40 -1000, Clifton Royston wrote:
   I got a request to summarize my results to the list, so here's a
 quick write-up.  Based on my preliminary testing last week, pkg_replace
 looks like the right tool for package-based server maintenance.

Interesting, as I'm facing the same problem.

   One invaluable feature which was not immediately obvious from the
 description and man page is that if you give it a list of binary
 packages on the command line, it orders the updates correctly based on
 the dependencies between those packages.

Does it take the dependency graph from the already installed packages?

   Thus updating my test server with the recently security-fixed
 versions of the packages for png and ImageMagick was just a matter of
 executing:
   sudo pkg_replace png-1.2.22.tbz ImageMagick-nox11-6.3.5.10_1.tbz 
 in my package repository directory.

Where is your package repository? Does pkg_replace work by simply
setting PKG_PATH=ftp://foo/bar ?

Cheers,
Ulrich Spoerlein
-- 
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Own Install CD with custom kernel

2007-09-25 Thread Ulrich Spoerlein
On 9/25/07, Matthias Fechner [EMAIL PROTECTED] wrote:
 thx a lot for your really great answer, but I have some more short
 questions. :)
 Do you copy the release target to the Makefile in
 /usr/src/release/Makefile or do you execute from another place?

Since we need to be able to reproduce our releases, we use the chroot
facility and build those releases in their very own directory. That
way we can also easily use a custom make.conf, especially for the
package building (which are built in that same chroot).

So, with the variables as defined below, I first run the 'init'
target, which sets up the chroot environment

init:
mkdir -p ${TLR}/usr ${TLR}/etc ${TLR}/usr/ports/local
mkdir -p ${TFR}/packages ${TFR}/distfiles
${TLR}/usr/ports/packages ${TLR}/usr/ports/distfiles
cd ${TLR}/usr  ${CVS} co -r ${SRCBRANCH} ${SRCDATE} src
cd ${TLR}/usr/src  make -j4 buildworld DESTDIR=${TLR}
cd ${TLR}/usr/src  make installworld DESTDIR=${TLR}
cd ${TLR}/usr/src  make distribution DESTDIR=${TLR}
cd ${TLR}/usr  ${CVS} co ${PORTSDATE} ports
cp -pr ports/* ${TLR}/usr/ports/local

then 'release' is run as given in my previous mail. After that, the
'packages' target does a lot of voodoo and then loops over a make
variable which contains all the packages we are interested in and
builds them. It is kind of messy, though as we have local patches
which are to be applied to the cvs checkout. Makeing this step
idempotent is ... interesting.

  rm -f ${TLR}/usr/src/release/.install.cfg
  [...]
  cd ${TRR}/R/ftp  find -d . | cpio --quiet -dumpl ${TFR}

 hm, cannot found the variables TLR and TRR anywhere defined. Can you
 please give me some more information how your buildprocess looks?

These are just arbitrary places where the stuff is located, they are defined as

# Build tree, needs LOTS of space ...
T=  /build
# Shortcuts
TLR=$T/live/${RELEASE}
TRR=$T/release/${RELEASE}
TFR=$T/ftproot/pub/FreeBSD/${RELEASE}


  And files/install.cfg contains the following

 where should I store that file?
 man release doesn't give here any information about it.

This is documented somewhere in sysinstall(8), I guess. You can place
it on a floppy (yeah, right). I put it in
${TLR}/usr/src/release/install.cfg as you saw from the example in my
previous mail and it should then make it into the ISO. How exactly
this works, I can't remember right now ... Ah, src/release/Makefile
contains under the release.8 target:
-test -f ${.CURDIR}/install.cfg \
 cp ${.CURDIR}/install.cfg ${RD}/mfsfd

So it ends up in the MFS from which FreeBSD installs itself.

  So basically, sysinstall is intructed to not install any kernel, but
  after all distributions are extracted the following commands are run
 
  command=/bin/sh -c cd /dist/${RELEASE}/kernels  ./install.sh GENERIC
  system
  command=/bin/sh -c cd /dist/${RELEASE}/kernels  ./install.sh SMP
  system

 where can you say sysinstall that it should run such commands after
 the installation?

install.cfg, take a look at
/usr/src/usr.sbin/sysinstall/install.cfg

hth,
Uli
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Own Install CD with custom kernel

2007-09-23 Thread Ulrich Spoerlein
On Thu, 20.09.2007 at 09:32:56 +0200, Matthias Fechner wrote:
 It seems that sysinstall will not install per default the new kernel.
 For a non SMP system (like mine) it is I4B.
 So it seems to me that I must change /usr/src/usr.sbin/sysinstall to
 do this. I attached a patch to this email which should do it.
 
 [...]
 
 I checked now the the installed system and there is absolutly no kernel
 installed. (no /boot/GENERIC, no /boot/I4B or anything else)
 
 I'm sure that I must oversaw something in sysinstall to change but I
 cannot find it.
 Can please anyone provide with some help?

Hi,

we need to install multiple kernels per system and instead of relying on
sysinstall (I couldn't figure out, how to install multiple kernels with
it, especially since it wants to install the default kernel to 'kernel')
I hacked up my own kernel installation

I'm using a Makefile to drive our release and package building and for
the releases I'm using an install.cfg, which gets created on the fly,
since the names of the kernels change now and then, here is the release
target

KERNELS=SERVER GENERIC SMP

release rerelease:
# Write automation script for sysinstall
rm -f ${TLR}/usr/src/release/.install.cfg
for k in ${KERNELS}; do printf %s\n%s\n command=/bin/sh -c \cd 
/dist/${RELEASE}/kernels  ./install.sh $$k\ system \
 ${TLR}/usr/src/release/.install.cfg; done
sed '/^#KERNELS#/r ${TLR}/usr/src/release/.install.cfg' 
files/install.cfg  ${TLR}/usr/src/release/install.cfg
cp files/src.diff ${TLR}/usr/src/release/src.diff
# Create a src patch for our kernels on the fly, so we can pass it to make 
release
(for i in ${KERNELS}; do diff -u /dev/null kernels/$$i 2/dev/null || 
true; done) | sed 's,kernels/,sys/i386/conf/,' \
 ${TLR}/usr/src/release/kernels.diff
# Copy them over again for rerelease, perhaps something changed
.if make(rerelease)
.for k in ${KERNELS}
-cp kernels/$k ${TRR}/usr/src/sys/i386/conf/
.endfor
.endif
cd ${TLR}/usr/src/release  make ${.TARGET} \
BUILDNAME=${RELEASE} \
CHROOTDIR=${TRR} \
WORLD_FLAGS=-j4 \
MODULES_WITH_WORLD=yes \
WITHOUT_MODULES='3dfx 3dfx_linux ath ath_hal ath_rate_amrr 
ath_rate_onoe ath_rate_sample aue\
bktr cardbus coda coda5 dcons dcons_crom fatm 
firewire firmware harp hatm \
if_ndis ip6fw ipw iwi joy kue ndis pccard ral 
splash syscons umodem ural urio\
uscanner utopia uvisor wi wlan wlan_acl 
wlan_ccmp wlan_tkip wlan_wep wlan_xauth' \
KERNEL_FLAGS=-j4 MODULES_WITH_WORLD=yes \
KERNELS_BASE=''\
NODOC=YES NOPORTS=YES NOSRC=YES NO_FLOPPIES=YES \
RELEASENOUPDATE=YES \ 
LOCAL_PATCHES='src.diff kernels.diff' \
KERNELS='${KERNELS}' \
CVSROOT=${CVSROOT} \ 
CVSCMDARGS='${SRCDATE}' \
RELEASETAG=${SRCBRANCH} 
cd ${TRR}/R/ftp  find -d . | cpio --quiet -dumpl ${TFR}

And files/install.cfg contains the following

debug=yes
mediaSetCDROM
# Select which distributions we want. We omit the kernels here, we do them by 
hand
dists= base doc manpages games catpages dict info
distSetCustom

# Partition Editor
diskInteractive=YES
bootManager=standard
diskPartitionEditor
diskLabelEditor

installCommit

# Magic marker, don't edit! Is set automatically from the Makefile!
#KERNELS#
# End of magic marker

So basically, sysinstall is intructed to not install any kernel, but
after all distributions are extracted the following commands are run

command=/bin/sh -c cd /dist/${RELEASE}/kernels  ./install.sh GENERIC
system
command=/bin/sh -c cd /dist/${RELEASE}/kernels  ./install.sh SMP
system

It has the nice side effekt of GENERIC and SMP landing in
/boot/{GENERIC,SMP}

We also ship a /boot/loader.conf that sets the correct kernel to boot
and is versioned and centrally controlled, yadda yadda yadda

hth,
Ulrich Spoerlein
-- 
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [PATCH] newsyslog - don't compress first log file

2007-08-12 Thread Ulrich Spoerlein
On Fri, 10.08.2007 at 09:13:18 -0700, David Wolfskill wrote:
 On Fri, Aug 10, 2007 at 02:19:55PM +0300, Artis Caune wrote:
  How about aditional flag (X) to newsyslog, which don't compress first 
  log file?
 ...
 
 Interesting idea, but it still falls short of something we recently
 needed to do at work:
 
 We have a requirement to retain some number of logfiles, but only
 compress those older than the Nth generation.
 
 Thus, we might retain 90 rotated generations of the log file, of which
 the oldest 50 are compressed, while the newest 40 are not.

Sorry, to be so blunt, but I think this .N suffix is a stupid approach
for archival purposes. You never know which time span is included in the
file foo.17.gz.

I'd rather see an extension for newsyslog which would rotate foo to
foo.2007-08-12.gz, iff rotation is done every day at midnight.

That way, you get a 'stable' name, which makes it easier to find the
logfile for 1999-12-31 or 2000-01-01 some years from now.

Right now, I have to use syslog-ng for that purpose.

Cheers,
Ulrich Spoerlein
-- 
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Tar output mode for installworld

2007-07-18 Thread Ulrich Spoerlein
On Tue, 17.07.2007 at 13:00:20 -0700, Matthew Dillon wrote:
 Probably the best way to do this is to pre-cache the data with an
 /etc/rc.d script.  Write a little program to do it or build it as a
 script.  Inode numbers for files on a CD tend to reflect the location

That is an interesting project in itself. This could be used to speed up
the boot process on any FreeBSD installation and I think MacOS' new init
system is where I got the idea from.

What I envisioned (quick n dirty):
- Init runs rc inside a ktrace session
- after the rc scripts have finished, you turn off ktrace
- kdump and read all files which were read during rc[2]
- do some magic to sort the list based on their hard disk location
- put this list in /var/db/precache.db
- /etc/rc.d/precache (which will run very early[1]):
  (for file; cat $file /dev/null); sleep 3
  yes, it will be run in the background

Problems with this naive approach: It reads entire files, not blocks.
The filelist has to be kept small and only small files should appear
in the list. With direct kernel support one could do a lot more, I
guess.

I'm running on a fast laptop with a crappy 4800RPM hard disk which is
dog slow. I have the feeling my bootup time could be reduced drastically
by this approach. Perhaps some day I get around to prototyping it.


[1] I know this is hard to decide.
[2] To make this self-tuning, the output of the precache script must not
appear in the ktrace/kdump list.

Cheers,
Ulrich Spoerlein
-- 
The trouble with the dictionary is you have to know how the word is
spelled before you can look it up to see how it is spelled.
-- Will Cuppy
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Tar output mode for installworld

2007-07-16 Thread Ulrich Spoerlein

On 7/15/07, Tim Kientzle [EMAIL PROTECTED] wrote:

Ulrich Spoerlein wrote:
 Simple and elegant. It would also do away with those base.aa, base.ab,
 etc. madness.

I'm confused.  base.aa, etc, are a tar file, so I don't
entirely understand how this would be different?  The
current installer does the equivalent of
   cat base.* | tar -xf -

I can see one advantage and one disadvantage of installing
a specification file (which references other files) instead:

Plus:  The specification file can re-use the existing
files on CD, so you don't have, e.g., one copy of /bin/sh
on the live CD and another buried in base.tgz.  This
could save space.


That is exactly what I was referring to above. And AFAIK DragonflyBSD
does it in a similar way. They simply copy the live CD onto the HDD.


Minus:  Installing a specification file this way would
be slower because you then have to read a lot of small
files off of CD.


True, but couldn't we optimize the ISO layout so it will be a near
sequential read of the CD? This should be done for every live CD
anyway to avoid excessive seeks during boot up.

Uli
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Tar output mode for installworld

2007-07-15 Thread Ulrich Spoerlein
On Sat, 14.07.2007 at 23:28:05 -0700, Tim Kientzle wrote:
  #%ntree
  bin/echo uid=0 gid=0 group=wheel contents=my/bin/echo
 
  I think this should form a reasonable basis against which
  to implement tar output for installworld.  I would actually
  suggest building the specification file at buildworld time, not
  at installworld time.  You could then create a tarball with
tar -czf system.tgz @specification.ntree
  or install directly from the specification file using
tar -xvpf specification.ntree -C ${DESTDIR}

This would be the perfect basis on which to build a live/install release
CD. You boot it up on a cd9660 filesystem and put some unionfs hacks on
top, to make it fully work as a live cd.

After you've done the fdisk/bsdlabel/gmirror/zfs stuff manually or via
some yet to be written installer, you then kick of the install through
tar.

Simple and elegant. It would also do away with those base.aa, base.ab,
etc. madness.

I like it!

Cheers,
Ulrich Spoerlein
-- 
The trouble with the dictionary is you have to know how the word is
spelled before you can look it up to see how it is spelled.
-- Will Cuppy
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: pkg_upgrade (was Re: pkg_add does not backtrack, does it?)

2007-02-08 Thread Ulrich Spoerlein
Kip Macy wrote:
 On Wed, 7 Feb 2007, Joan Picanyol i Puig wrote:
 
 I know what I'd like: a utility in the base system for binary upgrading
 of packages. More flexible logic in how the '-r' option is handled would
 be nice (being able to fetch all packages from All/ even if you are
 on RELENG). Doesn't
 
 freebsd-update fetch install  pkg_upgrade -a
 
 look nice for keeping up to date? The obvious hairy details must be
 harder than it seems, I'm sure others have considered it (and would have
 done it) before.

 portupgrade -aPP

Requires a fully populated /usr/ports together with an up-to-date INDEX.

Not exactly what we are looking for here. I hacked together an ugly
shell script, that will use pkg_version (it can grab the INDEX from the
pkg-site via ftp) and gives you the feature to pkg_delete/pkg_add
selected packages.

It is missing a lot of other stuff, though.

Ulrich Spoerlein
-- 
A: Yes.
Q: Are you sure?
 A: Because it reverses the logical flow of conversation.
 Q: Why is top posting frowned upon?
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: dump reads more than restore writes?

2007-01-08 Thread Ulrich Spoerlein

On 1/8/07, Oliver Fromme [EMAIL PROTECTED] wrote:

However, I think that there must be a bug in gstat when it
displays 600 GB read to copy a 200 GB file system.  dump(8)
is inefficient, but not _that_ inefficient.


When doing the dump|restore dance to copy filesystems, I make it a
habit to have iostat(1) running. It is _always_ displaying a read rate
twice as high as the write rate. And since the iostat/gstat numbers
usually match up, eg., dd(1) numbers, I heavily doubt that it's a
reporting/statistics glitch.

It has to be dump(8).

Uli
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: net/mpd causes a kernel freeze

2006-11-14 Thread Ulrich Spoerlein
Gonzalo Arana wrote:
 Hi,
 
 When I open a pptp tunnel with net/mpd, my PC freezes (numlock stops
 responding, for instance).
 
 I am using 6.1-RELEASE with GENERIC kernel.  I've recompiled removing
 USB, SCSI/RAID controllers, with the same result.
 
 The freeze occurs right after the tunnel is up.

Hi,

you should build a Kernel with debugging options turned on (DDB, KDB,
WITNESS, INVARIANTS, etc. see the handbook). And then enter the debugger
if the freeze occurs, refer again to the handbook about kernel
debugging.

It may also help to turn OFF PREEMPTION, ie. remove that line from your
kernel conf.


Ulrich Spoerlein
-- 
A: Yes.
Q: Are you sure?
 A: Because it reverses the logical flow of conversation.
 Q: Why is top posting frowned upon?
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: File trees: the deeper, the weirder

2006-10-29 Thread Ulrich Spoerlein
Yar Tikhiy wrote:
 Weird, eh?  Any ideas what's going on?

None, but have you tried without soft updates?

Ulrich Spoerlein
-- 
A: Yes.
Q: Are you sure?
 A: Because it reverses the logical flow of conversation.
 Q: Why is top posting frowned upon?
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: absolute vs. relative offsets in disklabel

2006-08-03 Thread Ulrich Spoerlein
Dmitry Marakasov wrote:
 There are many weighty arguments for relative offsets:
 - No confusion (once I did try to dd slice from one place on disk to
   another to copy it, and was very surprised when changes made on one
   partition appeared on another as well)
 - Ability to copy and move slices with simple dd(1).

Yes please! I am faced with the problem, that I want to offset my
FreeBSD slice about -2GB, so I can use growfs to enlarge it.

btw, how hard would it be to write a shrinkfs and perhaps movefs tool?

Ulrich Spoerlein
-- 
A: Yes.
Q: Are you sure?
 A: Because it reverses the logical flow of conversation.
 Q: Why is top posting frowned upon?
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Atomic updates of NFS export lists

2006-04-25 Thread Ulrich Spoerlein
Andrey Simonenko wrote:
 [Lots of good stuff]
 Now mountd does not work if there is some error in exports file.
 I think this is correct behaviour and I'm ready to explain this.

Hello Andrey,

I hope these 'errors' in the exports file only mean syntactical errors?
For example, I have a /vol partition mounted on my NFS server, which is
exported via NFS. Now, sometimes /vol is mounted, sometimes it is not
mounted (on the server). This will generate some warnings from mountd,
as it can't export the /vol filesystem, but mountd still works the same.
Once /vol becomes available, I don't even need to restart mountd, it
will simply pick up /vol and make it available.

I hope these semantics will remain? (No sorry, I didn't not test your
patch yet).

Ulrich Spoerlein
-- 
 PGP Key ID: 20FEE9DD   Encrypted mail welcome!
Fingerprint: AEC9 AF5E 01AC 4EE1 8F70  6CBD E76E 2227 20FE E9DD
Which is worse: ignorance or apathy?
Don't know. Don't care.


pgpgo3MCQM24c.pgp
Description: PGP signature


Re: Naive implementation of strverscmp(3)

2006-02-17 Thread Ulrich Spoerlein

Jilles Tjoelker wrote:

On Wed, Feb 15, 2006 at 10:05:24AM -0600, Dan Nelson wrote:
 Your function is simpler than the C implementation on that site, but
 falls over when a run of numbers exceeds 2^31 (raise it to 2^64 if you
 use strtoull, but that's as high as you can yet).

That problem can be avoided fairly easily. First skip the leading zeroes
on both sides, then strspn for digits; the longest run of digits is
greater, otherwise strncmp it.


Yes, the trouble begins, when you really want to be compatible with the 
GNU version.


Attached is an new, ugly version of strverscmp(3) that behaves exactly 
as the glibc version (at least for a limit amount of testing).


Ulrich Spoerlein
--
 PGP Key ID: 20FEE9DD   Encrypted mail welcome!
Fingerprint: AEC9 AF5E 01AC 4EE1 8F70  6CBD E76E 2227 20FE E9DD
Which is worse: ignorance or apathy?
Don't know. Don't care.
#include stdio.h
#include stdlib.h
#include string.h
#include limits.h

#ifdef __FreeBSD__
int
strverscmp(const char *s1, const char *s2);

int
strverscmp(const char *s1, const char *s2)
{
  static const char *digits = 0123456789;
  int ret, lz1, lz2;
  size_t p1, p2;

  p1 = strcspn(s1, digits);
  p2 = strcspn(s2, digits);
  while (p1 == p2  s1[p1] != '\0'  s2[p2] != '\0') {
/* Different prefix */
if ((ret = strncmp(s1, s2, p1)) != 0)
  return ret;

s1 += p1;
s2 += p2;

lz1 = lz2 = 0;
if (*s1 == '0')
  lz1 = 1;
if (*s2 == '0')
  lz2 = 1;

if (lz1  lz2)
  return -1;
else if (lz1  lz2)
  return 1;
else if (lz1 == 1) {
  /*
   * If the common prefix for s1 and s2 consists only of zeros, then the
   * longer number has to compare less. Otherwise the comparison needs
   * to be numerical (just fallthrough). See
   * http://refspecs.freestandards.org/LSB_2.0.1/LSB-generic/
   * LSB-generic/baselib-strverscmp.html
   */
  while (*s1 == '0'  *s2 == '0') {
++s1;
++s2;
  }

  p1 = strspn(s1, digits);
  p2 = strspn(s2, digits);

  /* Catch empty strings */
  if (p1 == 0  p2  0)
return 1;
  else if (p2 == 0  p1  0)
return -1;

  /* Prefixes are not same */
  if (*s1 != *s2  *s1 != '0'  *s2 != '0') {
if (p1  p2)
  return 1;
else if (p1  p2)
  return -1;
  } else {
if (p1  p2)
  ret = strncmp(s1, s2, p1);
else if (p1  p2)
  ret = strncmp(s1, s2, p2);
if (ret != 0)
  return ret;
  }
}

p1 = strspn(s1, digits);
p2 = strspn(s2, digits);

if (p1  p2)
  return -1;
else if (p1  p2)
  return 1;
else if ((ret = strncmp(s1, s2, p1)) != 0)
  return ret;

/* Numbers are equal or not present, try with next ones. */
s1 += p1;
s2 += p2;
p1 = strcspn(s1, digits);
p2 = strcspn(s2, digits);
  }
  
  return strcmp(s1, s2);
}
#endif

int
main(int argc, char **argv)
{
  char **array, *temp;
  int i, j, n = 18;

  array = (char **) calloc(n, sizeof(char *));
  array[0] = strdup(10.jpg);
  array[1] = strdup(2.jpg);
  array[2] = strdup(1.jpg);
  array[3] = strdup(09.jpg);
  array[4] = strdup(1.012);
  array[5] = strdup(0010.jpg);
  array[6] = strdup(1.002);
  array[7] = strdup(1.01);
  array[8] = strdup(1.10);
  array[9] = strdup(1.01000);
  array[10] = strdup(000999);
  array[11] = strdup(001000);
  array[12] = strdup(999);
  array[13] = strdup(1000);
  array[14] = strdup(1.01);
  array[15] = strdup(1.09);
  array[17] = strdup(1.01020);
  array[16] = strdup(1.0102);

  /* Bubble sort */
#if 1
  for (i=0; in; ++i) {
for (j=i; jn; ++j) {
  if (strverscmp(array[i], array[j])  0) {
temp = array[j];
array[j] = array[i];
array[i] = temp;
  }
}
printf(%s\n, array[i]);
  }
  printf(%2d = 0\n, strverscmp(a, a));
  printf(%2d  0\n, strverscmp(alpha1, alpha001));
  printf(%2d  0\n, strverscmp(part1_f012, part1_f01));
  printf(%2d  0\n, strverscmp(item#99, item#100));
  printf(%2d  0\n, strverscmp(foo.009, foo.0));
  printf(%2d  0\n, strverscmp(0009, 09));
#endif
  printf(%2d  0\n, strverscmp(1.002, 1.01000));
  printf(%2d  0\n, strverscmp(1.01000, 1.0102));
  printf(%2d  0\n, strverscmp(1.002, 1.01));
  printf(%2d  0\n, strverscmp(1.012, 1.09));
  printf(%2d  0\n, strverscmp(1.01, 1.012));

  return 0;
}


pgpwA8JaW0pSQ.pgp
Description: PGP signature


Re: Naive implementation of strverscmp(3)

2006-02-15 Thread Ulrich Spoerlein

Peter Jeremy wrote:
Is there a chance this might get included into libc? Or is it considered 
bloat?

I don't think it belongs in libc.  Maybe libutil.


This would require patching the gqview configure script, but I can live 
with that.



For the first point, consider
  strverscmp(jan25, janx25);


This fell victim to a rearranging of the while loop. Thanks for pointing 
that out!


Attached is an updated version, which now also takes leading zeros into 
account. It still differs from the GNU version, because

strverscmp(foo.009, foo.0)  0
In my book, '009' is just greater than zero, no matter what. If someone 
could explain to me, why the GNU folks do it the other way round, I 
could try implementing that too.


Also, what do people think about the commented out while construct? It 
saves a call to strcspn(s2) if s1 has no digits, but it's rather ugly.



Ulrich Spoerlein
--
 PGP Key ID: 20FEE9DD   Encrypted mail welcome!
Fingerprint: AEC9 AF5E 01AC 4EE1 8F70  6CBD E76E 2227 20FE E9DD
Which is worse: ignorance or apathy?
Don't know. Don't care.
#include stdio.h
#include stdlib.h
#include string.h
#include limits.h

#ifdef __FreeBSD__
int
strverscmp(const char *s1, const char *s2);

int
strverscmp(const char *s1, const char *s2)
{
  static const char *digits = 0123456789;
  char *t1, *t2;
  int ret;
  long n1, n2;
  size_t p1, p2;

  p1 = strcspn(s1, digits);
  p2 = strcspn(s2, digits);
  //while ((p1=strcspn(s1, digits)) != 0  p1 == (p2=strcspn(s2, digits))) {
  while (p1 == p2  p1 != 0) {
  
/* Different prefix */
if ((ret = strncmp(s1, s2, p1)) != 0)
  return ret;

s1 += p1;
s2 += p2;
n1 = strtol(s1, t1, 10);
n2 = strtol(s2, t2, 10);

if (n1  n2)
  return -1;
else if (n1  n2)
  return 1;

/* One number is shorter, e.g., 07 vs 007 */
if (t1-s1  t2-s2)
  return 1;
else if (t1-s1  t2-s2)
  return -1;

/* Numbers are equal or not present, try with next ones. */
s1 = t1;
s2 = t2;
p1 = strcspn(s1, digits);
p2 = strcspn(s2, digits);
  }
  
  return strcmp(s1, s2);
}
#endif

int
main(int argc, char **argv)
{
  char **array, *temp;
  int i, j, n = 10;

  array = (char **) calloc(n, sizeof(char *));
  array[0] = strdup(jan009);
  array[1] = strdup(jan10);
  array[2] = strdup(jan09);
  array[3] = strdup(jan0a);
  array[4] = strdup(jan17b);
  array[5] = strdup(jan17a);
  array[6] = strdup(janx25);
  array[7] = strdup(jan25);
  array[8] = strdup(jan17x);
  array[9] = strdup(jan9);

  /* Bubble sort */
  for (i=0; in; ++i) {
for (j=i; jn; ++j) {
  if (strverscmp(array[i], array[j])  0) {
temp = array[j];
array[j] = array[i];
array[i] = temp;
  }
}
  }

  for (i=0; in; ++i) {
printf(%s\n, array[i]);
  }

  printf(%d = 0\n, strverscmp(a, a));
  printf(%d  0\n, strverscmp(item#99, item#100));
  printf(%d  0\n, strverscmp(alpha1, alpha001));
  printf(%d  0\n, strverscmp(part1_f012, part1_f01));
  printf(%d  0\n, strverscmp(foo.009, foo.0));
  printf(%d\n, strcmp(jan25, janx25));
  printf(%d\n, strverscmp(jan25, janx25));

  return 0;
}


pgp4Zf3I8k6Sp.pgp
Description: PGP signature


Re: Naive implementation of strverscmp(3)

2006-02-15 Thread Ulrich Spoerlein

Dan Nelson wrote:

This looks a lot like strnatcmp, which is natural sort or do what I
mean sort :)

http://sourcefrog.net/projects/natsort/


Heh, I didn't know about that one, but since gqview uses strverscmp I 
only google for that one.



Your function is simpler than the C implementation on that site, but
falls over when a run of numbers exceeds 2^31 (raise it to 2^64 if you
use strtoull, but that's as high as you can yet).


That's true, I didn't think of that. It's funny how a simple function 
like comparing alphanumerical strings can cause that much trouble.


Anyway, attached is a last version, which now also functions for strings 
starting with numbers and which I'll probably try getting committed to 
the gqview port.


You may do with the code whatever you want. :)

Ulrich Spoerlein
--
 PGP Key ID: 20FEE9DD   Encrypted mail welcome!
Fingerprint: AEC9 AF5E 01AC 4EE1 8F70  6CBD E76E 2227 20FE E9DD
Which is worse: ignorance or apathy?
Don't know. Don't care.
#include stdio.h
#include stdlib.h
#include string.h
#include limits.h

#ifdef __FreeBSD__
int
strverscmp(const char *s1, const char *s2);

int
strverscmp(const char *s1, const char *s2)
{
  static const char *digits = 0123456789;
  char *t1, *t2;
  int ret;
  long n1, n2;
  size_t p1, p2;

  p1 = strcspn(s1, digits);
  p2 = strcspn(s2, digits);
  while (p1 == p2  s1[p1] != '\0'  s2[p2] != '\0') {
/* Different prefix */
if ((ret = strncmp(s1, s2, p1)) != 0)
  return ret;

s1 += p1;
s2 += p2;
n1 = strtol(s1, t1, 10);
n2 = strtol(s2, t2, 10);

if (n1  n2)
  return -1;
else if (n1  n2)
  return 1;

/* One number is shorter, e.g., 07 vs 007 */
if (t1-s1  t2-s2)
  return 1;
else if (t1-s1  t2-s2)
  return -1;

/* Numbers are equal or not present, try with next ones. */
s1 = t1;
s2 = t2;
p1 = strcspn(s1, digits);
p2 = strcspn(s2, digits);
  }
  
  return strcmp(s1, s2);
}
#endif

int
main(int argc, char **argv)
{
  char **array, *temp;
  int i, j, n = 10;

  array = (char **) calloc(n, sizeof(char *));
  array[0] = strdup(10.jpg);
  array[1] = strdup(2.jpg);
  array[2] = strdup(1.jpg);
  array[3] = strdup(09.jpg);
  array[4] = strdup(a01b2);
  array[5] = strdup(a1b1);
  array[6] = strdup(a);
  array[7] = strdup(1.001);
  array[8] = strdup(1.1);
  array[9] = strdup(1.01);

  /* Bubble sort */
  for (i=0; in; ++i) {
for (j=i; jn; ++j) {
  if (strverscmp(array[i], array[j])  0) {
temp = array[j];
array[j] = array[i];
array[i] = temp;
  }
}
  }

  for (i=0; in; ++i) {
printf(%s\n, array[i]);
  }

  printf(%d = 0\n, strverscmp(a, a));
  printf(%d  0\n, strverscmp(item#99, item#100));
  printf(%d  0\n, strverscmp(alpha1, alpha001));
  printf(%d  0\n, strverscmp(part1_f012, part1_f01));
  printf(%d  0\n, strverscmp(foo.009, foo.0));

  return 0;
}


pgpGCPqSlIXkY.pgp
Description: PGP signature


Naive implementation of strverscmp(3)

2006-02-14 Thread Ulrich Spoerlein

Hello Hackers,

this is probably not the right list, but I'd like to collect reviews of 
a strverscmp(3) function I wrote. It is used by the graphics/gqview port 
(if present in libc) and since I want/need that functionality I whipped 
up a somewhat working version.


It tries to sort strings like jan1, jan2, jan10, etc. into the 
natural order.


Is there a chance this might get included into libc? Or is it considered 
bloat?


The GNU version can be found here
http://refspecs.freestandards.org/LSB_2.0.1/LSB-generic/LSB-generic/baselib-strverscmp.html

Quite frankly, I don't understand their integral/fraction distinction, 
and my version differs in that regard. See the return values of the 
attached sample code.


Ulrich Spoerlein
--
 PGP Key ID: 20FEE9DD   Encrypted mail welcome!
Fingerprint: AEC9 AF5E 01AC 4EE1 8F70  6CBD E76E 2227 20FE E9DD
Which is worse: ignorance or apathy?
Don't know. Don't care.
#include stdio.h
#include stdlib.h
#include string.h
#include limits.h

#ifdef __FreeBSD__
int
strverscmp(const char *s1, const char *s2);

int
strverscmp(const char *s1, const char *s2)
{
  static const char *digits = 0123456789;
  int ret;
  long n1, n2;
  size_t p1, p2;

  do {
p1 = strcspn(s1, digits);
p2 = strcspn(s2, digits);
  
/* Different prefix */
if ((ret = strncmp(s1, s2, p1)) != 0)
  return ret;

s1 += p1;
s2 += p2;
n1 = strtol(s1, NULL, 10);
n2 = strtol(s2, NULL, 10);

if (n1  n2)
  return -1;
else if (n1  n2)
  return 1;

/* Numbers are equal or not present, try with next ones. */
p1 = strspn(s1, digits);
p2 = strspn(s2, digits);
s1 += p1;
s2 += p2;
  } while (p1 == p2  p1 != 0  p1 != 0);
  
  return strcmp(s1, s2);
}
#endif

int
main(int argc, char **argv)
{
  char **array, *temp;
  int i, j, n = 10;

  array = (char **) calloc(n, sizeof(char *));
  array[0] = strdup(jan2);
  array[1] = strdup(jan10);
  array[2] = strdup(jan);
  array[3] = strdup(jan0a);
  array[4] = strdup(jan17b);
  array[5] = strdup(jan17a);
  array[6] = strdup(jan17x1234);
  array[7] = strdup(jan17x123);
  array[8] = strdup(jan17x123a);
  array[9] = strdup(jan9);

  /* Bubble sort */
  for (i=0; in; ++i) {
for (j=i; jn; ++j) {
  if (strverscmp(array[i], array[j])  0) {
temp = array[j];
array[j] = array[i];
array[i] = temp;
  }
}
  }

  for (i=0; in; ++i) {
printf(%s\n, array[i]);
  }

  printf(%d\n, strverscmp(a, a));
  printf(%d\n, strverscmp(item#99, item#100));
  printf(%d\n, strverscmp(alpha1, alpha001));
  printf(%d\n, strverscmp(part1_f012, part1_f01));
  printf(%d\n, strverscmp(foo.009, foo.0));

  return 0;
}


pgpREa1U5fcJv.pgp
Description: PGP signature


Re: JFS2 on freebsd

2005-09-12 Thread Ulrich Spoerlein
On Fri, 09.09.2005 at 12:28:39 +0100, Robert Watson wrote:
 On Thu, 8 Sep 2005, Kamal R. Prasad wrote:
  Has there been any work on porting JFS2 onto Freebsd?
 There has been recent work to port several of the newer Linux file systems to 
 FreeBSD, 
 including:

What about the Google SoC project of porting FUSE to FreeBSD? I think
this could be the next best thing with regard to supporting non-BSD
filesystems.

Iff the user-space FS implementations of FUSE are portable, this would
bring support of numerous FS to FreeBSD: SMB via FUSE, SSHFS,
gphoto2-fuse-fs (I really could use this one), NTFS (with read/write
support) and others.

Now some Linux guy could re-implement ext3fs in FUSE and some other
hacker could do a UFS/UFS2 port and then Linux and FreeBSD would have
better implementations of the other's FS.

No, I'm not volunteering, and since I don't know much about porting FS
anyway, this all might be a dream. But my understanding of FUSE is that
this should be possible.

Ulrich Spoerlein
-- 
 PGP Key ID: F0DB9F44   Encrypted mail welcome!
Fingerprint: F1CE D062 0CA9 ADE3 349B  2FE8 980A C6B5 F0DB 9F44
Ok, which part of Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn.
didn't you understand?


pgpBx0k6ndZ0s.pgp
Description: PGP signature


Re: Firewire blues

2005-02-19 Thread Ulrich Spoerlein
On Fri, 18.02.2005 at 23:18:50 -0500, Stephan Uphoff wrote:
 Strange - are you sure that you have not accidentally have
 options DCONS_FORCE_CONSOLE=1
 in your config file?
 ( Or forgot to config or make depend after removing it?)

I made a new kernel (make kernel) and since I never set such an option
anywhere, I'm pretty confident, that it's at its default value.

 There is a tunable hidden in dcons_crom that causes the dcons console to
 be selected.
 
 Try adding boot_multicons and hw.firewire.dcons_crom.force_console to
 /boot/loader.conf:
 boot_multicons=YES
 hw.firewire.dcons_crom.force_console=0

Thank you! That worked, I still am running the kernel with the change
you mentioned earlier, though.

I noticed this in dcons_crom.c
#if __FreeBSD_version = 50
static int force_console = 1;
TUNABLE_INT(hw.firewire.dcons_crom.force_console, force_console);
#endif

Which to me looks like the default is to force the console, even if
NOTES has this default
./conf/NOTES:optionsDCONS_FORCE_CONSOLE=0   # force to be the primary 
console

Anyway, let's turn on ULE and PREEMPTION and see what happens :)

Ulrich Spoerlein
-- 
 PGP Key ID: F0DB9F44   Encrypted mail welcome!
Fingerprint: F1CE D062 0CA9 ADE3 349B  2FE8 980A C6B5 F0DB 9F44
Ok, which part of Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn.
didn't you understand?
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Firewire blues

2005-02-18 Thread Ulrich Spoerlein
On Fri, 18.02.2005 at 14:32:36 -0500, Stephan Uphoff wrote:
 Changing a line in the function dcons_modevent() (File
 sys/dev/dcons/dcons.c or dcons_os.c depending on your sources) should
 help you.
 
  #if __FreeBSD_version = 50
   - if (ret == 0) {
   + if (ret == 0  dcons_consdev.cn_pri == CN_DEAD) {
 dcons_cnprobe(dcons_consdev);
 dcons_cninit(dcons_consdev);
 cnadd(dcons_consdev);
 }
 #endif

Didn't work.

 As a work around you should also be able to set 
 boot_multicons=YES
 in your /boot/loader.conf file. (Not tested)

Didnt work either. I tried both and booted into single-user mode. There
was _no_ local console, only the firewire one.

 On a running system you can use conscontrol to change console devices.

This works, running conscontrol consolectl immediately switches to the
local console, but how am I supposed to run this command when booting
into singleuser? Can I somehow lower the priority of dcons?

Ulrich Spoerlein
-- 
 PGP Key ID: F0DB9F44   Encrypted mail welcome!
Fingerprint: F1CE D062 0CA9 ADE3 349B  2FE8 980A C6B5 F0DB 9F44
Ok, which part of Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn.
didn't you understand?


pgpwuQP0W3cGc.pgp
Description: PGP signature


Re: Firewire blues

2005-02-16 Thread Ulrich Spoerlein
On Sun, 13.02.2005 at 22:46:29 -0500, Stephan Uphoff wrote:
 +device dcons
 +device dcons_crom

 Then configured/compiled/installed the GENERIC.debug kernel.
 Copied the kernel.debug file in the GENERIC.debug compile directory to
 the debug station and rebooted the target machine.

I tried this with modules first, and failed every time. It needs to be
compiled into the kernel to really work, which brings me to the next
problem.

When dcons_crom is loaded (module or not) and I boot my system (laptop),
I only get the kernel output on screen. All the other output (starting
from Mounting root from ufs) goes to the firewire console.

But since I'm using GBDE on this laptop, the startup scripts want me to
enter my passphrase, which in turn I can only enter via a second machine
through firewire.

This _is_ rather unpractical :( and renders single-user console useless.
What am I doing wrong here?

Other than that, remote gdb is working. Poking inside the fwmem itself
is however not working, I get this after setting eui64_{hi,lo}
% kgdb -c /dev/fwmem0.0 kernel.debug
...
0x in ?? ()

What's missing here?

Ulrich Spoerlein
-- 
 PGP Key ID: F0DB9F44   Encrypted mail welcome!
Fingerprint: F1CE D062 0CA9 ADE3 349B  2FE8 980A C6B5 F0DB 9F44
Ok, which part of Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn.
didn't you understand?
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Firewire blues

2005-02-16 Thread Ulrich Spoerlein
On Wed, 16.02.2005 at 13:10:22 +0100, Gerald Heinig wrote:
 When dcons_crom is loaded (module or not) and I boot my system (laptop),
 I only get the kernel output on screen. All the other output (starting
 from Mounting root from ufs) goes to the firewire console.

 I don't know whether this will break other stuff, but in the course of
 my attempts to get the setup working, I tried setting

 options   DCONS_FORCE_CONSOLE=1

 This caused all the output of the console to go to the Firewire port. I
 could log in etc. as normal on the console (over Firewire of course).

This is backwards. I _don't_ want to have the console on the firewire
port, I want/need it on the local keyboard/display (aka syscons)
console.

The firewire is just for on-demand debugging (hangs, panics, stuff), it
shouldn't interfere with normal usage.

Right now, I would need two kernel and a reboot in between to get the
desired functionality.

Ulrich Spoerlein
-- 
 PGP Key ID: F0DB9F44   Encrypted mail welcome!
Fingerprint: F1CE D062 0CA9 ADE3 349B  2FE8 980A C6B5 F0DB 9F44
Ok, which part of Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn.
didn't you understand?
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Firewire blues

2005-02-07 Thread Ulrich Spoerlein
On Mon, 07.02.2005 at 10:16:13 +0100, Gerald Heinig wrote:
 [dcons disconnected (get crom failed)]
 [...]
 BTW, I'm trying to set up remote debugging with gdb to debug a kernel hang.

As Stephan already suggested, try fwcontrol -r (probably on both hosts).
This worked for me. And good luck in getting kgdb to work over firewire,
I failed :(

If you get it working, please get back to me!

Ulrich Spoerlein
-- 
 PGP Key ID: F0DB9F44   Encrypted mail welcome!
Fingerprint: F1CE D062 0CA9 ADE3 349B  2FE8 980A C6B5 F0DB 9F44
Ok, which part of Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn.
didn't you understand?
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]