./fspy-0.1.1/0000755000175000017500000000000011141102402011371 5ustar e-axee-axe./fspy-0.1.1/LICENSE0000644000175000017500000000134211141102401012375 0ustar e-axee-axeCopyright (C) 2008-2009 Richard Sammet This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this package; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ./fspy-0.1.1/obj/0000755000175000017500000000000011141102402012143 5ustar e-axee-axe./fspy-0.1.1/obj/stating.o0000644000175000017500000000607011141102402013777 0ustar e-axee-axeELF4( UWVxD$D$$E@tt`trt`w1t t}t@ttttxbloc@k de@vice@ xchar@acte@r de@ vice@xdire@ctorf@yxFIFO@/pipf@erxsyml@ink]xregu@lar @file@ =xsockf@et@%E@%D$D$x$xppЍHU x׉ЁĠ^_]UWD$D$$} u'ED$ D$ D$$/E D$ED$ D$D$$E$E}uOED$$D$ D$/D$$$EUXD$T$ $7EHEEEbHE%=DžE%=@DžE%=u~DžE%=u`DžE%= uBDžxE%=`u'Dž]E%=u DžBEEED$DE$E}E$DžĔ_]Ux} uXED$E$t t $ECE%=@u E+E"E @%=@u EEEUE D$E$t!t$EEEfdspcboUNKNOWN: %u%s%s%sERROR: checktype()->statit() returned != TRUE! ,x'V'''''''' ''isdir()->stat()statit()->stat()GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2).symtab.strtab.shstrtab.rel.text.data.bss.rel.rodata.comment.note.GNU-stack4L %+40 <9(EaaU  8  $,6?FIMT[`gnsxystating.ctwhitelstgettypememsetsprintfchecktypesnprintfstrdupstatitstderrfwriteexitmemcpystrtokfreeisdir__errno_locationperrorstat&   -C ^t P8C[ .3HLPTX\`dhlptx|./fspy-0.1.1/obj/output.o0000644000175000017500000001000411141102402013656 0ustar e-axee-axeELFP4( UW`D$D$$`D$D$$EEE D$ED$ D$ D$`$E$EEXXHLEEEATT6TTE D$$ED$$`¸D$D$$E @`D$$D$$E D$$E @D$$uE @D$$ZE @ D$$?`¸D$D$$ED$`D$`$D$$E8$EEPPHEHE@u&ED$ ED$ED$$"ED$$kE@$EELLHEHE@u&ED$ ED$ED$$"ED$$EH$EEHHHEHE@ u&ED$ ED$ED$$"ED$$m$\\$EEDDHEHED$$ Eu4E@,‰ED$T$L$ ED$$)E@,D$T$$2E@u+E@‹ED$ T$ED$$7yE@D$$?^E@u+E@‹ED$ T$ED$$7(E@D$$? E@u)EPED$ T$ED$$CE@D$$KE@u+E@ ‹ED$ T$ED$$7E@ D$$?pE@ u*EP‹ED$ T$ED$$7;EPD$$?!E$ED$$EEED$OE$E}M$ E$_]%s%s%s%i%u0x%08x%s%s%s%s%lld%s%lld%s%ld%s%ld%s%lo%s%lo,4`2o$ tGCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2).symtab.strtab.shstrtab.rel.text.data.bss.rel.rodata.comment.note.GNU-stack4k p %+400 L <(EU0 @  p i k%,3BJPU]doutput.cprint_datamemsetsnprintfstrdupprintfget_event_descgettypectimetimeputcharstrtokfree% D KRk    A [ fk      &+ >    $) <   AF af     7< RW      /:S^TX\`dhlptx|  $(,./fspy-0.1.1/obj/fspy.o0000644000175000017500000003265411141102402013316 0ustar e-axee-axeELFh%4( U$$U(D$ D$ D$B D$wD$ D$D$$H $U]ÍL$qUWVSQؘ|gEEEEgD$D$$DžgEEEEEEEEEE|g8UxgxgIexgICxgDxgDxgtkxgA'BxgF0xgRxgRxgOxgTxgvg(g Džtg pgDžlgtgpglg(u$Em$E[$EI$E7$E%E$E E%gD$D$ T$|gFD$|g$E}#t%D$ D$ND$$ |g)Ɖ}E؉$EعhghgЍX$c@9sXE؉$Eȃ}~}c~1D$ cD$D$< $$E؉$1D$ cD$D$< $$}EйdgdgH=v)D$D$ $$EЉ$t1D$ D$@D$$ $EУ}EԹ`g`gH=v)D$D$($$Eԉ$t1D$ D$BD$$$Eԣ}E\g\gH=v)D$D$$$E$EuED$$t#EXgXgHv1D$ D$7D$$$D$P$E}iE$}tREܹTgTgH=D$D$T$$$E܃}u1D$ D$CD$$$E[,T,@], ,@d,:,@ p,f}EPgPgH=v)D$D$$$E$EuED$$t#ELgLgHv1D$ D$7D$$4$D$P$E}iE$E$EEtED$E܉$t#EHgHgHv1D$ D$oD$$l$D$P$E}jE$E$E$$E}u1D$ D$7D$$$$E}u1D$ D$9D$$$$XE}u1D$ D$2D$$P$D$t$u $EE$|gBDgDgH=v1D$ D$.D$$$|gB@g@gЍH|gBEljED$E$t1D$ D$*D$$$ED$E$uOE25c3version: %i.%i.%i build: %i codename: %s author: %s website: %s filterrecursivediffoutputtypeinvertedadaptiveverbosehelpversionF:R:O:T:I:D:AvhWARNING: running fspy without root permissions might affect normal operation! ERROR: value of argument '-R/--recursive' needs to be a number between %i and %i! ERROR: the filter string/regex (-F/--filter) need not to be longer than %i chars! ERROR: there is a problem with your string/regex (-F/--filter)! ERROR: the inverted filter string/regex (-I/--inverted) need not to be longer than %i chars! ERROR: there is a problem with your string/regex (-I/--inverted)! ERROR: the type string (-T/--type) need not to be longer than %i chars! ERROR: invalid type/format in type string (-T/--type)! ,ERROR: the output string (-O/--output) need not to be longer than %i chars! ERROR: could not allocate mem for tmp_output_string (-O/--output)! ERROR: the diff string (-D/--diff) need not to be longer than %i chars! ERROR: invalid type/format in type string (-D/--diff)! ERROR: diff string (-D/--diff) contains fields which are not contained within the output string (-O/--output)! ERROR: could not allocate mem for lpath (path_lookup)! ERROR: could not allocate mem for initial path variable! ERROR: could not allocate mem for statdat (main)! signal()ERROR: the given path/file string is to long! ERROR: main()->statit() returned != TRUE! |PATH_LOOKUP_ERROR|%s%s/inotify_rm_watch()GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2).symtab.strtab.shstrtab.rel.text.rel.data.bss.rodata.comment.note.GNU-stack4 -` ) % T5X /4<$(E%%UH'P  +\V!t/ >KR]hu 2 $+2AHO\s)1:Kfspy.cprint_helpprint_versionmy_sig_handlelong_opts.3659opt_str.3658siginttypestringdiffstringfilterstringifilterstringputsexitprintfmainmemsetoptargstrdupgetopt_longgeteuidstdoutfwriteoptindisnumbernumlenatoistderrfprintffreereg_compireg_comptwhitelststrstrstrtokmallocdbasewhitelistsignalperrorinotify_initgrab_max_element_countmax_element_countinit_free_wdsstatitisdirrecwrapinotify_add_watchelc_oareadstrcatpathlookupsnprintfreg_matchireg_matchchecktypeadaptive_checkdprintdiffingprint_datamemmovereg_destinotify_rm_watch__errno_location (08_dpy ]eow"+FKP| !" #!+3"?s!"$!!$,"8C%M!hmy!"&'2!MR^dmu}(#!")!,1=!"*' !',8>GOW(o#z'!    (1 #< A L #X )f !    ) !    ) !   & 2 +> C ,H -P .U /` 0e  !     % 1/ !J O [ m 2 3 46 5h 6 ' 5A 7a | 8  7   91 !;@La27:;<X=]k>t>y>~>>>>>>>>>>>>>>>>>?>@`A  B1C:DHM,Ya5q#|#### 0@P`p./fspy-0.1.1/obj/fsevents.o0000644000175000017500000000445011141102402014163 0ustar e-axee-axeELFT4( UWVxD$D$$EtttttGtttI/ttt@t@t ttttVtOtt vt Gt@QQt @t @%t@t@t@At@xfile@ was@ acc@ essef@dxfile@ was@ mod@ ifief@dxmeta@data@ cha@ nged@xǾlxǾPxfile@ was@ ope@ ned*xǾ6xfile@ was@ mov@ ed t@o Yxfile@ was@ cre@ ated@xfile@ was@ del@ eted@xself@ was@ del@ eted@exself@ was@ movf@ ed@<xǾL"xǾexfile@ was@ ign@ ored@xdir @was @crea@ tedxmeta@data@ cha@ nged@xdir @acce@ss (f@ 1)@fxdir @acce@ss (f@ 2)@@xdir @was @dele@ tedED$D$}x$xppЍHU x׉ЁĠ^_]writeable file was closedunwriteable file was closedfile was moved from Xbacking fs was unmountedevent queued overflowedUNKNOWN: %xGCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2).symtab.strtab.shstrtab.rel.text.data.bss.rodata.comment.note.GNU-stack4 @ %P+P0P8(AQ   * "fsevents.cget_event_descmemsetsprintf& `z ./fspy-0.1.1/obj/enumdirs.o0000644000175000017500000001252411141102402014155 0ustar e-axee-axeELF` 4( UWd}@D$$E}x*D$@ED$E$E$E$&$Ed_]U($ E}u1D$ D$4D$$0$EU D$E$E}u1D$ D$4D$$h$EU(E[EE@;E u;EEPED$T$ $EE9EvEEUWVD$D$$D$D$$EЍHUlj󤍅$E}u$DžjHHd_name to long! ...ERROR: grabdirs()->statit(): returned != TRUE ! /ERROR: max_user_watches (%i) reached! ERROR: grabdirs(): path to long! ERROR: grabdirs() returned NULL! GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2).symtab.strtab.shstrtab.rel.text.data.bss.rodata.comment.note.GNU-stack4  @ %< +< 0< 8 (A  Q  K %<AFKRWQahovmD%(09Aenumdirs.cmax_element_countelc_oagrab_max_element_countopenreadatoiperrorexitinit_listmallocstderrfwriteextend_listreallocpathlookupmemcpygrabdirsmemsetopendirreaddirstrcatstatitdiffstringdelc_oaisdirfilterstringreg_matchifilterstringireg_matchtypestringchecktypefprintfclosedirrecwrapinit_diff). Q \ hmy */;  GW\ 7RWc{(t*S !,"6#H$R%_%&     '!<AMu   (*)O     ;  O  c      ./fspy-0.1.1/obj/numlen.o0000644000175000017500000000133511141102402013623 0ustar e-axee-axeELF4( UE#MEgfffE)ȉEE}u׋EGCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2).symtab.strtab.shstrtab.text.data.bss.comment.note.GNU-stack4=!t't,t(5EL  =numlen.cnumlen./fspy-0.1.1/obj/isnumber.o0000644000175000017500000000151411141102402014150 0ustar e-axee-axeELF4( UE0EE%u EEEEuEEGCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2).symtab.strtab.shstrtab.rel.text.data.bss.comment.note.GNU-stack4X D%+0(9I   # Xisnumber.cisnumber__ctype_b_loc./fspy-0.1.1/obj/adaptive.o0000644000175000017500000000460411141102402014124 0ustar e-axee-axeELFL4( U(E$u1D$ D$9D$$$EE¡E9EvUWV EED$E$E1E¡tE¡E E9EvŃ}u@ED$ED$$EEE}ЍHEE UljEU EEU EB ^_]U}EWARNING: This should never happen!!!,jjjjj!jjj-jYjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjGCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2).symtab.strtab.shstrtab.rel.text.data.bss.rel.rodata.comment.note.GNU-stack4  % +4p0  <h (E  U   X  ) $07?FMRock+szdiff.cdbasewhitelistdelc_oainit_diffdprintmallocfelsptrstderrfwriteexitextend_diff_listreallocdiffingstrcmpstrdupputsstrtokfree     % * / 4 9 > C H M R W \ a f r w |   "V k      J   C v   o   >   Q mr  $(,048<@DHLPTX\`dhl./fspy-0.1.1/obj/regmatch.o0000644000175000017500000000266411141102402014125 0ustar e-axee-axeELF4( UD$ ED$$t$EEEUD$ ED$$t$ EEEUD$D$ D$ED$$t EEEUD$D$ D$ED$$u EEEU$reg_comp()ireg_comp()GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2).symtab.strtab.shstrtab.rel.text.data.bss.rodata.comment.note.GNU-stack44 Dp %h+h0h8(AQ0  c F  'FF1 5J?GJR [regmatch.creg_compreregcompperrorireg_compirereg_matchregexecireg_matchreg_destregfree  (- ^ c ns   ) ../fspy-0.1.1/Makefile0000644000175000017500000000230611141102402013032 0ustar e-axee-axe# This file is part of fspy # ######################### BUILD = $(shell date +%Y%m%d%H) #DEBUG = -g -D_DEBUG OPTS = -DMAJORVERSION=0 -DMINORVERSION=1 -DSUBMINORVERSION=1 -DBUILD=$(BUILD) -DCODENAME=\"25c3\" CFLAGS = -Wall SDIR = src/ ODIR = obj/ INSTBINDIR = /usr/local/bin SRCS = $(SDIR)fspy.c $(SDIR)enumdirs.c $(SDIR)fsevents.c $(SDIR)isnumber.c $(SDIR)stating.c $(SDIR)output.c $(SDIR)regmatch.c $(SDIR)numlen.c $(SDIR)adaptive.c $(SDIR)diff.c OBJS = $(ODIR)fspy.o $(ODIR)enumdirs.o $(ODIR)fsevents.o $(ODIR)isnumber.o $(ODIR)stating.o $(ODIR)output.o $(ODIR)regmatch.o $(ODIR)numlen.o $(ODIR)adaptive.o $(ODIR)diff.o CC = gcc LD = gcc LDFLAGS = DFLAGS = RM = /bin/rm PROG = fspy all: $(PROG) $(PROG): $(OBJS) $(LD) $(LDFLAGS) $(DFLAGS) $(DEBUG) $(OPTS) $(OBJS) -o $(PROG) $(ODIR)%.o: $(SDIR)%.c $(CC) $(CFLAGS) $(LDFLAGS) $(DFLAGS) $(DEBUG) $(OPTS) -c $< -o $(ODIR)$*.o install: cp $(PROG) $(INSTBINDIR)/$(PROG) clean: $(RM) $(PROG) $(ODIR)*.o # DO NOT DELETE THIS LINE -- make depend depends on it. fspy.o: fspy.h enumdirs.o: enumdirs.h fsevents.o: fsevents.h isnumber.o: isnumber.h stating.o: stating.h output.o: output.h regmatch.o: regmatch.h numlen.o: numlen.h adaptive.o: adaptive.h diff.o: diff.h ./fspy-0.1.1/README0000644000175000017500000000737611141102402012266 0ustar e-axee-axe FSpy (c) Richard Sammet (e-axe) http://mytty.org/fspy/ INTRODUCTION ------------ fspy is an easy to use linux filesystem activity monitoring tool which is meant to be small, fast and to handle system resources conservative. you can apply filters, use diffing and your own output format in order to get the best results. REQUIREMENTS (to be clarified) ------------ linux >= 2.6.13 (http://kernel.org) inotify stat glibc >= 2.4 COMPILE AND INSTALL ------------------- just type make to comile and make install to install the fspy binary to /usr/local/bin. EXAMPLES -------- fspy -R 2 -T f,d /etc/ this command will use /etc/ as its base dir with a recursive depth of 2, which means that all files and dirs (because of -T f,d) within /etc/*/*/* will be monitored. fspy -D s,A -O '[,T,], ,d,:,p,f, size: ,s, atime: ,A' /tmp/ will monitor /tmp/ for filesystem activities, print out the requested information (-O) and highlight changes of the size (s) and atime (A) of elements within /tmp/. try it, you will see it is as easy as 1,2,3 ;) MISC ---- have a look at the manpage: man 7 inotify especially interesting are the following files: /proc/sys/fs/inotify/max_queued_events /proc/sys/fs/inotify/max_user_instances /proc/sys/fs/inotify/max_user_watches BUGS & FEATURES --------------- drop me a line (or multiple) to richard[tod]sammet[ta]gmail[tod]com -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v2.0.9 (GNU/Linux) mQGiBEfp+9QRBACk0fpMU3+1ODvgeYONx+QEH9MiEoSbCK22md9hAGjeMmsTPboh b3kpBywg5k9j2beYzDL5FaTP1Fci6lbBkuTBMH5+H3liK9XTdDqGCGxr4R1pARlT hdqtJivcHVCc6FV++e74f9bcAeQNYs6qfqlCxTPn1zM8QT8FKZ1Ww6wRZwCg/XMf LRLpGmKV/x1L906OIJ9e/K8D/jOPY/xxc6u/3ytbH1kyYpUdBkgMskz2YvznBLFL qVMjT0sx17sNW7ia24oBWei9Sl2GeE2lpsgZ0qDWU4sMHIgbd3oiQimRkV/LWATi lZp0g8y43uXVYkAOabTWLTfVArS2sYMbuWikKSPryuy/DOndoUINEuTsZ9n0Jjyj FOPhA/9q5awfNkwL06885hSFvlVK/oUmviKqvI8XnB3Cg1eZzRfIAqEI+IV2IAGh BrJ2RHv6bX3ix8vYldX1LYnab5CeZSEtG9fPEy6Dshi/zfUYVG7QUkytOkNtLcFB eUZOepSRGddJnF2TvvcBnL8eTYcZjZkCJTyW1wnHRngjKQTXA7Q2UmljaGFyZCBT YW1tZXQgKGUtYXhlKSA8cmljaGFyZC5zYW1tZXRAZ29vZ2xlbWFpbC5jb20+iGYE ExECACYFAkfp+9QCGwMFCQeEzgAGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRDy 6IQSyfs793uoAKDtZjfch8XxdpfjqwtuUvK2kSo/ogCaAkraVudP0HCo2KeJnXuD UgM0//65BA0ER+n71BAQAMkeAvvmJLq3YmAf/xYOMUas3q+1HIWg0IDcZcMhkPQo YIP5BjqBk1M+icUr1cqsLKwUwRLyoS1uVusFbA27ikT39abp5fY94zkFS5cl5xVN byVCbKda6lpa4WHWa57eIz/4/BoWUcv34+pnh3dtP4GtPi0Z8HTLmCgOMV/QDY13 Kf1E1vaS1Cuo1nXcqCg1eoiDYP03mQibsa0u0w4VRbxpjVDtmXJXLNCOHPOyV8QQ 60usn0DHveDM9Mp623fSPZV7nOzUrT9sN0BIDNISN2kHLtSRsJ8ju3KOsHNTw60K qssj1LuMRJWHAm0RiS8tWHKL6YQegkIBOAFHAfk01BDcPOs3CwA1AQKyLrz7aO+w 1wKhWjqGbcj+onPrg3vn0BECibNbFSnTTwUSeMWllsQY54d01NVYL/9qHbMObsYb cgu6bOF7BIbh0Gs8iNNxeh9bTFAIIH7Y9iiN3DgFLW1gHMlfRJTP2ZUyNkyHFdcS UKELmyuxMq+R2/zYxcvLmUqpcD/kW+RE4blSgDTvk0CIYs6yFiYsSuGDI4RpOvnH 0qzrrTXwQyLwIX0sIkwX+tByoBLUH3YARlCDml7XRomzik0orhBqVR7qSHYlb1hc th2Wv1VkA++bFtf2Uh11zAnt030xt+T5iO/6Q3htTGDHcjag7IbjmWnO/vdR5Sab AAMGD/sFh7tozLXqgCrXiBHwvPT3Q/UEh+CdKCcSXKaepZCXl5ahN2b6kPi700Fm hcXNlRK4n3PoTSaCgcTx6WVKn8AqXR2W1mpStc2cxbCrODaR2fzuChVTMacsCzle nonI/tuFTiaVKXiNoVK2fX8WRJYmivmPpGz9Cp9YM3PylDGe4Z7BxVat83Yaa5DX 6jbFWCI8UNJ6W7eIa2EIIIqcfk0pYgfQkfgGEDLjdjJdmHo3MIE7g57hq19/nyfu 2y2+nPWtzXlKbNBkg/VeCNjNO2DDRnesp1Et68Wd2fnbLg0jqBGLjYXS8iPECPWi dwkHuptlY87xy7N6lCvU73iVr5rxBx49R11HEazNdbx1x0nF+Ht9Z37JDr+7qEWL ZFXKxWHgaUkHO23L0e+K5GSbzZQ5xcroYLeL9bfrsPd5kwAWjI4u1oyjBHWvxsiv kKgnmx61p/nZI0I1SAwc2DDEzBGIp20IAjox4GJkH2qX4SyffMxO+t3zb7lxZgFU PE7r0r5RXfL2NH5HpbUrLev4hBzlVLLA2cmMXj6gHJmw3fxdA3XQdH/zPIja0MDy t/sW7e5/owT8aiL6hboL7FiSgqLoPrC4Ru4FxfDnMG2LPqnxA4NFNjhaq3dIT8b1 3O096iJD7cdqggjnER+tek9zty4mLZIZQmNaz/3JVLl6WhWEUohPBBgRAgAPBQJH 6fvUAhsMBQkHhM4AAAoJEPLohBLJ+zv3tKoAoOR/0lcP/Q+7gSrpN8n64vJjpQu1 AKCXdZdSbpFPLJny+S7CKQ13CaVL7A== =+atq -----END PGP PUBLIC KEY BLOCK----- ./fspy-0.1.1/GPL_V_2.txt0000644000175000017500000004310311141102402013263 0ustar e-axee-axe GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. ./fspy-0.1.1/src/0000755000175000017500000000000011141102402012160 5ustar e-axee-axe./fspy-0.1.1/src/regmatch.c0000644000175000017500000000556611141102402014132 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #include #include #include #include #include "fspy.h" regex_t re; regex_t ire; int reg_comp(char *pattern) { if(regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_EESCAPE) != 0) { perror("reg_comp()"); return FALSE; } return TRUE; } int ireg_comp(char *pattern) { if(regcomp(&ire, pattern, REG_EXTENDED|REG_NOSUB|REG_EESCAPE) != 0) { perror("ireg_comp()"); return FALSE; } return TRUE; } int reg_match(const char *string) { if(regexec(&re, string, (size_t) 0, NULL, 0) != 0) { return FALSE; } return TRUE; } int ireg_match(const char *string) { if(!(regexec(&ire, string, (size_t) 0, NULL, 0) != 0)) { return FALSE; } return TRUE; } void reg_dest(void) { (void) regfree(&re); } ./fspy-0.1.1/src/fspy.c0000644000175000017500000004646211141102402013321 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #include #include #include #include #include #include #include #include #include #include #include "fspy.h" #include "enumdirs.h" #include "fsevents.h" #include "isnumber.h" #include "numlen.h" #include "regmatch.h" #include "output.h" #include "stating.h" #include "adaptive.h" #include "diff.h" /* setting the sig_exit check var. */ volatile sig_atomic_t sigint = 1; extern unsigned int max_element_count; /* from enumdirs.c */ extern unsigned int elc_oa; /* from enumdirs.c */ extern char twhitelst[]; /* from stating.c */ extern char dbasewhitelist[]; /* from diff.c */ extern struct diffprint dprint; char *typestring = NULL; char *diffstring = NULL; char *filterstring = NULL; char *ifilterstring = NULL; static void print_help(void) { printf( "Usage: fspy [options] [file/dir]\n" "\n" "Options:\n" " -F, --filter STRING/REGEX\ta string or regular expression which will be used to filter the output.\n" " \t(the regex will be matched against the whole path e.g. [/etc/passwd])\n" " -I, --inverted STRING/REGEX\tits the same like -F/--filter but inverted. you can combine both.\n" " \te.g. -F '.conf' -I 'wvdial.conf' will filter for files with \".conf\"\n" " \tin its name but without \"wvdial.conf\" in it.\n" " -R, --recursive NUMBER\tenables the recursive engine to look at a depth of NUMBER.\n" " -A, --adaptive \t\t(HIGHLY-EXPERIMENTAL) enables the adaptive mode. e.g. if new items will be added\n" " \t\twithin the path fspy will automatically add those items to the watch list.\n" " -D, --diff VALUE\t\t(EXPERIMENTAL) enables the diffing feature.\n" " \t\tVALUE may be a comma separated list of:\n" " \t\ts - element size (byte)\n" " \t\tA - last access time (e.g. Mon Jul 21 21:32:31 2008)\n" " \t\tM - last modification time (e.g. Mon Jul 21 21:32:31 2008)\n" " \t\tS - last status change time (e.g. Mon Jul 21 21:32:31 2008)\n" " \t\tO - permissions (octal)\n" " \t\tU - owner (uid)\n" " \t\tG - group (gid)\n" " \t\tI - inode number\n" " \t\tD - device id\n" " -T, --type VALUE\t\tspecifies the type of objects to look for.\n" " \t\tVALUE may be a comma separated list of:\n" " \t\tf - regular file\n" " \t\td - directory\n" " \t\ts - symlink\n" " \t\tp - FIFO/pipe\n" " \t\tc - character device\n" " \t\tb - block device\n" " \t\to - socket\n" " \t\tdefault is any.\n" " -O, --output VALUE\t\tspecifies output format.\n" " \t\tVALUE may be a comma separated list of:\n" " \t\tf - filename\n" " \t\tp - path\n" " \t\td - access description\n" " \t\tt - element type\n" " \t\ts - element size (byte)\n" " \t\tw - watch descriptor (inotify manpage)\n" " \t\tc - cookie (inotify manpage)\n" " \t\tm - access mask (inotify manpage | src/fsevents.h)\n" " \t\tl - len (inotify manpage)\n" " \t\tA - last access time (e.g. Mon Jul 21 21:32:31 2008)\n" " \t\tM - last modification time (e.g. Mon Jul 21 21:32:31 2008)\n" " \t\tS - last status change time (e.g. Mon Jul 21 21:32:31 2008)\n" " \t\tO - permissions (octal)\n" " \t\tU - owner (uid)\n" " \t\tG - group (gid)\n" " \t\tI - inode number\n" " \t\tD - device id\n" " \t\tT - date and time (for this event) (e.g. Tue Mar 25 09:23:16 CET 2008)\n" //" \t\ti - timestamp (for this event) (seconds since 1970-01-01 00:00:00 UTC)\n" //" \t\tu - nanoseconds (for this event) (000000000..999999999)\n" " \t\te.g.: '[,T,], ,d,:,p,f' would result in:\n" " \t\t'[Mon Sep 1 12:31:25 2008] file was opened:/etc/passwd'\n" " \t\t(take a look at the README).\n" //" -v, --verbose\t\t\tactivate verbose mode.\n" //" \t\t\tuse twice (-vv) or more for more verbose output\n" " -h, --help\t\t\tthis short help.\n" " --version\t\t\tversion information.\n" "\n" ); exit(EXIT_SUCCESS); } static void print_version(void) { printf( "version:\t %i.%i.%i\n" "build:\t\t %i\n" "codename:\t %s\n" "author:\t\t %s\n" "website:\t %s\n" , MAJORVERSION, MINORVERSION, SUBMINORVERSION, BUILD, CODENAME, AUTHOR, WEBSITE); exit(EXIT_SUCCESS); } static void my_sig_handle(int sig) { #ifdef _DEBUG fprintf(stderr, "caught SIGINT - shutting down!\n"); #endif sigint = 0; } int main(int argc, char **argv) { unsigned int fd, wd, cnt = 0, len = 0, i = 0; char buf[BUF_LEN], *path, *lpath = NULL; char pbuf[EVENT_SIZE + 4096]; char fpath[ELEMENT_SIZE * 2] = {0}; struct inotify_event *event; struct felement *lsptr; struct stat *statdat; int co, opt_idx = 0, verbose_lvl = 0, recursive_depth = 0; int adaptive = FALSE; char *tmp_filter_string = NULL, *tmp_ifilter_string = NULL; char *tmp_recursive_depth = NULL, *tmp_output_string = NULL; char *tmp_type_string = NULL, *tmp_diff_string = NULL, *tsp = NULL, *freeme; static const char *opt_str="F:R:O:T:I:D:Avh"; static struct option long_opts[]={ {"filter", required_argument, NULL, 'F'}, {"recursive", required_argument, NULL, 'R'}, {"diff", required_argument, NULL, 'D'}, {"output", required_argument, NULL, 'O'}, {"type", required_argument, NULL, 'T'}, {"inverted", required_argument, NULL, 'I'}, {"adaptive", no_argument, NULL, 'A'}, {"verbose", no_argument, NULL, 'v'}, {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 0 }, {0, 0, NULL, 0 } }; /* if no arguments are given... */ if(argc < 2) print_help(); while((co = getopt_long(argc, argv, opt_str, long_opts, &opt_idx)) != -1) { switch(co) { case 0: /* if this option sets a short opt, do nothing else now. */ if(long_opts[opt_idx].flag != 0) break; if(strcmp("version", long_opts[opt_idx].name) == 0) { print_version(); break; } case 'F': tmp_filter_string = strdup(optarg); break; case 'O': tmp_output_string = strdup(optarg); break; case 'D': tmp_diff_string = strdup(optarg); break; case 'T': tmp_type_string = strdup(optarg); break; case 'R': tmp_recursive_depth = strdup(optarg); break; case 'A': adaptive = TRUE; break; case 'I': tmp_ifilter_string = strdup(optarg); break; case 'v': verbose_lvl++; break; case 'h': default: print_help(); break; } } /* check which user calls "us" */ if(geteuid() != 0) { fprintf(stdout, "WARNING: running fspy without root permissions might affect normal operation!\n"); } /* if dir/file is missing */ if((argc-optind) < 1) print_help(); /* check the given recursive depth */ if(tmp_recursive_depth != NULL) { if(isnumber(tmp_recursive_depth) == TRUE && strlen(tmp_recursive_depth) < (numlen(MAXRECURDEPTH) + 1)) { recursive_depth = atoi(tmp_recursive_depth); if(recursive_depth < MINRECURDEPTH || recursive_depth > MAXRECURDEPTH) { fprintf(stderr, "ERROR: value of argument '-R/--recursive' needs to be a number between %i and %i!\n", MINRECURDEPTH, MAXRECURDEPTH); exit(EXIT_FAILURE); } free(tmp_recursive_depth); }else{ fprintf(stderr, "ERROR: value of argument '-R/--recursive' needs to be a number between %i and %i!\n", MINRECURDEPTH, MAXRECURDEPTH); exit(EXIT_FAILURE); } } /* check the given filter string */ if(tmp_filter_string != NULL) { if(strlen(tmp_filter_string) > MAXREGEXLEN) { fprintf(stderr, "ERROR: the filter string/regex (-F/--filter) need not to be longer than %i chars!\n", MAXREGEXLEN); exit(EXIT_FAILURE); }else{ if(reg_comp(tmp_filter_string) != TRUE) { fprintf(stderr, "ERROR: there is a problem with your string/regex (-F/--filter)!\n"); exit(EXIT_FAILURE); } filterstring = tmp_filter_string; } } /* check the given inverted filter string */ if(tmp_ifilter_string != NULL) { if(strlen(tmp_ifilter_string) > MAXREGEXLEN) { fprintf(stderr, "ERROR: the inverted filter string/regex (-I/--inverted) need not to be longer than %i chars!\n", MAXREGEXLEN); exit(EXIT_FAILURE); }else{ if(ireg_comp(tmp_ifilter_string) != TRUE) { fprintf(stderr, "ERROR: there is a problem with your string/regex (-I/--inverted)!\n"); exit(EXIT_FAILURE); } ifilterstring = tmp_ifilter_string; } } /* check the given type string */ if(tmp_type_string != NULL) { if(strlen(tmp_type_string) > MAXTYPELEN) { fprintf(stderr, "ERROR: the type string (-T/--type) need not to be longer than %i chars!\n", MAXTYPELEN); exit(EXIT_FAILURE); }else{ freeme = typestring = strdup(tmp_type_string); while((tsp = strtok(typestring, DELIM))) { if((strstr(twhitelst, tsp) == NULL) || (strlen(tsp) > 1)) { fprintf(stderr, "ERROR: invalid type/format in type string (-T/--type)!\n"); exit(EXIT_FAILURE); } typestring = NULL; } free(freeme); typestring = NULL; } } /* check the given output string */ if(tmp_output_string != NULL) { if(strlen(tmp_output_string) > MAXOUTSTRLEN) { fprintf(stderr, "ERROR: the output string (-O/--output) need not to be longer than %i chars!\n", MAXOUTSTRLEN); exit(EXIT_FAILURE); } }else{ if((tmp_output_string = malloc(MAXOUTSTRLEN * sizeof(char))) == NULL) { fprintf(stderr, "ERROR: could not allocate mem for tmp_output_string (-O/--output)!\n"); exit(EXIT_FAILURE); } sprintf(tmp_output_string, "%s", "[,T,], ,d,:,p,f"); } /* check the given diff string */ if(tmp_diff_string != NULL) { if(strlen(tmp_diff_string) > MAXDIFFSTRLEN) { fprintf(stderr, "ERROR: the diff string (-D/--diff) need not to be longer than %i chars!\n", MAXDIFFSTRLEN); exit(EXIT_FAILURE); }else{ freeme = diffstring = strdup(tmp_diff_string); while((tsp = strtok(diffstring, DELIM))) { if((strstr(dbasewhitelist, tsp) == NULL) || (strlen(tsp) > 1)) { fprintf(stderr, "ERROR: invalid type/format in type string (-D/--diff)!\n"); exit(EXIT_FAILURE); } diffstring = NULL; } free(freeme); freeme = diffstring = strdup(tmp_diff_string); tsp = NULL; while((tsp = strtok(diffstring, DELIM))) { if((strstr(tmp_output_string, tsp) == NULL) || (strlen(tsp) > 1)) { fprintf(stderr, "ERROR: diff string (-D/--diff) contains fields which are not contained within the output string (-O/--output)!\n"); exit(EXIT_FAILURE); } diffstring = NULL; } free(freeme); diffstring = strdup(tmp_diff_string); free(tmp_diff_string); } } if((lpath = malloc(ELEMENT_SIZE * sizeof(char))) == NULL) { fprintf(stderr, "ERROR: could not allocate mem for lpath (path_lookup)!\n"); exit(EXIT_FAILURE); } if((path = malloc(ELEMENT_SIZE * sizeof(char))) == NULL) { fprintf(stderr, "ERROR: could not allocate mem for initial path variable!\n"); exit(EXIT_FAILURE); } if((statdat = (struct stat *) malloc(sizeof(struct stat))) == NULL) { fprintf(stderr, "ERROR: could not allocate mem for statdat (main)!\n"); exit(EXIT_FAILURE); } /* setting the signal handler */ if(signal(SIGINT, my_sig_handle) == SIG_ERR) { perror("signal()"); } /* getting an inotify instance */ if((fd = inotify_init()) < 0) { perror("inotify_init()"); exit(EXIT_FAILURE); } //TODO: cleanup! error checks! plausibility checks! max_element_count = grab_max_element_count(); init_free_wds(fd); /* init the list which will hold the freed wds */ #ifdef _DEBUG printf("MAX_ELEMENTS: %i\n", max_element_count); #endif if(strlen((argv+optind)[0]) > ELEMENT_SIZE) { fprintf(stderr, "ERROR: the given path/file string is to long!\n"); exit(EXIT_FAILURE); }else{ memcpy(path, (argv+optind)[0], strlen((argv+optind)[0])); if(statit(path, statdat) != TRUE) { fprintf(stderr, "ERROR: main()->statit() returned != TRUE!\n"); exit(EXIT_FAILURE); } if(isdir(path, statdat) == TRUE) if(path[strlen(path)-1] != '/') strcat(path, "/"); } #ifdef _DEBUG printf("INIT_PATH: %s\n", path); #endif /* at this point we hand the dirty work over to the recursive directory parser */ lsptr = (struct felement *) recwrap(path, recursive_depth, statdat); while(cnt <= elc_oa) { #ifdef _DEBUG printf("ADDING: %s %i", (&lsptr[cnt])->path, cnt); #endif /* adding a watch */ if((wd = inotify_add_watch(fd, (&lsptr[cnt])->path, IN_ALL_EVENTS)) < 0) { perror("inotify_add_watch()"); exit(EXIT_FAILURE); } lsptr[cnt++].wd = wd; #ifdef _DEBUG printf(" wd: %i\n", lsptr[cnt-1].wd); #endif } /* loop unitl SIGINT arrives */ while(sigint) { /* reading inotify_event data from the given inotify instance */ if((len += read(fd, buf + len, BUF_LEN - len)) < 0) { perror("read()"); }else{ while(sigint) { if(len < EVENT_SIZE) { break; }else if(len >= EVENT_SIZE) { memset(pbuf, 0, EVENT_SIZE + 4096); memcpy(pbuf, buf, EVENT_SIZE); event = (struct inotify_event *) pbuf; if((event->len > 0) && ((EVENT_SIZE + event->len) <= len)) { memcpy(pbuf, buf, EVENT_SIZE + event->len); }else if((EVENT_SIZE + event->len) > len) { break; } } if((event->len == 0) && (elc_oa == 1)) { strcat(event->name, path); }else{ memset(lpath, 0, ELEMENT_SIZE); /* check if there is a path available for this element */ if(pathlookup(lpath, event->wd, lsptr) == FALSE) strcat(lpath, "|PATH_LOOKUP_ERROR|"); } memset(statdat, 0, sizeof(struct stat)); memset(fpath, 0, (ELEMENT_SIZE * 2)); snprintf(fpath, (ELEMENT_SIZE * 2), "%s%s", lpath, event->name); if(statit(fpath, statdat) != TRUE) { fprintf(stderr, "ERROR: main()->statit() returned != TRUE!\n"); exit(EXIT_FAILURE); } if(isdir(fpath, statdat) == TRUE) if(fpath[strlen(fpath)-1] != '/') strcat(fpath, "/"); if(((filterstring != NULL) ? (reg_match(fpath) == TRUE):TRUE) && ((ifilterstring != NULL) ? (ireg_match(fpath) == TRUE):TRUE) && ((typestring != NULL) ? (checktype(lpath, (struct inotify_event *) event, typestring, statdat) == TRUE):TRUE)) { if(adaptive == TRUE) adaptive_check(event->mask, fpath, lsptr, statdat, event->wd); if(diffstring != NULL) { dprint.s = dprint.A = dprint.M = dprint.S = dprint.O = dprint.U = dprint.G = dprint.G = dprint.I = dprint.D = 0; diffing(fpath, statdat, &dprint, diffstring); } /* TODO: change print_data to use fpath instead of lpath and assembling the fqp on its own */ print_data(tmp_output_string, (struct inotify_event *) event, lpath, statdat, &dprint); if(((len > EVENT_SIZE) && (event->len == 0)) || (len > (EVENT_SIZE + event->len) && (event->len > 0))) goto more; } memset(buf, 0, BUF_LEN); len = 0; break; more: memmove(buf, buf + (EVENT_SIZE + event->len), (len - (EVENT_SIZE + event->len))); memset(buf + (len - (EVENT_SIZE + event->len)), 0, BUF_LEN - (len - (EVENT_SIZE + event->len))); len = (len - (EVENT_SIZE + event->len)); } } } /* destroying regular expression element */ reg_dest(); #ifdef _DEBUG printf("elc_oa: %i\n", elc_oa); #endif /* destroying wd's */ for(i = 0 ; i <= elc_oa ; i++) { #ifdef _DEBUG printf("removing number -> %i wd -> %i\n", i ,lsptr[i].wd); #endif if(inotify_rm_watch(fd, lsptr[i].wd) != 0) { if(errno == EBADF) { perror("inotify_rm_watch()"); exit(EXIT_FAILURE); }else{ #ifdef _DEBUG fprintf(stderr, "WARNING: inotify_rm_watch(): Invalid argument: maybe a symlink issue?\n"); #endif } } } /* destroying element structure */ free(lsptr); /* freeing helpers */ free(statdat); free(tmp_output_string); free(lpath); free(path); #ifdef _DEBUG printf("safely shutting down...\n"); #endif return 0; } ./fspy-0.1.1/src/regmatch.h0000644000175000017500000000445411141102402014132 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #ifndef _REGMATCH_H #define _REGMATCH_H int reg_comp(char *pattern); int ireg_comp(char *pattern); int reg_match(const char *string); int ireg_match(const char *string); void reg_dest(void); #endif ./fspy-0.1.1/src/stating.h0000644000175000017500000000472311141102402014010 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #ifndef _STATING_H #define _STATING_H #include #include char *gettype(const char *fpath, char *ptr, struct stat *statdat); int checktype(const char *event_fpath, struct inotify_event *event, char *tstring, struct stat *statdat); int isdir(const char *path, struct stat *statdat); int statit(const char *path, struct stat *buf); #endif ./fspy-0.1.1/src/adaptive.c0000644000175000017500000001322711141102402014126 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #include #include #include #include /* definition of UINT_MAX */ #include #include /* struct stat */ #include #include "fspy.h" #include "fsevents.h" #include "adaptive.h" #include "enumdirs.h" /* needed for max_element_count */ #include "stating.h" extern unsigned int max_element_count; /* from enumdirs.c */ extern unsigned int elc_oa; /* from enumdirs.c */ unsigned int *free_wds; /* holds the freed wds - faster reuse */ unsigned int fd; /* module global - the inotify file descriptor */ void init_free_wds(unsigned int fdin) { unsigned int i; fd = fdin; if((free_wds = (unsigned int *) malloc(max_element_count * sizeof(unsigned int))) == NULL) { fprintf(stderr, "ERROR: could not allocate mem for initial free wds list!\n"); exit(EXIT_FAILURE); } for(i=0; i <= max_element_count; i++) { free_wds[i] = UINT_MAX; } #ifdef _DEBUG printf("INIT_FREE_WDS_LIST: %i\n", max_element_count); #endif } void adaptive_add(const char *path, struct felement *lsptr, struct stat *statdat) { unsigned int wd, i, id = UINT_MAX; if(isdir(path, statdat) != TRUE) return; /* searching the empty element list for a reusable entry */ for(i=0; i <= max_element_count; i++) { if(free_wds[i] != UINT_MAX) { id = free_wds[i]; break; } } if(id == UINT_MAX) id = ++elc_oa; #ifdef _DEBUG printf("ADDING: %s %i\n", path, elc_oa); #endif if((wd = inotify_add_watch(fd, path, IN_ALL_EVENTS)) < 0) { perror("inotify_add_watch()"); exit(EXIT_FAILURE); } memcpy((&lsptr[id])->path, path, strlen(path)); //memcpy(&lsptr[id].festat, statdat, sizeof(struct stat)); lsptr[id].id = id; lsptr[id].wd = wd; } void adaptive_delete(const char *path, struct felement *lsptr, unsigned int wd) { if(wd == 1) /* dirty workaround! */ return; unsigned int i, id; /* getting the element id */ for(i=0; i <= elc_oa; i++) { if(lsptr[i].wd == wd) { id = lsptr[i].id; break; } } #ifdef _DEBUG printf("removing wd -> %i path -> %s\n", wd, path); #endif if(inotify_rm_watch(fd, wd) != 0) { if(errno == EBADF) { perror("inotify_rm_watch()"); exit(EXIT_FAILURE); }else{ #ifdef _DEBUG fprintf(stderr, "WARNING: inotify_rm_watch(): Invalid argument: maybe a symlink issue?\n"); #endif } } /* adding the empty element list entry to the available entries list */ for(i=0; i <= max_element_count; i++) { if(free_wds[i] == UINT_MAX) { free_wds[i] = id; break; } } //elc_oa--; return; } int adaptive_action(int event_mask, const char *path, struct felement *lsptr, struct stat *statdat, unsigned int wd) { switch(event_mask) { case FSPY_IN_DIR_CREATE: adaptive_add(path, lsptr, statdat); break; /*case FSPY_IN_DIR_DELETE: adaptive_delete(path, wd); break;*/ case FSPY_IN_DELETE_SELF: adaptive_delete(path, lsptr, wd); break; /*case FSPY_IN_MOVE_SELF: break; case FSPY_IN_MOVED_FROM: adaptive_delete(path, lsptr, statdat); break; case FSPY_IN_MOVED_TO: adaptive_add(path, lsptr, statdat); break;*/ default : return FALSE; break; } return TRUE; /* foo */ } int adaptive_check(int event_mask, const char *path, struct felement *lsptr, struct stat *statdat, unsigned int wd) { if(event_mask & FSPY_IN_NEED_ACTION) { if(adaptive_action(event_mask, path, lsptr, statdat, wd) == TRUE) return TRUE; } return FALSE; } ./fspy-0.1.1/src/diff.h0000644000175000017500000000456611141102402013254 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #ifndef _DIFF_H #define _DIFF_H #ifndef DELIM #define DELIM "," #endif struct festat *init_diff(void); struct festat *extend_diff_list(struct festat *felsptr); void diffing(char *fpath, struct stat *statdat, struct diffprint *dprintptr, char *diffstring); #endif ./fspy-0.1.1/src/numlen.h0000644000175000017500000000424611141102402013635 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #ifndef _NUMLEN_H #define _NUMLEN_H int numlen(int nbr); #endif ./fspy-0.1.1/src/fsevents.c0000644000175000017500000000775111141102402014173 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #include #include #include "fsevents.h" char *get_event_desc(int event, char *ptr) { char desc[128]={0}; switch(event) { case FSPY_IN_ACCESS: sprintf(desc,"file was accessed"); break; case FSPY_IN_MODIFY: sprintf(desc, "file was modified"); break; case FSPY_IN_ATTRIB: sprintf(desc, "metadata changed"); break; case FSPY_IN_CLOSE_WRITE: sprintf(desc, "writeable file was closed"); break; case FSPY_IN_CLOSE_NOWRITE: sprintf(desc, "unwriteable file was closed"); break; case FSPY_IN_OPEN: sprintf(desc, "file was opened"); break; case FSPY_IN_MOVED_FROM: sprintf(desc, "file was moved from X"); break; case FSPY_IN_MOVED_TO: sprintf(desc, "file was moved to Y"); break; case FSPY_IN_CREATE: sprintf(desc, "file was created"); break; case FSPY_IN_DELETE: sprintf(desc, "file was deleted"); break; case FSPY_IN_DELETE_SELF: sprintf(desc, "self was deleted"); break; case FSPY_IN_MOVE_SELF: sprintf(desc, "self was moved"); break; case FSPY_IN_UNMOUNT: sprintf(desc, "backing fs was unmounted"); break; case FSPY_IN_Q_OVERFLOW: sprintf(desc, "event queued overflowed"); break; case FSPY_IN_IGNORED: sprintf(desc, "file was ignored"); break; case FSPY_IN_DIR_CREATE: sprintf(desc, "dir was created"); break; case FSPY_IN_DIR_ATTRIB: sprintf(desc, "metadata changed"); break; case FSPY_IN_DIR_ACCESS_1: sprintf(desc, "dir access (1)"); break; case FSPY_IN_DIR_ACCESS_2: sprintf(desc, "dir access (2)"); break; case FSPY_IN_DIR_DELETE: sprintf(desc, "dir was deleted"); break; default : sprintf(desc, "UNKNOWN: %x", event); } return memcpy(ptr, desc, strlen(desc)); } ./fspy-0.1.1/src/isnumber.h0000644000175000017500000000426111141102402014160 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #ifndef _ISNUMBER_H #define _ISNUMBER_H int isnumber(char *nbrstr); #endif ./fspy-0.1.1/src/isnumber.c0000644000175000017500000000447511141102402014162 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #include #include "fspy.h" #include "isnumber.h" int isnumber(char *nbrstr) { int i = 0; while(nbrstr[i] != '\0') { if(!isdigit(nbrstr[i])) return FALSE; i++; } return TRUE; } ./fspy-0.1.1/src/fsevents.h0000644000175000017500000001132311141102402014166 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #ifndef _FSEVENTS_H #define _FSEVENTS_H /* most of these are taken from linux/inotify.h */ /* File was accessed */ #define FSPY_IN_ACCESS 0x00000001 /* File was modified */ #define FSPY_IN_MODIFY 0x00000002 /* Metadata changed */ #define FSPY_IN_ATTRIB 0x00000004 /* Writtable file was closed */ #define FSPY_IN_CLOSE_WRITE 0x00000008 /* Unwrittable file closed */ #define FSPY_IN_CLOSE_NOWRITE 0x00000010 /* File was opened */ #define FSPY_IN_OPEN 0x00000020 /* File was moved from X */ #define FSPY_IN_MOVED_FROM 0x00000040 /* File was moved to Y */ #define FSPY_IN_MOVED_TO 0x00000080 /* Subfile was created */ #define FSPY_IN_CREATE 0x00000100 /* Subfile was deleted */ #define FSPY_IN_DELETE 0x00000200 /* Self was deleted */ #define FSPY_IN_DELETE_SELF 0x00000400 /* Self was moved */ #define FSPY_IN_MOVE_SELF 0x00000800 /* Backing fs was unmounted */ #define FSPY_IN_UNMOUNT 0x00002000 /* Event queued overflowed */ #define FSPY_IN_Q_OVERFLOW 0x00004000 /* File was ignored */ #define FSPY_IN_IGNORED 0x00008000 /* Generic close */ #define FSPY_IN_CLOSE (FSPY_IN_CLOSE_WRITE | FSPY_IN_CLOSE_NOWRITE) /* Generic move */ #define FSPY_IN_MOVE (FSPY_IN_MOVED_FROM | FSPY_IN_MOVED_TO) /* Dir was created */ #define FSPY_IN_DIR_CREATE 0x40000100 /* Metadata changed */ #define FSPY_IN_DIR_ATTRIB 0x40000004 /* Dir was accessed (1) */ #define FSPY_IN_DIR_ACCESS_1 0x40000010 /* Dir was accessed (2) */ #define FSPY_IN_DIR_ACCESS_2 0x40000020 /* Generic dir access */ #define FSPY_IN_DIR_ACCESS (FSPY_IN_DIR_ACCESS_1 |FSPY_IN_DIR_ACCESS_2) /* Dir was deleted */ #define FSPY_IN_DIR_DELETE 0x40000200 /* Generic all file events */ #define FSPY_IN_ALL_FILE_EVENTS (FSPY_IN_ACCESS | FSPY_IN_MODIFY | FSPY_IN_ATTRIB | FSPY_IN_CLOSE | \ FSPY_IN_OPEN | FSPY_IN_MOVE | FSPY_IN_CREATE | FSPY_IN_DELETE | \ FSPY_IN_DELETE_SELF | FSPY_IN_MOVE_SELF) /* Generic all dir events */ #define FSPY_IN_ALL_DIR_EVENTS (FSPY_IN_DIR_CREATE | FSPY_IN_DIR_ACCESS | FSPY_IN_DIR_DELETE | FSPY_IN_DIR_ATTRIB) /* Generic all special events */ #define FSPY_IN_ALL_SPECIAL (FSPY_IN_UNMOUNT | FSPY_IN_Q_OVERFLOW | FSPY_IN_IGNORED) /* Genereic action needed events */ #define FSPY_IN_NEED_ACTION (FSPY_IN_CREATE | FSPY_IN_DELETE | FSPY_IN_DELETE_SELF | FSPY_IN_MOVE_SELF | FSPY_IN_MOVED_FROM | FSPY_IN_MOVED_TO) /* Generic all events */ #define FSPY_IN_ALL (FSPY_IN_ALL_FILE_EVENTS | FSPY_IN_ALL_DIR_EVENTS | FSPY_IN_ALL_SPECIAL) char *get_event_desc(int event, char *ptr); #endif ./fspy-0.1.1/src/adaptive.h0000644000175000017500000000453311141102402014133 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #ifndef _ADAPTIVE_H #define _ADAPTIVE_H #include #include "fspy.h" void init_free_wds(unsigned int fdin); int adaptive_check(int event_mask, const char *path, struct felement *lsptr, struct stat *statdat, unsigned int wd); #endif ./fspy-0.1.1/src/stating.c0000644000175000017500000001402311141102402013775 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #include #include #include #include #include #include #include #include "fspy.h" #include "stating.h" #include "output.h" /* little helper variable... do not miss to update when more types are added! */ char twhitelst[] = "fdspcbo"; char *gettype(const char *fpath, char *ptr, struct stat *statdat) { char desc[128] = {0}; switch (statdat->st_mode & S_IFMT) { case S_IFBLK: sprintf(desc, "block device"); break; case S_IFCHR: sprintf(desc, "character device"); break; case S_IFDIR: sprintf(desc, "directory"); break; case S_IFIFO: sprintf(desc, "FIFO/pipe"); break; case S_IFLNK: sprintf(desc, "symlink"); break; case S_IFREG: sprintf(desc, "regular file"); break; case S_IFSOCK: sprintf(desc, "socket"); break; default: sprintf(desc, "UNKNOWN: %u", (statdat->st_mode & S_IFMT)); break; } return memcpy(ptr, desc, strlen(desc)); } int checktype(const char *event_fpath, struct inotify_event *event, char *tstring, struct stat *statdat) { char mychar; char *tstring_tmp, *mystr; char *freeme; struct stat sb; char fpath[ELEMENT_SIZE * 2] = {0}; /* because we call it from multiple locations... */ if(event == NULL) { snprintf(fpath, (ELEMENT_SIZE * 2), "%s", event_fpath); }else{ snprintf(fpath, (ELEMENT_SIZE * 2), "%s%s", event_fpath, event->name); } tstring_tmp = strdup(tstring); if(statdat == NULL) { if(statit(fpath, &sb) != TRUE) { fprintf(stderr, "ERROR: checktype()->statit() returned != TRUE!\n"); exit(EXIT_FAILURE); } }else{ memcpy(&sb, statdat, sizeof(struct stat)); } while((mystr = strtok(tstring_tmp, DELIM))) { if(strlen(mystr) == 1) { mychar = mystr[0]; /* ATTENTION: do not miss to update *twhitelst at the top of this file! */ switch(mychar) { case 'f': if((sb.st_mode & S_IFMT) == S_IFREG) return TRUE; break; case 'd': if((sb.st_mode & S_IFMT) == S_IFDIR) return TRUE; break; case 's': if((sb.st_mode & S_IFMT) == S_IFLNK) return TRUE; break; case 'p': if((sb.st_mode & S_IFMT) == S_IFIFO) return TRUE; break; case 'c': if((sb.st_mode & S_IFMT) == S_IFCHR) return TRUE; break; case 'b': if((sb.st_mode & S_IFMT) == S_IFBLK) return TRUE; break; case 'o': if((sb.st_mode & S_IFMT) == S_IFSOCK) return TRUE; break; default : /* TODO: not existant! we should check that at startup! */ break; } }else{ /* TODO: implement a startup check for this value... it should be of a type like this: a,b,c,d,e */ } freeme = tstring_tmp; tstring_tmp = NULL; } free(freeme); return FALSE; } int isdir(const char *path, struct stat *statdat) { struct stat sb; if(statdat == NULL) { #ifdef _DEBUG printf("isdir()->STATING: %s\n", path); #endif if(statit(path, &sb) != TRUE) { if(errno != 0) { perror("isdir()->stat()"); } return FALSE; } if(S_ISDIR(sb.st_mode)) return TRUE; return FALSE; } if(S_ISDIR(statdat->st_mode)) return TRUE; return FALSE; } int statit(const char *path, struct stat *buf) { #ifdef _DEBUG printf("statit()->STATING: %s\n", path); #endif /* TODO: add exception handling for all different types of errno's */ if(stat(path, buf) != 0) { if(errno == ENOENT) { #ifdef _DEBUG printf("WARNING: file \"%s\" does not exist (deleted?)!\n", path); #endif }else{ perror("statit()->stat()"); return FALSE; } } return TRUE; } ./fspy-0.1.1/src/enumdirs.c0000644000175000017500000002053611141102402014160 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #include #include #include #include #include #include #include #include #include #include #include "fspy.h" #include "enumdirs.h" #include "stating.h" #include "regmatch.h" #include "diff.h" extern char *typestring; /* from fspy.c */ extern char *diffstring; /* from fspy.c */ extern char *filterstring; /* from fspy.c */ extern char *ifilterstring; /* from fspy.c */ extern unsigned int delc_oa; /* from diff.c */ extern struct festat *felsptr; /* from diff.c */ unsigned int max_element_count = 0; /* maximum number of elements */ unsigned int elc_oa = 0; /* over all element counter */ /* ATTENTION: the max num. of elements must not be greater than /proc/sys/fs/inotify/max_user_watches */ int grab_max_element_count(void) { int fd; char buf[64]={0}; fd = open("/proc/sys/fs/inotify/max_user_watches", O_RDONLY); if(fd >= 0) { read(fd, buf, 64); }else{ perror("open()"); exit(EXIT_FAILURE); } return atoi(buf); } struct felement *init_list(void) { struct felement *lsptr; if((lsptr = (struct felement *) malloc(ELEMENT_INIT_COUNT * sizeof(struct felement))) == NULL) { fprintf(stderr, "ERROR: could not allocate mem for initial dir list!\n"); exit(EXIT_FAILURE); } #ifdef _DEBUG printf("INIT_LIST: %i\n", ELEMENT_INIT_COUNT); #endif return lsptr; } struct felement *extend_list(struct felement *lsptr) { if((lsptr = (struct felement *) realloc(lsptr, (elc_oa + ELEMENT_INIT_COUNT) * sizeof(struct felement))) == NULL) { fprintf(stderr, "ERROR: could not reallocate mem to extend dir list!\n"); exit(EXIT_FAILURE); } #ifdef _DEBUG printf("EXTEND_LIST: %i (%i)\n", elc_oa + ELEMENT_INIT_COUNT, (elc_oa + ELEMENT_INIT_COUNT) * sizeof(struct felement)); #endif return lsptr; } int pathlookup(char *lpath, unsigned int wd, struct felement *lsptr) { unsigned int cnt = 0; /* TODO: optimize this! there should be no need to copy that value - just point to it! */ while(cnt <= elc_oa) { if(lsptr[cnt].wd == wd) { memcpy(lpath, lsptr[cnt].path, ELEMENT_SIZE); return TRUE; } cnt++; } return FALSE; } struct felement *grabdirs(const char *initial_path, struct felement *lsptr, struct festat *felsptr) { DIR *dirfd; struct dirent *dp; struct stat tmp_stat; char path[ELEMENT_SIZE] = {0}; char ip_local[ELEMENT_SIZE] = {0}; memcpy(ip_local, initial_path, strlen(initial_path)); if((dirfd = (DIR *)opendir(ip_local)) == NULL) { perror("opendir()"); return NULL; } if(ip_local[strlen(ip_local)-1] != '/') strcat(ip_local, "/"); while(dirfd) { if((dp = readdir(dirfd)) != NULL) { /* TODO: optimize string handling */ memset(path, 0, ELEMENT_SIZE); if(strlen(ip_local) > ELEMENT_SIZE) { fprintf(stderr, "ERROR: grabdirs(): ip_local to long!\n"); exit(EXIT_FAILURE); }else{ strcat(path, ip_local); } if((strlen(dp->d_name) + strlen(ip_local)) > ELEMENT_SIZE) { fprintf(stderr, "ERROR: grabdirs(): ip_local + dp->d_name to long!\n"); exit(EXIT_FAILURE); }else{ strcat(path, dp->d_name); } if(!((strcmp(dp->d_name, "..") == 0) || (strcmp(dp->d_name, ".") == 0))) { if(statit(path, &tmp_stat) != TRUE) { fprintf(stderr, "ERROR: grabdirs()->statit(): returned != TRUE !\n"); exit(EXIT_FAILURE); } /* TODO: !!! add the elements to the diffing list!!! */ if(diffstring != NULL) { memcpy((&felsptr[delc_oa])->path, path, strlen(path)); memcpy(&felsptr[delc_oa].statdat, &tmp_stat, sizeof(struct stat)); felsptr[delc_oa].id = delc_oa; delc_oa++; } if(isdir(path, &tmp_stat) == TRUE) { if(path[strlen(path)-1] != '/') strcat(path, "/"); #ifdef _DEBUG printf("DIR: %s\n", path); #endif if(!((filterstring != NULL) ? (reg_match(path) == TRUE):TRUE) && ((ifilterstring != NULL) ? (ireg_match(path) == TRUE):TRUE) && ((typestring != NULL) ? (checktype(path, NULL, typestring, NULL) == TRUE):TRUE)) continue; if((elc_oa > 0) && (elc_oa % ELEMENT_SIZE == 0)) { lsptr = (struct felement *) extend_list(lsptr); } if(++elc_oa > max_element_count) { /* TODO: prop. we should just warn the user and stop grabbing dirs...? */ fprintf(stderr, "ERROR: max_user_watches (%i) reached!\n", max_element_count); exit(EXIT_FAILURE); }else{ if(strlen(path) > ELEMENT_SIZE) { fprintf(stderr, "ERROR: grabdirs(): path to long!\n"); exit(EXIT_FAILURE); }else{ memcpy((&lsptr[elc_oa])->path, path, strlen(path)); //memcpy(&lsptr[elc_oa].festat, &tmp_stat, sizeof(struct stat)); lsptr[elc_oa].id = elc_oa; #ifdef _DEBUG printf("ADDED DIR: %s AS: %i\n", path, elc_oa); #endif } } }else{ continue; } }else{ continue; } }else{ break; } } closedir(dirfd); return lsptr; } /* small an nasty recursion wrapper */ struct felement *recwrap(char *initial_path, int recursive_depth, struct stat *statdat) { int recnt; /* temp. recusrion counter */ int base, sticky, elc_oa_sticky; /* helper -> placemark */ struct felement *lsptr; struct festat *felsptr; lsptr = init_list(); if(diffstring != NULL) { felsptr = init_diff(); memcpy((&felsptr[delc_oa])->path, initial_path, strlen(initial_path)); memcpy(&felsptr[delc_oa].statdat, statdat, sizeof(struct stat)); lsptr[delc_oa].id = delc_oa; delc_oa++; } /* adding initial path */ memcpy((&lsptr[elc_oa])->path, initial_path, strlen(initial_path)); lsptr[elc_oa].id = elc_oa; if((recursive_depth == 0) || (isdir((&lsptr[elc_oa])->path, NULL) == FALSE)) return lsptr; for(base = elc_oa, recnt = 0; recnt < recursive_depth; recnt++, base++) { for(elc_oa_sticky = elc_oa, sticky = base; sticky <= elc_oa_sticky; sticky++) { if((lsptr = grabdirs((&lsptr[sticky])->path, lsptr, felsptr)) == NULL) { fprintf(stderr, "ERROR: grabdirs() returned NULL!\n"); exit(EXIT_FAILURE); } } } return lsptr; } ./fspy-0.1.1/src/enumdirs.h0000644000175000017500000000476111141102402014167 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #ifndef _ENUMDIRS_H #define _ENUMDIRS_H #include "fspy.h" #define ELEMENT_SIZE 1024 #define ELEMENT_INIT_COUNT 1024 #define DIFF_ELEMENT_INIT_COUNT 2048 #define NO_DIR NULL int grab_max_element_count(void); int pathlookup(); //struct felement *recwrap(); struct felement *recwrap(char *initial_path, int recursive_depth, struct stat *statdat); #endif ./fspy-0.1.1/src/output.h0000644000175000017500000000456711141102402013705 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #ifndef _OUTPUT_H #define _OUTPUT_H #include #include #ifndef DELIM #define DELIM "," #endif void print_data(char *mystrin, struct inotify_event *event, const char *event_fpath, struct stat *statdat, struct diffprint *dprint); #endif ./fspy-0.1.1/src/fspy.h0000644000175000017500000000653011141102402013316 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #ifndef _FSPY_H #define _FSPY_H #include /* required -> struct stat */ #include "enumdirs.h" /* needed -> ELEMENT_SIZE */ #define AUTHOR "Richard Sammet (e-axe) " #define WEBSITE "http://mytty.org/fspy/" #define TRUE 1 #define FALSE 0 /* how long could a regex be? */ #define MAXREGEXLEN 128 /* how long could a typestring be? */ #define MAXTYPELEN 128 /* how long could a output string be? */ #define MAXOUTSTRLEN 128 /* how long could a diff string be? */ #define MAXDIFFSTRLEN MAXOUTSTRLEN /* how deep you wanna look into your folder hirachie? */ #define MINRECURDEPTH 1 #define MAXRECURDEPTH 99 /* size of the event structure, not counting name */ #define EVENT_SIZE (sizeof(struct inotify_event)) /* reasonable guess as to size of 1024 events */ #define BUF_LEN (1024 * (EVENT_SIZE + 16)) typedef int boolean_t; struct felement { unsigned int id; unsigned int wd; char path[ELEMENT_SIZE]; }; struct festat { unsigned int id; char path[ELEMENT_SIZE]; struct stat statdat; }; struct diffprint { unsigned int s; unsigned int A; unsigned int M; unsigned int S; unsigned int O; unsigned int U; unsigned int G; unsigned int I; unsigned int D; }; #endif ./fspy-0.1.1/src/diff.c0000644000175000017500000001541511141102402013242 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #include #include #include #include #include #include #include #include "fspy.h" #include "output.h" #include "fsevents.h" #include "stating.h" /* the base of allowed diffable fields */ /* do not forget to modify this list as needed! */ char dbasewhitelist[] = "sAMSOUGID"; /* holds the fields to be printed colored */ struct diffprint dprint; /* holds all the needed data to perform a diff */ struct festat *felsptr; /* global diffing element counter */ unsigned int delc_oa = 0; struct festat *init_diff(void) { dprint.s = dprint.A = dprint.M = dprint.S = dprint.O = dprint.U = dprint.G = dprint.G = dprint.I = dprint.D = 0; if((felsptr = (struct festat *) malloc(DIFF_ELEMENT_INIT_COUNT * sizeof(struct festat))) == NULL) { fprintf(stderr, "ERROR: could not allocate mem for initial festat list!\n"); exit(EXIT_FAILURE); } #ifdef _DEBUG printf("INIT_FESTAT_LIST: %i\n", DIFF_ELEMENT_INIT_COUNT); #endif return felsptr; } struct festat *extend_diff_list(struct festat *felsptr) { if((felsptr = (struct festat *) realloc(felsptr, (delc_oa + DIFF_ELEMENT_INIT_COUNT) * sizeof(struct festat))) == NULL) { fprintf(stderr, "ERROR: could not reallocate mem to extend dir list!\n"); exit(EXIT_FAILURE); } #ifdef _DEBUG printf("EXTEND_DIFF_LIST: %i (%i)\n", delc_oa + DIFF_ELEMENT_INIT_COUNT, (delc_oa + DIFF_ELEMENT_INIT_COUNT) * sizeof(struct festat)); #endif return felsptr; } void diffing(char *fpath, struct stat *statdat, struct diffprint *dprintptr, char *diffstring) { char *mystrin_tmp; char *mystr; char mychar; char *freeme; unsigned int i, id; #ifdef _DEBUG printf("DIFFING: %s\n", fpath); #endif /* getting the element id */ for(i=0; i <= delc_oa; i++) { if(strcmp(felsptr[i].path, fpath) == 0) { id = felsptr[i].id; break; } } mystrin_tmp = strdup(diffstring); while((mystr = strtok(mystrin_tmp, DELIM))) { if(strlen(mystr) == 1) { mychar = mystr[0]; switch(mychar) { case 's': if(memcmp(&felsptr[i].statdat.st_size, &statdat->st_size, sizeof(off_t))) { dprintptr->s = 1; memcpy(&felsptr[i].statdat.st_size, &statdat->st_size, sizeof(off_t)); } break; case 'A': if(memcmp(&felsptr[i].statdat.st_atime, &statdat->st_atime, sizeof(time_t))) { dprintptr->A = 1; memcpy(&felsptr[i].statdat.st_atime, &statdat->st_atime, sizeof(time_t)); } break; case 'M': if(memcmp(&felsptr[i].statdat.st_mtime, &statdat->st_mtime, sizeof(time_t))) { dprintptr->M = 1; memcpy(&felsptr[i].statdat.st_mtime, &statdat->st_mtime, sizeof(time_t)); } break; case 'S': if(memcmp(&felsptr[i].statdat.st_ctime, &statdat->st_ctime, sizeof(time_t))) { dprintptr->S = 1; memcpy(&felsptr[i].statdat.st_ctime, &statdat->st_ctime, sizeof(time_t)); } break; case 'O': if(memcmp(&felsptr[i].statdat.st_mode, &statdat->st_mode, sizeof(mode_t))) { dprintptr->O = 1; memcpy(&felsptr[i].statdat.st_mode, &statdat->st_mode, sizeof(mode_t)); } break; case 'U': if(memcmp(&felsptr[i].statdat.st_uid, &statdat->st_uid, sizeof(uid_t))) { dprintptr->U = 1; memcpy(&felsptr[i].statdat.st_uid, &statdat->st_uid, sizeof(uid_t)); } break; case 'G': if(memcmp(&felsptr[i].statdat.st_gid, &statdat->st_gid, sizeof(gid_t))) { dprintptr->G = 1; memcpy(&felsptr[i].statdat.st_gid, &statdat->st_gid, sizeof(gid_t)); } break; case 'I': if(memcmp(&felsptr[i].statdat.st_ino, &statdat->st_ino, sizeof(ino_t))) { dprintptr->I = 1; memcpy(&felsptr[i].statdat.st_ino, &statdat->st_ino, sizeof(ino_t)); } break; case 'D': if(memcmp(&felsptr[i].statdat.st_dev, &statdat->st_dev, sizeof(dev_t))) { dprintptr->D = 1; memcpy(&felsptr[i].statdat.st_dev, &statdat->st_dev, sizeof(dev_t)); } break; default : printf("diffing()->WARNING: This should never happen!!!\n"); break; } } freeme = mystrin_tmp; mystrin_tmp = NULL; } free(freeme); } ./fspy-0.1.1/src/output.c0000644000175000017500000001354011141102402013667 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #include #include #include #include #include #include #include #include "fspy.h" #include "output.h" #include "fsevents.h" #include "stating.h" #include "diff.h" void print_data(char *mystrin, struct inotify_event *event, const char *event_fpath, struct stat *statdat, struct diffprint *dprint) { char *mystrin_tmp; char *mystr; char mychar; char desc_ptr[128] = {0}; char *ctp; char fpath[ELEMENT_SIZE * 2] = {0}; char *freeme; const char *const normal = "\033[0m"; const char *const marked = "\033[1;31m"; time_t currtime; snprintf(fpath, (ELEMENT_SIZE * 2), "%s%s", event_fpath, event->name); mystrin_tmp = strdup(mystrin); while((mystr = strtok(mystrin_tmp, DELIM))) { if(strlen(mystr) == 1) { mychar = mystr[0]; switch(mychar) { case 'f': printf("%s", event->name); break; case 'p': printf("%s", event_fpath); break; case 'd': memset(desc_ptr, 0, 128 * sizeof(char)); printf("%s", get_event_desc(event->mask, desc_ptr)); break; case 'w': printf("%i", event->wd); break; case 'c': printf("%u", event->cookie); break; case 'm': printf("0x%08x", event->mask); break; case 'l': printf("%u", event->len); break; case 't': memset(desc_ptr, 0, 128 * sizeof(char)); printf("%s", gettype(fpath, desc_ptr, statdat)); break; /* yeah, i know, thats some kind of dirty style ;) but i dont like the additional newline at EOL... */ case 'A': ctp = ctime(&statdat->st_atime); ctp[strlen(ctp) - 1] = '\0'; (dprint->A == 1)?printf("%s%s%s", marked, ctp, normal):printf("%s", ctp); break; case 'M': ctp = ctime(&statdat->st_mtime); ctp[strlen(ctp) - 1] = '\0'; (dprint->M == 1)?printf("%s%s%s", marked, ctp, normal):printf("%s", ctp); break; case 'S': ctp = ctime(&statdat->st_ctime); ctp[strlen(ctp) - 1] = '\0'; (dprint->S == 1)?printf("%s%s%s", marked, ctp, normal):printf("%s", ctp); break; case 'T': currtime = time(NULL); ctp = ctime(&currtime); ctp[strlen(ctp) - 1] = '\0'; printf("%s", ctp); break; case 's': (dprint->s == 1)?printf("%s%lld%s", marked, (long long int) statdat->st_size, normal):printf("%lld", (long long int) statdat->st_size); break; case 'U': (dprint->U == 1)?printf("%s%ld%s", marked, (long int) statdat->st_uid, normal):printf("%ld", (long int) statdat->st_uid); break; case 'G': (dprint->G == 1)?printf("%s%ld%s", marked, (long int) statdat->st_gid, normal):printf("%ld", (long int) statdat->st_gid); break; case 'O': (dprint->O == 1)?printf("%s%lo%s", marked, (unsigned long int) statdat->st_mode, normal):printf("%lo", (unsigned long int) statdat->st_mode); break; case 'I': (dprint->I == 1)?printf("%s%ld%s", marked, (long int) statdat->st_ino, normal):printf("%ld", (long int) statdat->st_ino); break; case 'D': (dprint->D == 1)?printf("%s%ld%s", marked, (long int) statdat->st_dev, normal):printf("%ld", (long int) statdat->st_dev); break; default : printf("%c", mychar); break; } }else{ printf("%s", mystr); } freeme = mystrin_tmp; mystrin_tmp = NULL; } printf("\n"); free(freeme); } ./fspy-0.1.1/src/numlen.c0000644000175000017500000000437011141102402013626 0ustar e-axee-axe/************************************************************************ * fspy - experimental POC linux filesystem activity monitor * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * it's based on the new linux kernel inotify interface (merged into * * the 2.6.13 linux kernel) * * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * this code was tested on 2.6.18.4 and newer kernels * ************************************************************************ * Copyright (C) 2007 Richard Sammet (e-axe) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * http://www.gnu.org/licenses/gpl.txt * ************************************************************************ * Contact, Bugs & Infos: * * richard.sammet@gmail.com * ************************************************************************ * Some infos: * * - tabstop size: * * set ts=2 * ************************************************************************/ #include "fspy.h" #include "numlen.h" int numlen(int nbr) { int i = 0; while(nbr != 0) { nbr = nbr / 10; i++; } return i; } ./fspy-0.1.1/fspy0000755000175000017500000010507211141102402012305 0ustar e-axee-axeELFЌ4Lu4 (444  TTT__ o   o  hhh QtdRtd o  e(/lib/ld-linux.so.2GNU %0(*- &'.,! )$"/ +#% +#."+,.)K9264?zi`] `!ECmzM.l%E<'E9:(TN+}D$ q=^XdL?;W1f%)2 >__gmon_start__libc.so.6_IO_stdin_usedexitreaddirsprintfoptindregexecperrorclosedirsignalputsregfreeinotify_rm_watchputcharreallocstrdupstrtokmemsetstrstr__errno_locationreadctimestdoutmemcpymallocstrcatopendir__ctype_b_locregcompoptargstderrinotify_initgetopt_longfwritegeteuidatoiopenfprintfinotify_add_watchmemmovestrcmp__libc_start_mainsnprintf__xstatGLIBC_2.4GLIBC_2.3GLIBC_2.3.4GLIBC_2.0ii ii ti ii .-+/   $ ( , 0 48<@DHLPTX\`dhlptx| !"#$%&'()*U?=5%%h%h%h% h%h %h(%h0%h8p% h@`%$hHP%(hP@%,hX0%0h` %4hh%8hp%<hx%@h%Dh%Hh%Lh%Ph%Th%Xh%\hp%`h`%dhP%hh@%lh0%ph %th%xh%|h%h%h%h%h%h %h(%h0%h8p%h@`%hHP1^PTRhhQVhUS[btnX[ÐU=t ҡuUtt $ÐU$$U(D$D$D$.D$wD$ D$D$$4$U]ÍL$qUWVSQؘ|gEEEEgD$D$$yDžgEEEEEEEEEE|g8UxgxgIexgICxgDxgDxgtkxgA'BxgF0xgRxgRxgOxgTxgvggDžtgpgDžlgtgpglg(u$Em$E[$wEI$eE7$SE%E$8E E%gD$D$ T$|gFD$|g$E}#t%D$ D$ND$$|g)Ɖ}E؉$\EعhghgЍX$ck*@9sXE؉$_Eȃ}~}c~1D$ cD$D$($[$/E؉$1D$ cD$D$($$}EйdgdgH=v)D$D$|$$EЉ$F(t1D$ D$@D$$t$XEУ}EԹ`g`gH=v)D$D$$$$Eԉ$'t1D$ D$BD$$t$Eԣ}E\g\gH=v)D$D$$$WE$  EuED$$Zt#EXgXgHv1D$ D$7D$$$  D$<$#E}iE$  }tREܹTgTgH=D$D$@$e$9$}E܃}u1D$ D$CD$$$E[,T,@], ,@d,:,@ p,f}EPgPgH=v)D$D$$$}E$BEuED$$t#ELgLgHv1D$ D$7D$$ $D$<$IE}iE$1E$EEtED$E܉$t#EHgHgHv1D$ D$oD$$XR$6D$<$E}jE$oE$E$T$(E}u1D$ D$7D$$$$E}u1D$ D$9D$$t$X$XE}u1D$ D$2D$$<.$D$$u $o=EdE$#|gBDgDgH=v1D$ D$.D$$x$j|gB@g@gЍH|gBEljED$E$t1D$ D$*D$$$ED$E$;uOE25c3version: %i.%i.%i build: %i codename: %s author: %s website: %s filterrecursivediffoutputtypeinvertedadaptiveverbosehelpversionF:R:O:T:I:D:AvhWARNING: running fspy without root permissions might affect normal operation! ERROR: value of argument '-R/--recursive' needs to be a number between %i and %i! ERROR: the filter string/regex (-F/--filter) need not to be longer than %i chars! ERROR: there is a problem with your string/regex (-F/--filter)! ERROR: the inverted filter string/regex (-I/--inverted) need not to be longer than %i chars! ERROR: there is a problem with your string/regex (-I/--inverted)! ERROR: the type string (-T/--type) need not to be longer than %i chars! ERROR: invalid type/format in type string (-T/--type)! ,ERROR: the output string (-O/--output) need not to be longer than %i chars! ERROR: could not allocate mem for tmp_output_string (-O/--output)! ERROR: the diff string (-D/--diff) need not to be longer than %i chars! ERROR: invalid type/format in type string (-D/--diff)! ERROR: diff string (-D/--diff) contains fields which are not contained within the output string (-O/--output)! ERROR: could not allocate mem for lpath (path_lookup)! ERROR: could not allocate mem for initial path variable! ERROR: could not allocate mem for statdat (main)! signal()ERROR: the given path/file string is to long! ERROR: main()->statit() returned != TRUE! |PATH_LOOKUP_ERROR|%s%s/inotify_rm_watch()/proc/sys/fs/inotify/max_user_watchesopen()ERROR: could not allocate mem for initial dir list! ERROR: could not reallocate mem to extend dir list! opendir()ERROR: grabdirs(): ip_local to long! ERROR: grabdirs(): ip_local + dp->d_name to long! ...ERROR: grabdirs()->statit(): returned != TRUE ! /ERROR: max_user_watches (%i) reached! ERROR: grabdirs(): path to long! ERROR: grabdirs() returned NULL! writeable file was closedunwriteable file was closedfile was moved from Xbacking fs was unmountedevent queued overflowedUNKNOWN: %xUNKNOWN: %u%s%s%sERROR: checktype()->statit() returned != TRUE! ,z˲˲˲˲˲˲˲˲˲\˲˲>isdir()->stat()statit()->stat()%s%s%s%i%u0x%08x%s%s%s%s%lld%s%lld%s%ld%s%ld%s%lo%s%lo,$P"_~ϵdreg_comp()ireg_comp()ERROR: could not allocate mem for initial free wds list! inotify_rm_watch()ERROR: could not allocate mem for initial festat list! ERROR: could not reallocate mem to extend dir list! diffing()->WARNING: This should never happen!!!,AMy"  o  P(o4oo҇ *:JZjzʊڊ *:JZjzʋڋ *:JZjz|FRDOTIAvhfdspcbosAMSOUGIDGCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2).symtab.strtab.shstrtab.interp.note.ABI-tag.gnu.hash.dynsym.dynstr.gnu.version.gnu.version_r.rel.dyn.rel.plt.init.text.fini.rodata.eh_frame.ctors.dtors.jcr.dynamic.got.got.plt.data.bss.commentTT#hh 5\1o4; CKo҇`Xo44Pg (p P y t Ќ :GG_  ooo  ooop q qpty - TTh҇4    Ќ   p V ! />KValv     4*z:m F`Y i qЌ x   `!%0CBJg`2 nQ x[$ l `2" z I )̾S 8E@ H0 WJ a%tE<% л ( F $| '.ܿo ?ak O\g l9~k   (= N}$ "4 >K F$M=i{2J XLX ` ? \F % +2;FWX1p%  W 2  fspy.cprint_helpprint_versionmy_sig_handlelong_opts.3659opt_str.3658enumdirs.cfsevents.cisnumber.cstating.coutput.cregmatch.cnumlen.cadaptive.cdiff.c_GLOBAL_OFFSET_TABLE___init_array_end__init_array_start_DYNAMICdata_start__errno_location@@GLIBC_2.0recwrapsprintf@@GLIBC_2.0open@@GLIBC_2.0extend_listregfree@@GLIBC_2.0__libc_csu_finigettype_startelc_oasignal@@GLIBC_2.0__xstat@@GLIBC_2.0__gmon_start__free_wds_Jv_RegisterClasses_fp_hwrealloc@@GLIBC_2.0_finiputchar@@GLIBC_2.0filterstringregexec@@GLIBC_2.3.4diffstringmemset@@GLIBC_2.0felsptr__libc_start_main@@GLIBC_2.0__statinit_listadaptive_addpathlookupstatread@@GLIBC_2.0perror@@GLIBC_2.0max_element_countreaddir@@GLIBC_2.0_IO_stdin_usedtypestringtwhitelststatitfree@@GLIBC_2.0optind@@GLIBC_2.0adaptive_check__data_startreget_event_descreg_matchregcomp@@GLIBC_2.0opendir@@GLIBC_2.0getopt_long@@GLIBC_2.0__ctype_b_loc@@GLIBC_2.3grabdirsfdinit_free_wdsgrab_max_element_countsigintireg_compdelc_oareg_deststderr@@GLIBC_2.0memcpy@@GLIBC_2.0extend_diff_listadaptive_action__dso_handle__libc_csu_initprintf@@GLIBC_2.0ctime@@GLIBC_2.0print_datainit_diffatoi@@GLIBC_2.0numlenclosedir@@GLIBC_2.0fwrite@@GLIBC_2.0fprintf@@GLIBC_2.0strstr@@GLIBC_2.0time@@GLIBC_2.0__bss_startmalloc@@GLIBC_2.0checktypediffingdprintinotify_rm_watch@@GLIBC_2.4strtok@@GLIBC_2.0ireg_matchmemmove@@GLIBC_2.0strcat@@GLIBC_2.0isnumber_endstdout@@GLIBC_2.0puts@@GLIBC_2.0ireinotify_add_watch@@GLIBC_2.4ifilterstringoptarg@@GLIBC_2.0reg_compisdir_edatasnprintf@@GLIBC_2.0strdup@@GLIBC_2.0inotify_init@@GLIBC_2.4strcmp@@GLIBC_2.0dbasewhitelistadaptive_deleteexit@@GLIBC_2.0__i686.get_pc_thunk.bxmain_initgeteuid@@GLIBC_2.0./fspy-0.1.1/GPL_V_3.txt0000644000175000017500000010451311141102402013267 0ustar e-axee-axe GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read .