Share

Archmbox

Tracker: Bugs

5 fuser on sun solaris - ID: 1032616
Last Update: Comment added ( koitsu2009 )

There are a couple of problems with using archmbox on
the sun related to fuser.

fuser on solaris doesn't have the -s option.

fuser on solaris has the follow return values (as far
as I can tell!) 1 if the fuser fails and 0 it fuser
suceeds i.e. the return value doesn't indicate if the
file is in access.

I'm not very good at editing configure scripts but I
suggest you should check that the return value is as
expected before setting $FUSER. So open a file
(./configure itself?) and run $FUSER, then run $FUSER
on an unopened file and check that the return values
are as expected. If not move to the next one.


Michael Graham ( oobermick ) - 2004-09-22 13:00

5

Closed

Fixed

Nobody/Anonymous

None

all_versions

Public


Comments ( 11 )

Date: 2009-12-07 20:39
Sender: koitsu2009

My name is Jeremy Chadwick; you can put that in the credits or ChangeLog.
Thank you!


Date: 2009-12-06 16:04
Sender: adottiProject AdminAccepting Donations

Great, and thanks for the report about my stupid typo :)

If you have a name I can include in the credit files, I'll update it as
well.

ciao
alex


Date: 2009-11-23 10:27
Sender: koitsu2009

Oh, one other thing (unrelated to this bug/ticket):

The help usage for archmbox continually uses the word "treshold" instead
of "threshold". I'm not sure why that is, but it should get fixed. :-)


Date: 2009-11-23 10:23
Sender: koitsu2009

adotti,

I've tested my patch on Solaris. Yep, it works correctly.

Original mailbox:
-rw------- 1 jdc jdc 1288969 Nov 21 10:38 mail

$ ./archmbox -a -o 5 /home/jdc/test/mail

Mailbox '/home/jdc/test/mail': 110 messages (1.23 MB)
Archived: 89 messages (0.95 MB)

Archive mailbox: mail.archived

Result:

-rw------- 1 jdc jdc 288733 Nov 23 02:18 mail
-rw------- 1 jdc jdc 1000236 Nov 23 02:18 mail.archived


And now testing with a process that already has file "mail" opened ("less
mail" in this case):

{in window #0}
$ less mail

{in window #1}
$ fuser mail
mail: 28348o
$ ps -aef | grep 28348
jdc 28348 990 0 02:21:32 pts/208 0:00 less mail

$ ./archmbox -a -o 5 /home/jdc/test/mail

Mailbox /home/jdc/test/bin/mail is in use. Skipped!

$



Date: 2009-11-21 00:25
Sender: adottiProject AdminAccepting Donations

Hi koitsu, thank you very much for your report, your patch and you clear
explanation about fcntl... I know the way archmbox handle locks right now
is really silly, and I have planned to switch to fcntl yet, but
unfortunately I hadn't have the time to do it (and test it enough).

About the solaris issue, I don't have access to any solaris system so, if
you can test your changes for me I'll be happy to include your patch and
make a new release. Please let me know.

Thank you very much.

ciao
alex


Date: 2009-11-16 16:38
Sender: koitsu2009

It would help if I provided the patch, wouldn't it?

http://jdc.parodius.com/archmbox_solaris_fuser.diff


Date: 2009-11-16 16:34
Sender: koitsu2009

Here's the code which should make fuser fuser work on Solaris. Note that
conditions such as ENOENT (no such file) won't be handled; there's no way
to do that.

PLEASE NOTE: I have NOT tested this at this point. Yes, I have access to
many Solaris boxes, but I need to set up some test mailboxes to see how
things behave. I can also test on NFS.

The methodology archmbox uses here is silly; it shouldn't be relying on
external utilities for this. Consider reading about fcntl(3) with perl (I
recommend using this over flock(3) since fcntl(3) should work on NFS
mounts, while there's no guarantee with flock). Perl has the Fcntl module
(note the capital F).

http://perldoc.perl.org/functions/fcntl.html

What you should do is:

- Use fcntl() to set a read AND write lock on the original/source mailbox
file; this should cause your program to block (wait) until the file lock is
released (e.g. while another program is writing to it and has set the
lock). You can use O_NONBLOCK if you want your program to return an error
immediately (e.g. to skip over the file).

- Also use fcntl() to set a write lock on the destination mailbox file;
this ensures nothing else would try to write to the file while you're
populating it. This is an optional step, given that people (hopefully)
won't be trying to do write operations on the files archmbox is creating.
:-) Your decision.

- When finished on both files, clear both locks, and continue on to the
next mailbox.

This will be significantly faster than what you're doing now, which is
doing a fork() + exec() to /bin/sh, which then does fork() + exec() on the
command (fuser/lsof/fstat) to get you back data -- and much less error
prone.

Remember that relying on external utilities in perl is dangerous and
generally looked down; try to do everything natively in perl, and if you
have to use POSIX, then use it heavily. :-)


Date: 2009-11-16 15:41
Sender: koitsu2009

adotti, please revert this change. Requiring Solaris users to have lsof is
downright silly; most Solaris systems, believe it or not, will not have
this utility. Additionally, it's *incredibly* slow to use on a system with
many users or many processes; no offence, but think about it.

Solaris's fuser(1M) command will achieve what it is you're trying to do in
function mailbox_in_use(), and achieve such very quickly. You need to fix
your configure script + perl code to Do The Right Thing(tm) for Solaris.

I'll work on providing a patch for you.


Date: 2004-09-28 19:11
Sender: adottiProject AdminAccepting Donations

Logged In: YES
user_id=197334

Sure it helps :)

Thank you very much Michael... I'm going to write a note on
the website and update the documentation as well.


Date: 2004-09-27 10:25
Sender: oobermick

Logged In: YES
user_id=959020

lsof sets the return value as you program expects and as a
evil hack I got you program to work by changing the line in
configure from:

for ac_prog in fuser fstat lsof

to

for ac_prog in lsof fuser fstat

I hope this helps.


Date: 2004-09-23 19:48
Sender: adottiProject AdminAccepting Donations

Logged In: YES
user_id=197334

The big problem is not the lack of the -s option in Solaris'
version of fuser, but rather the return value, as you
mentioned in your bug report.

I have no Solaris box available to do some test myself, so I
kindly ask you to find a way (or a command) that helps to
determine if a file is in use or not by another process.

This is the starting point. I'll be really happy to tune
archmbox and add support for Sun Solaris.

Thanks for your report and thanks in advance for your help.


Attached File

No Files Currently Attached

Changes ( 4 )

Field Old Value Date By
artifact_group_id None 2004-09-28 19:13 adotti
status_id Open 2004-09-28 19:12 adotti
resolution_id None 2004-09-28 19:12 adotti
close_date - 2004-09-28 19:12 adotti