Package: libfam-dev Version: 2.7.0-6 Hi, i've been trying out fam, and i noticed a couple of bugs in man 3 fam, 3 of them of normal severity, the rest minor or wishlist, i think. Here they are :
* functions FAMMonitor* take an argument 'void* userData', but it is not described in this manpage. * manpage says that struct FAMEvent's member fr has type FAMRequest, but the compiler disagrees (and it's not a pointer to a FAMRequest either). * i noticed that famd can report multiple change events for a single change, atleast that's what i saw when i saved a modified file with xemacs, while simply touch-ing the file resulted in only one event ; maybe it repors changes in filesize and modificationtime separately ? In that case, it could be usefull to document that in the manpage. * manpage says, in description of FAMOpen/FAMClose, that "Variable char* appName should be set to name of your application.", however, there is no such variable (at least it is not described in this manpage). * if i can believe the description in the manpage, FAMSuspend/ResumeMonitor are completely superfluous, as they have identical result to simply not requesting events. * error-reporting is completely broken, according to this manpage, and there is no mention of what kind of errors could occur, which makes it kinda difficult to decide how to work around it. * it seems only way to get events in a non-blocking way is to set an alarm ; but what if alarm goes off while app is receiving an event ? does this break things or is it atomical ? * see also refers to fstat(1), which doesn't exist because man fstat is in section 2; not really a big problem, but it makes my 'mkmyman' script fail to find it's whatis. * it doesnt include any examples ; if it had, i wouldn't have had to write my testprogram, so i'm attaching that in case you would like to include it. thanks for maintaining fam, it does work :-) have fun ! Siward de Groot <home.wanadoo.nl/siward>
/* famonitor.c : use fam to tell famd to monitor a file or directory , and print results */ /* compile with : cc -lfam famonitor.c -o famonitor */ /* use as : famonitor <filename> */ /* this is a testprogram to test fam, intended to be usable for copy&paste */ #include <stdio.h> /* printf */ #include <fam.h> #include <sys/stat.h> /* stat */ void e( char * pc ){ printf("ERROR: fomonitor: %s\n", pc ); } void ex( char * pc ){ e(pc); exit(0); } char * codename( int code ){ switch( code ){ case FAMChanged : return( "FAMChanged" ); case FAMDeleted : return( "FAMDeleted" ); case FAMStartExecuting : return( "FAMStartExecuting" ); case FAMStopExecuting : return( "FAMStopExecuting" ); case FAMCreated : return( "FAMCreated" ); case FAMMoved : return( "FAMMoved" ); case FAMAcknowledge : return( "FAMAcknowledge" ); case FAMExists : return( "FAMExists" ); case FAMEndExist : return( "FAMEndExist" ); default : return( "invalid code" ); } } int main( int ARGC, char * ARGV[] ){ char * filename ; struct stat stats ; int ck ; int isdir ; FAMConnection * pfc ; FAMRequest fr ; FAMRequest * pfr = &fr ; FAMEvent fe ; int count ; if( ARGC != 2 ){ ex("you must supply one filename argument"); } filename = ARGV[1] ; if( *filename != '/' ){ ex("filename argument must be fully qualified"); } ck = stat( filename, &stats ); if( ck != 0 ){ ex("filename specified as argument does not exist"); } isdir = S_ISDIR( stats.st_mode ); if( (! isdir) && (! S_ISREG( stats.st_mode) ) ){ ex("file is neither a regular file nor a directory"); } /* input is ok, now connect to famd */ ck = FAMOpen( pfc ); if( ck != 0 ){ ex("can't connect to famd"); } else { printf("i have been given filedescriptor %d for this connection\n", pfc->fd ); } if( isdir ){ ck = FAMMonitorDirectory( pfc, filename, pfr, NULL ); } else { ck = FAMMonitorFile( pfc, filename, pfr, NULL ); } if( ck != 0 ){ e("famd refuses to monitor this file"); FAMClose(pfc); exit(0); } else { printf("i have been given requestnumber %d\n", pfr->reqnum ); } for( count=0 ; count < 10 ; count++ ){ ck = FAMNextEvent( pfc, &fe ); if( ck < 0 ){ e("FAMNextEvent reports lack of success"); continue ; } printf("famonitor: received event :\n"); if( fe.fc != pfc ){ e("wrong connection"); } /* if( fe.fr != pfr ){ e("wrong request"); } */ printf(" hostname = %s\n", fe.hostname ); printf(" filename = %s\n", fe.filename ); if( fe.userdata != NULL ){ e("wrong userdata"); } printf(" code = %d (%s)\n", fe.code, codename(fe.code) ); } ck = FAMCancelMonitor( pfc, pfr ); if( ck != 0 ){ e("FAMCancelMonitor() returned 'failed'"); } else { printf("successfully canceled monitor\n"); } ck = FAMClose( pfc ); if( ck != 0 ){ e("FAMClose() returned 'failed'"); } else { printf("successfully closed connection to famd\n"); } return(0); }