Annotation of fam/fam/Interest.h, Revision 1.1
1.1 ! trev 1: // Copyright (C) 1999 Silicon Graphics, Inc. All Rights Reserved.
! 2: //
! 3: // This program is free software; you can redistribute it and/or modify it
! 4: // under the terms of version 2 of the GNU General Public License as
! 5: // published by the Free Software Foundation.
! 6: //
! 7: // This program is distributed in the hope that it would be useful, but
! 8: // WITHOUT ANY WARRANTY; without even the implied warranty of
! 9: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, any
! 10: // license provided herein, whether implied or otherwise, is limited to
! 11: // this program in accordance with the express provisions of the GNU
! 12: // General Public License. Patent licenses, if any, provided herein do not
! 13: // apply to combinations of this program with other product or programs, or
! 14: // any other product whatsoever. This program is distributed without any
! 15: // warranty that the program is delivered free of the rightful claim of any
! 16: // third person by way of infringement or the like. See the GNU General
! 17: // Public License for more details.
! 18: //
! 19: // You should have received a copy of the GNU General Public License along
! 20: // with this program; if not, write the Free Software Foundation, Inc., 59
! 21: // Temple Place - Suite 330, Boston MA 02111-1307, USA.
! 22:
! 23: #ifndef Interest_included
! 24: #define Interest_included
! 25:
! 26: #include <sys/stat.h>
! 27: #include <sys/types.h>
! 28: #include <sys/time.h>
! 29: #include <netinet/in.h> // for in_addr
! 30:
! 31: #include "Boolean.h"
! 32:
! 33: class Event;
! 34: class FileSystem;
! 35: class IMon;
! 36: struct stat;
! 37:
! 38: // Interest -- abstract base class for filesystem entities of interest.
! 39: //
! 40: // An Interest is monitored by imon or, if imon fails, it is polled
! 41: // by the Pollster.
! 42: //
! 43: // All Interests are kept in a global table keyed by dev/ino.
! 44: //
! 45: // The classes derived from Interest are...
! 46: //
! 47: // ClientInterest an Interest a Client has explicitly monitored
! 48: // Directory a directory
! 49: // File a file
! 50: // DirEntry an entry in a monitored directory
! 51:
! 52: class Interest {
! 53:
! 54: public:
! 55:
! 56: enum ExportVerification { VERIFY_EXPORTED, NO_VERIFY_EXPORTED };
! 57:
! 58: Interest(const char *name, FileSystem *, in_addr host, ExportVerification);
! 59: virtual ~Interest();
! 60:
! 61: const char *name() const { return myname; }
! 62: bool exists() const { return old_stat.st_mode != 0; }
! 63: bool isdir() const { return (old_stat.st_mode & S_IFMT) == S_IFDIR; }
! 64: virtual bool active() const = 0;
! 65: bool needs_scan() const { return scan_state != OK; }
! 66: void needs_scan(bool tf) { scan_state = tf ? NEEDS_SCAN : OK; }
! 67: void mark_for_scan() { needs_scan(true); }
! 68: virtual bool do_scan();
! 69: void report_exec_state();
! 70:
! 71: virtual bool scan(Interest * = 0) = 0;
! 72: virtual void unscan(Interest * = 0) = 0;
! 73: void poll() { scan(); }
! 74:
! 75: // Public Class Method
! 76:
! 77: static void imon_handler(dev_t, ino_t, int event);
! 78:
! 79: static void enable_xtab_verification(bool enable);
! 80:
! 81: protected:
! 82:
! 83: bool do_stat();
! 84: virtual void post_event(const Event&, const char * = NULL) = 0;
! 85: char& ci_bits() { return ci_char; }
! 86: char& dir_bits() { return dir_char; }
! 87: const char& ci_bits() const { return ci_char; }
! 88: const char& dir_bits() const { return dir_char; }
! 89: const in_addr& host() const { return myhost; }
! 90: void verify_exported_to_host();
! 91: bool exported_to_host() const { return mypath_exported_to_host; }
! 92:
! 93: private:
! 94:
! 95: enum { HASHSIZE = 257 };
! 96: enum ScanState { OK, NEEDS_SCAN };
! 97: enum ExecState { EXECUTING, NOT_EXECUTING };
! 98:
! 99: // Instance Variables
! 100:
! 101: Interest *hashlink;
! 102: dev_t dev;
! 103: ino_t ino;
! 104: char *const myname;
! 105: ScanState scan_state: 1;
! 106: ExecState cur_exec_state: 1;
! 107: ExecState old_exec_state: 1;
! 108: char ci_char;
! 109: char dir_char;
! 110: struct stat old_stat;
! 111: in_addr myhost;
! 112: bool mypath_exported_to_host;
! 113:
! 114:
! 115: // Private Instance Methods
! 116:
! 117: bool dev_ino(dev_t, ino_t);
! 118: void revoke();
! 119: virtual void notify_created(Interest *) = 0;
! 120: virtual void notify_deleted(Interest *) = 0;
! 121:
! 122: // Class Variables
! 123:
! 124: static IMon imon;
! 125: static Interest *hashtable[HASHSIZE];
! 126: static bool xtab_verification;
! 127:
! 128: // The Hashing Function
! 129:
! 130: static Interest **hashchain(dev_t d, ino_t i)
! 131: { return &hashtable[(unsigned) (d + i) % HASHSIZE]; }
! 132: Interest **hashchain() const { return hashchain(dev, ino); }
! 133:
! 134: Interest(const Interest&); // Do not copy
! 135: Interest & operator = (const Interest&); // or assign.
! 136:
! 137: };
! 138:
! 139: #endif /* !Interest_included */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>