Philippe Elie wrote:
> On Tue, 02 Mar 2004 at 18:32 +0000, Will Cohen wrote:
>>I have reworked the patch for opcontrol to minimize the stuff done for
>>the user dump by factoring out code that is common betweeen the root and
>>normal user. I also removed the unneeded check of "OPROFILE_AVAILABLE"
>>in the data dump. The comment that check for the presences of the daemon
>>has be changed to reflect that the check doesn't verify that the daemon
>>is actually running.
>>The oproffs.patch changes the /dev/oprofile/dump to be world writeable.
>>The combination of the two patches should allow normal users to flush
>>- # make sure that the daemon is running
>>+ # make sure that the daemon is not dead and gone
>> if test -e "$DIR/lock"; then
>> OPROFILED_PID=`cat $DIR/lock`
>> if test ! -d "/proc/$OPROFILED_PID"; then
>>@@ -1073,14 +1084,14 @@
>> # find current time
>> TMPFILE=`mktemp /tmp/oprofile.XXXXXX` || exit 1
>> echo 1 > $MOUNT/dump
>>- # loop until there is a file to check
>>- while [ ! -e "$DIR/complete_dump" ]
>>- sleep 1;
>>- # loop until modification data of $MOUNT/dump after TMPFILE
>>- while [ "$TMPFILE" -nt "$DIR/complete_dump" ]
>>+ # loop until there is a file to check and
>>+ # the modification data of $MOUNT/dump after TMPFILE
>>+ while [ \( ! -e "$DIR/complete_dump" \) -a \( "$TMPFILE" -nt "$DIR/complete_dump" \) ]
> I think we need -o here else if complete_dump doesn't exists we silently
> do nothing.
Yes, -a should be -o.
>>+ if test ! -d "/proc/$OPROFILED_PID"; then
> here we know daemon was running (or a dangling lock file existed) can we
> add an.
> echo "dump fail: either daemon died during last run or dies during dump"
> in some case we can get twice error message but this is exceptional
> and usefull for us.
No problem giving additional details that oprofiled is no longer around.
>>+ rm $TMPFILE
>>+ return 1
>> sleep 1;
>> rm $TMPFILE
>>@@ -1092,6 +1103,18 @@
>> return 0;
>>+# returns 0 if successful
>>+# exits if unsuccessful
> if [ $OPROFILE_AVAILABLE != "yes" ]; then
> echo "dump: daemon not running, nothing to do"
> return 0
> I don"t remember if we can't do that here, in this case we know the daemon
> is running and can tweak error message by removing the one I suggested in
> do_dump and tweak the next echo.
>>+ if test $? -ne 0 -a "$ONLY_DUMP" = "yes"; then
>>+ echo "Unable to complete dump of oprofile data" >& 2
>>+ exit 1;
>>+ return 0;
>>+#determine which module is loaded
>>+ grep oprofilefs /etc/mtab >/dev/null
>>+ if test "$?" -eq 0; then
>>+ # need to have oprofilefs mounted for this to work on 2.6
>>+ # need to have /proc/oprof available for this to work on 2.4
>>+ grep oprof /proc/devices >/dev/null
>>+ if test "$?" -eq 0; then
>> # main
>> # determine the location of opcontrol and related programs
>>@@ -1252,8 +1292,17 @@
>> if test "$UID" != "0"; then
>>- echo "Must be root to use oprofile." >&2
>>+ if test "$1" = "--dump" -a -z "$2"; then
> We can't assume the kernel use the version allowing a user dump, we must
> test it else someone using 2.3 driver with 0.8.0 can get an access denied
> and loop forever in the wait for complete_dump change
I have added a check to make sure that the write to $MOUNT/dump was
>>+ exit 0;
>>+ echo "Normal users are limited to '--dump'." >&2
>> exit 1
> I've not checked if this will work with 2.4 (can we do a user dump with 2.4 ?)
All the Red Hat distro use a back port of the 2.6 mechanism, so I
haven't tried it on 2.4.