JAVA: remove unsupported JAVA component

The Java (libjafs) component has been marked as obsolete.  Other than
a minor update in 2007 (java-admin-interface-updates-20071214 f72145f79)
there have been no substantial changes since 2003
(java-jafs-update-20030619 af1a0ea03). Changes since then have been
mostly related to source cleanups and a commit in 2012 (Make libjafs
buildable again 967d7201ee).

By default the Java component isn't built and an attempt to build fails
with an error in the src/JAVA/libjafs/Makefile:
make[1]: Entering directory '.../src/JAVA/libjafs'
Makefile:34: *** Recursive variable 'CC' references itself (eventually).
             Stop.

Clean out the source and references for the obsolete JAVA component
(src/JAVA).

Change-Id: Idc241e08f62a1b9384a5ce4d0f2fdb13e2f96904
Reviewed-on: https://gerrit.openafs.org/14839
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
Cheyenne Wills 2021-11-12 14:01:11 -07:00 committed by Michael Meffie
parent 372930175e
commit cbfdf1ed97
58 changed files with 0 additions and 28129 deletions

View File

@ -617,20 +617,6 @@ libadmin: libafsauthent bozo bubasics
echo Not building MT libadmin for ${SYS_NAME} ;; \ echo Not building MT libadmin for ${SYS_NAME} ;; \
esac esac
libjafs: libadmin
+case ${SYS_NAME} in \
sgi_*|sun4x_*|rs_aix*|*linux*|hp_ux110) \
${COMPILE_PART1} JAVA/libjafs ${COMPILE_PART2} ;; \
*) \
echo Not building MT libjafs for ${SYS_NAME} ;; \
esac
libjafsadm: libjafs
jafs: libjafs
jafsadm: libjafsadm
build_tools: config comerr rxgen build_tools: config comerr rxgen
+${COMPILE_PART1} util ${COMPILE_PART2A} buildtools_clean +${COMPILE_PART1} util ${COMPILE_PART2A} buildtools_clean
@ -761,7 +747,6 @@ clean2:
-${COMPILE_PART1} libadmin/cfg ${COMPILE_CLEAN} -${COMPILE_PART1} libadmin/cfg ${COMPILE_CLEAN}
-${COMPILE_PART1} libadmin/test ${COMPILE_CLEAN} -${COMPILE_PART1} libadmin/test ${COMPILE_CLEAN}
-${COMPILE_PART1} libadmin/samples ${COMPILE_CLEAN} -${COMPILE_PART1} libadmin/samples ${COMPILE_CLEAN}
-${COMPILE_PART1} JAVA/libjafs ${COMPILE_CLEAN}
-${COMPILE_PART1} finale ${COMPILE_CLEAN} -${COMPILE_PART1} finale ${COMPILE_CLEAN}
-${COMPILE_PART1} libafs ${COMPILE_CLEAN} -${COMPILE_PART1} libafs ${COMPILE_CLEAN}
-${COMPILE_PART1} libuafs ${COMPILE_CLEAN} -${COMPILE_PART1} libuafs ${COMPILE_CLEAN}
@ -845,7 +830,6 @@ distclean: clean
src/fsint/Makefile \ src/fsint/Makefile \
src/fsprobe/Makefile \ src/fsprobe/Makefile \
src/gtx/Makefile \ src/gtx/Makefile \
src/JAVA/libjafs/Makefile \
src/kauth/Makefile \ src/kauth/Makefile \
src/kauth/test/Makefile \ src/kauth/test/Makefile \
src/kopenafs/Makefile \ src/kopenafs/Makefile \

View File

@ -99,7 +99,6 @@ AC_CONFIG_FILES([
src/fsint/Makefile src/fsint/Makefile
src/fsprobe/Makefile src/fsprobe/Makefile
src/gtx/Makefile src/gtx/Makefile
src/JAVA/libjafs/Makefile
src/kauth/Makefile src/kauth/Makefile
src/kauth/test/Makefile src/kauth/test/Makefile
src/kopenafs/Makefile src/kopenafs/Makefile

View File

@ -41,7 +41,6 @@ EXCLUDE = \
src/dvolser \ src/dvolser \
src/external \ src/external \
src/finale \ src/finale \
src/JAVA \
src/kauth \ src/kauth \
src/libafs \ src/libafs \
src/NTObjdir \ src/NTObjdir \

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path=""/>
</classpath>

View File

@ -1,6 +0,0 @@
# After changing this file, please run
# git ls-files -i --exclude-standard
# to check that you haven't inadvertently ignored any tracked files.
!.classpath
!.project

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>JAVA-openafs</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -1,910 +0,0 @@
#-----------------------------------------------------------
# Custom UFiler Error Codes
#-----------------------------------------------------------
UNKNOWN = Unknown error.
SPECIAL_CASE = Special case error.
GENERAL_FAILURE = Operation returned unsuccessful.
E1000 = Data requested does not exist or is null.
E1001 = User session is invalid
E1002 = Session has expired, please login again
E1003 = Operation aborted
E1004 = Operation was forced to abort
#-----------------------------------------------------------
# Standard UNIX Error Codes
#-----------------------------------------------------------
E1 = Operation not permitted
E2 = No such file or directory
E3 = No such process
E4 = Interrupted system call
E5 = I/O error
E6 = No such device or address
E7 = Arg list too long
E8 = Exec format error
E9 = Bad file number
E10 = No child processes
E11 = Try again
E12 = Out of memory
E13 = Permission denied
E14 = Bad address
E15 = Block device required
E16 = Device or resource busy
E17 = File exists
E18 = Cross-device link
E19 = No such device
E20 = Not a directory
E21 = Is a directory
E22 = Invalid argument
E23 = File table overflow
E24 = Too many open files
E25 = Not a typewriter
E26 = Text file busy
E27 = File too large
E28 = No space left on device
E29 = Illegal seek
E30 = Read-only file system
E31 = Too many links
E32 = Broken pipe
E33 = Math argument out of domain of func
E34 = Math result not representable
E35 = Resource deadlock would occur
E36 = File name too long
E37 = No record locks available
E38 = Function not implemented
E39 = Directory not empty
E40 = Too many symbolic links encountered
E41 = Operation would block
E42 = No message of desired type
E43 = Identifier removed
E44 = Channel number out of range
E45 = Level 2 not synchronized
E46 = Level 3 halted
E47 = Level 3 reset
E48 = Link number out of range
E49 = Protocol driver not attached
E50 = No CSI structure available
E51 = Level 2 halted
E52 = Invalid exchange
E53 = Invalid request descriptor
E54 = Exchange full
E55 = No anode
E56 = Invalid request code
E57 = Invalid slot
E58 = Dead lock
E59 = Bad font file format
E60 = Device not a stream
E61 = No data available
E62 = Timer expired
E63 = Out of streams resources
E64 = Machine is not on the network
E65 = Package not installed
E66 = Object is remote
E67 = Link has been severed
E68 = Advertise error
E69 = Srmount error
E70 = Communication error on send
E71 = Protocol error
E72 = Multihop attempted
E73 = RFS specific error
E74 = Not a data message
E75 = Value too large for defined data type
E76 = Name not unique on network
E77 = File descriptor in bad state
E78 = Remote address changed
E79 = Can not access a needed shared library
E80 = Accessing a corrupted shared library
E81 = .lib section in a.out corrupted
E82 = Attempting to link in too many shared libraries
E83 = Cannot exec a shared library directly
E84 = Illegal byte sequence
E85 = Interrupted system call should be restarted
E86 = Streams pipe error
E87 = Too many users
E88 = Socket operation on non-socket
E89 = Destination address required
E90 = Message too long
E91 = Protocol wrong type for socket
E92 = Protocol not available
E93 = Protocol not supported
E94 = Socket type not supported
E95 = Operation not supported on transport endpoint
E96 = Protocol family not supported
E97 = Address family not supported by protocol
E98 = Address already in use
E99 = Cannot assign requested address
E100 = Network is down
E101 = Network is unreachable
E102 = Network dropped connection because of reset
E103 = Software caused connection abort
E104 = Connection reset by peer
E105 = No buffer space available
E106 = Transport endpoint is already connected
E107 = Transport endpoint is not connected
E108 = Cannot send after transport endpoint shutdown
E109 = Too many references: cannot splice
E110 = Connection timed out
E111 = Connection refused
E112 = Host is down
E113 = No route to host
E114 = Operation already in progress
E115 = Operation now in progress
E116 = Stale NFS file handle
E117 = Structure needs cleaning
E118 = Not a XENIX named type file
E119 = No XENIX semaphores available
E120 = Is a named type file
E121 = Remote I/O error
E122 = Quota exceeded
E123 = No medium found
E124 = Wrong medium type
#-----------------------------------------------------------
# Error Codes for acfg_errors
#-----------------------------------------------------------
E70354688 = mysterious failure
E70354689 = could not find entry
E70354690 = do not know that information
E70354691 = line appears before a cell has been defined
E70354692 = syntax error
E70354693 = a database file is missing
E70354694 = no more entries
#-----------------------------------------------------------
# Error Codes for ktc_errors
#-----------------------------------------------------------
E11862784 = an unexpected error was encountered
E11862785 = a buffer was too small for the response
E11862786 = an invalid argument was passed in
E11862787 = no such entry
E11862788 = a pioctl failed
E11862789 = AFS kernel pioctl doesn't exist
E11862790 = unknown cell was passed to SetToken
E11862791 = Cache Manager is not initialized / afsd is not running
E11862792 = failed to send or receive session key via remote procedure call
E11862793 = Cache Manager RPC server is not responding
#-----------------------------------------------------------
# Error Codes for boserr
#-----------------------------------------------------------
E39424 = process not active
E39425 = no such entity
E39426 = can't do operation now
E39427 = entity already exists
E39428 = failed to create entity
E39429 = index out of range
E39430 = you are not authorized for this operation
E39431 = syntax error in create parameter
E39432 = I/O error
E39433 = network problem
E39434 = unrecognized bnode type
E39435 = kvno already used - have to remove existing kvno's before reuse
E39436 = this function requires encrypted input, use a newer client program
#-----------------------------------------------------------
# Error Codes for butc_errs
#-----------------------------------------------------------
E156566272 = error in dump/restore process
E156566273 = ungraceful abort
E156566274 = the process has already been aborted
E156566275 = unable to end dump/restore since work in progress
E156566276 = some of the dump/restores were unsuccessful
E156566277 = could not abort the process
E156566278 = the process was aborted by request
E156566279 = scan tape resulted in failure
E156566280 = No dump task with specified ID
E156566281 = No tasks active
E156566282 = the volume was not found on tape
E156566283 = unexpected EOF encountered on tape
E156566284 = missing file trailer on tape
E156566285 = unexpected tape label
E156566286 = tape was unusable
E156566287 = corrupted volume header on tape
E156566288 = internal error
E156566289 = corruption in internal queue data structures
E156566290 = memory allocation failure
E156566291 = access denied
E156566292 = tape requested to be skipped
E156566293 = invalid task
#-----------------------------------------------------------
# Error Codes for butm_errs
#-----------------------------------------------------------
E156568832 = interface incompatible
E156568833 = there is not an opened tape
E156568834 = multiple simultaneous opens not permitted
E156568835 = can't open tape
E156568836 = error during tape close
E156568837 = tape I/O error
E156568838 = write operation on read-only tape
E156568839 = operation inappropriate in this context
E156568840 = read file ended before all data read
E156568841 = write a zero length file
E156568842 = end of tape
E156568843 = problem reading configuration
E156568844 = argument too long or out of range
E156568845 = unexpected end of volume data
E156568846 = appended tape label
E156568847 = end of dump
E156568848 = tape device error
E156568849 = end-of-file marker
E156568850 = unexpected tape datablock
E156568851 = no label on tape
E156568852 = cannot position within the file
#-----------------------------------------------------------
# Error Codes for butx_errs
#-----------------------------------------------------------
E156571648 = Version 1
E156571649 = XBSA couldn't mount shared library
E156571650 = XBSA handle already initialized
E156571651 = XBSA invalid serverType specified
E156571652 = XBSA invalid serverName specified
E156571653 = XBSA invalid bsaObjectOwner specified
E156571654 = XBSA invalid appObjectOwner specified
E156571655 = XBSA invalid secToken specified
E156571656 = XBSA invalid objectSpaceName specified
E156571657 = XBSA invalid pathName specified
E156571658 = XBSA invalid bufferSize specified
E156571659 = XBSA invalid dataBuffer specified
E156571660 = XBSA invalid lGName specified
E156571661 = XBSA invalid objectDescription specified
E156571662 = XBSA invalid objectInfo specified
E156571663 = XBSA version mismatch
E156571664 = XBSA unable to mount the XBSA library
E156571665 = XBSA initialization of the XBSA interface failed
E156571666 = XBSA begin transaction failed
E156571667 = XBSA has not been initialized, no handle
E156571668 = XBSA end transaction failed
E156571669 = XBSA terminate session failed
E156571670 = XBSA query object failed
E156571671 = XBSA get object failed
E156571672 = XBSA end data failed
E156571673 = XBSA create object failed
E156571674 = XBSA delete object failed
E156571675 = XBSA send data failed
E156571676 = XBSA get data failed
E156571677 = XBSA get environment failed
E156571678 = XBSA volume to delete not found
#-----------------------------------------------------------
# Error Codes for bucoord_errs
#-----------------------------------------------------------
E156288000 = Unacceptable user supplied argument
E156288001 = Object has been updated
E156288002 = Search matched more than one item
E156288003 = Can't allocate working memory
E156288004 = Can't get cell configuration information
E156288005 = Specified item already exists
E156288006 = Error in configuration parameters
E156288007 = No such volume set
E156288008 = No such volume entry
E156288009 = Volume set already exists
E156288010 = No such server
E156288011 = No such partition
E156288012 = Version number mismatch
E156288013 = Lock has not been acquired
E156288014 = Internal error
E156288015 = No such host/port entry
#-----------------------------------------------------------
# Error Codes for budb_errs
#-----------------------------------------------------------
E156303872 = dump with specified id already exists
E156303873 = no dump matching the id was found
E156303874 = no dump matching the name was found
E156303875 = no tape matching the name was found
E156303876 = no volume matching the name was found
E156303877 = entry doesn't exist
E156303878 = reference to a tape not being used
E156303879 = dump of database failed
E156303880 = access to database denied
E156303881 = incompatible version numbers
E156303882 = argument too long or out of range
E156303883 = sequence of operations incorrect
E156303884 = inconsistent or unsupported flags bit combination
E156303885 = requested list too large
E156303886 = index to iterator function is out of range
E156303887 = bad database block type
E156303888 = lock is not set
E156303889 = lock is held by another user
E156303890 = attempt to lock a lock already held
E156303891 = interface incompatible
E156303892 = Ubik I/O error
E156303893 = bad database address
E156303894 = backup database is inconsistent
E156303895 = internal error encountered in backup database server
E156303896 = error reading cell database
E156303897 = cell name not found
E156303898 = database empty or corrupted
E156303899 = Ubik ClientInit failed
E156303900 = couldn't allocate entry
E156303901 = can't allocate memory
E156303902 = dump is not an initial dump
E156303903 = reference to a dump not being used
#-----------------------------------------------------------
# Error Codes for cmd_errors
#-----------------------------------------------------------
E3359744 = More than the maximum number of parameters defined
E3359745 = Internal parsing error
E3359746 = Too many values specified after a CMD_SINGLE switch
E3359747 = Too many parameters specified
E3359748 = Impossibly few aguments specified
E3359749 = unrecognized or ambiguous command name
E3359750 = unrecognized or ambiguous switch name
E3359751 = <unused>
E3359752 = Insufficient required parameters provided
E3359753 = Token too large
#-----------------------------------------------------------
# Error Codes for test1
#-----------------------------------------------------------
E11829760 = Can't read ticket file
E11829761 = Can't find ticket or TGT
E11829762 = TGT expired
E11829763 = Can't decode authenticator
E11829764 = Ticket expired
E11829765 = Repeated request
E11829766 = The ticket isn't for us
E11829767 = Request is inconsistent
E11829768 = Delta-T too big
E11829769 = Incorrect net address
E11829770 = Protocol version mismatch
E11829771 = Invalid message type
E11829772 = Message stream modified
E11829773 = Message out of order
E11829774 = Unauthorized request
E11829775 = Current password is null
E11829776 = Incorrect current password
E11829777 = Protocol error
E11829778 = Error returned by KDC
E11829779 = Null ticket returned by KDC
E11829780 = Retry count exceeded
E11829781 = Can't send request
#-----------------------------------------------------------
# Error Codes for test2
#-----------------------------------------------------------
E1163220992 = foo
E1163220993 = bar
E1163220994 = meow
#-----------------------------------------------------------
# Error Codes for kaerrors
#-----------------------------------------------------------
E180480 = AuthServer database is inconsistent
E180481 = user already exists
E180482 = Ubik I/O error
E180483 = couldn't allocate entry
E180484 = user doesn't exist
E180485 = database empty or corrupted
E180486 = name or instance is too long or contains illegal characters
E180487 = bad index used internally
E180488 = caller not authorized
E180489 = answer packet too short for result
E180490 = password is incorrect
E180491 = interface incompatible
E180492 = argument out of range
E180493 = administrative command called incorrectly
E180494 = can't create session key
E180495 = can't read password from terminal
E180496 = illegal key: bad parity or weak
E180497 = Ubik ClientInit failed
E180498 = Ubik Call failed
E180499 = AuthServer returned incorrect response
E180500 = error reading cell database
E180501 = cell name not found
E180502 = too many Ubik security objects outstanding
E180503 = too many keys were passed to the server's security object
E180504 = authentication server was passed a bad ticket
E180505 = unknown key version number
E180506 = key cache invalidated by some key change
E180507 = may not issue ticket for server
E180508 = may not authenticate as this user
E180509 = may not change your key
E180510 = not allowed to create associate
E180511 = can't find suitable ticket
E180512 = operation not allowed for associate user
E180513 = not a special AuthServer principal
E180514 = server and client clocks are badly skewed
E180515 = not allowed to recursively call set_password from get_time
E180516 = Rx failed for some reason
E180517 = zero length password is illegal
E180518 = internal error encountered in kaserver
E180519 = password has expired (KAPWEXPIRED)
E180520 = it seems like a reused password (KAREUSED)
E180521 = you changed it too recently; see your systems administrator (KATOOSOON)
E180522 = ID is locked - see your system admin (KALOCKED)
#-----------------------------------------------------------
# Error Codes for afs_AdminBosErrors
#-----------------------------------------------------------
E16896 = the bos server name cannot be NULL
E16897 = the bos server handle cannot be NULL
E16898 = the bos server handle cannot be NULL
E16899 = the bos server handle failed to pass the magic number test. Most likely the server handle is invalid, or has been overwritten by mistake.
E16900 = the bos server handle is invalid
E16901 = the bos server handle does not reference a valid server
E16902 = unable to establish a connection with the specified bos server machine
E16903 = the process name cannot be NULL
E16904 = the process cannot be NULL
E16905 = the cron time cannot be NULL when creating a process of type cron
E16906 = the cron time must be NULL when creating a process of type fs or simple
E16907 = the process status cannot be NULL
E16908 = the process type cannot be NULL
E16909 = the process information cannot be NULL
E16910 = the parameter cannot be NULL
E16911 = the notifier cannot be NULL
E16912 = the administrator name cannot be NULL
E16913 = the key cannot be NULL
E16914 = the key cannot be NULL
E16915 = the host name cannot be NULL
E16916 = the source file cannot be NULL
E16917 = the destination file cannot be NULL
E16918 = the new time cannot be NULL
E16919 = the old time cannot be NULL
E16920 = the backup time cannot be NULL
E16921 = the restart time cannot be NULL
E16922 = the log name cannot be NULL
E16923 = the log buffer size cannot be NULL
E16924 = the log data buffer cannot be NULL
E16925 = the command cannot be NULL
E16926 = the auxiliary process status cannot be NULL
E16927 = the process status is invalid. You can only set a process state to BOS_PROCESS_STOPPED or BOS_PROCESS_RUNNING
E16928 = the process type retrieved from the bos server was invalid.
E16929 = the executable source file could not be opened for reading.
E16930 = unable to determine the size of the executable source file
E16931 = the executable source file could not be read.
E16932 = an error occurred transmitting the contents of the executable source file to the bos server.
E16933 = the executable source file cannot be NULL.
E16934 = the hour member of the time parameter must be between 0 and 23.
E16935 = the minute member of the time parameter must be between 0 and 60.
E16936 = the second member of the time parameter must be between 0 and 60.
E16937 = the day member of the time parameter must be between 0 and 6.
E16938 = unable to successfully read log file.
E16939 = the cell handle does not contain a valid token.
E16940 = the cell handle is not valid for vos requests.
E16941 = a parition must be specified when salvaging a volume .
E16942 = the log file could not be opened for writing.
E16943 = the resulting salvage command is too long to pass to the bos server.
E16944 = bos_ProcessCreate can't create fs processes, use bos_FSProcessCreate instead.
E16945 = the file server executable path cannot be NULL.
E16946 = the volume server executable path cannot be NULL.
E16947 = the salvager executable path cannot be NULL.
#-----------------------------------------------------------
# Error Codes for afs_AdminCfgErrors
#-----------------------------------------------------------
E17920 = the specified configuration option is not yet supported
E17921 = the host name parameter cannot be NULL
E17922 = the host name parameter exceeds the maximum allowed length
E17923 = the host handle reference parameter cannot be NULL
E17924 = the host handle parameter cannot be NULL
E17925 = the host handle parameter failed the magic number test; the handle is invalid or corrupted
E17926 = the host handle parameter is marked as invalid
E17927 = the host handle parameter contains a NULL host name reference
E17928 = the host handle parameter contains a NULL cell handle
E17929 = the host handle parameter contains a NULL cell name reference
E17930 = the administrator principal parameter cannot be NULL
E17931 = the administrator principal parameter exceeds the maximum allowed length
E17932 = the password parameter cannot be an empty string
E17933 = the configuration status reference parameter cannot be NULL
E17934 = the cell name reference parameter cannot be NULL
E17935 = the minimally required server configuration information is missing, unreadable, or invalid
E17936 = the server is not configured in any cell
E17937 = the server does not have any keys
E17938 = the server's cell is not listed in the server's cell database
E17939 = the server's cell database contains no database server entries for the server's cell
E17940 = the cell name parameter cannot be NULL
E17941 = the cell name parameter exceeds the maximum allowed length
E17942 = the cell name parameter conflicts with the cell name contained in the host handle parameter
E17943 = the database hosts parameter cannot be NULL
E17944 = the database hosts parameter contains too many host names
E17945 = unable to set the server cell information; most likely cause is an unknown database host name
E17946 = the bosserver process is currently running on the server host
E17947 = the vice partition table reference parameter cannot be NULL
E17948 = the vice partition table entry count reference parameter cannot be NULL
E17949 = unable to read the vice partition table
E17950 = the partition name parameter cannot be NULL
E17951 = the partition name parameter syntax is invalid
E17952 = the device name parameter cannot be NULL
E17953 = the device name parameter syntax is invalid
E17954 = the vice partition table entry is invalid
E17955 = unable to write to the vice partition table
E17956 = the valid flag reference parameter cannot be NULL
E17957 = the installed flag reference parameter cannot be NULL
E17958 = the version number reference parameter cannot be NULL
E17959 = the started flag reference parameter cannot be NULL
E17960 = the minimally required client configuration information is missing, unreadable, or invalid
E17961 = the client is not configured in any cell
E17962 = the client's cell is not listed in the client's cell database
E17963 = the client's cell database contains no database server entries for the client's cell
E17964 = unable to determine which version of the AFS client is installed
E17965 = unable to read the client's cell database
E17966 = unable to update the client's cell database
E17967 = the client's cell database contains the maximum number of entries for the specified cell; a new database host can not be added
E17968 = failed to edit client's cell database
E17969 = unable to set the client's current cell
E17970 = the AFS bosserver control service is not configured or is improperly configured
E17971 = the AFS bosserver control service is not prepared to accept a control request or is not responding
E17972 = timed out waiting for the AFS bosserver control service to start or stop
E17973 = cannot determine the status of the AFS bosserver control service
E17974 = failed to set or clear the AFS server authentication flag
E17975 = the bosserver-processes flag reference parameter cannot be NULL
E17976 = the database-servers-configured flag reference parameter cannot be NULL
E17977 = the fileserver-configured flag reference parameter cannot be NULL
E17978 = the upserver-configured flag reference parameter cannot be NULL
E17979 = the update client instance suffix cannot be NULL
E17980 = the update client instance suffix exceeds the maximum allowed length
E17981 = the update client's target server name cannot be NULL
E17982 = the update client's import directory list cannot be NULL
E17983 = the upclient-configured flag reference parameter cannot be NULL
E17984 = unable to establish a connection with the specified Ubik voting service on the specified host
E17985 = timed out waiting for one or more database servers to achieve quorum; common causes are time skew between database server machines and network connectivity problems
E17986 = the server's cell database contains too many database server entries
E17987 = the callback parameter cannot be NULL
E17988 = the update count reference parameter cannot be NULL
E17989 = the AFS server principal (afs) key can not be obtained from pre 3.5 database servers
E17990 = the specified AFS server principal (afs) password is invalid; the password generates a key that fails a checksum comparison with the current AFS server principal (afs) key
E17991 = the resolver is unable to retrieve host information from the default host database
E17992 = the specfied host name resolves to a fully qualified name that exceeds the maximum allowed length
E17993 = the AFS client service is not configured or is improperly configured
E17994 = the AFS client service is not prepared to accept a control request or is not responding
E17995 = timed out waiting for the AFS client service to start or stop
E17996 = cannot determine the status of the AFS client service
#-----------------------------------------------------------
# Error Codes for afs_AdminClientErrors
#-----------------------------------------------------------
E19456 = the cell handle parameter cannot be NULL
E19457 = the cell handle reference parameter cannot be NULL
E19458 = the server handle parameter failed to pass the magic number test. Most likely the server handle is invalid, or has been overwritten by mistake.
E19459 = the cell handle is not valid.
E19460 = the cell handle is not valid for authentication server requests
E19461 = the cell handle authentication server pointer is NULL
E19462 = the cell handle is not valid for protection server requests
E19463 = the cell handle protection server pointer is NULL
E19464 = the cell handle is not valid for volume server requests
E19465 = the cell handle volume server pointer is NULL
E19466 = the cell name parameter cannot be NULL
E19467 = the token handle parameter cannot be NULL
E19468 = the token handle is invalid
E19469 = the token handle parameter failed to pass the magic number test. Most likely the token handle is invalid, or has been overwritten by mistake
E19470 = failed to create a new client security object for the token handle
E19471 = unable to locate the location of AFS install
E19472 = unable to initialize the AFS rpc component
E19473 = unable to initialize the windows socket component
E19474 = afsclient_Init must be called before calling any other afsclient function
E19475 = an error occurred while trying to access the local client configuration information
E19476 = the token handle was marked as containing valid tokens, but the actual tokens were invalid
E19477 = the token handle must contain valid afs tokens for the cell
E19478 = the directory parameter cannot be NULL
E19479 = the volume name parameter cannot be NULL
E19480 = unable to determine the parent of the given directory
E19481 = the directory is not in AFS
E19482 = the server did not match any known AFS servers
E19483 = the rpc stat handle cannot be NULL
E19484 = the cell handle does not contain kas tokens
E19485 = there is no connection to the server
E19486 = the client stat handle cannot be NULL
E19487 = there is no connection to the client
E19488 = the cell name pointer cannot be NULL
E19489 = the client configuration pointer cannot be NULL
E19490 = the rxdebug handle cannot be NULL
E19491 = the rxdebug request timed out
E19492 = the rxdebug request is not supported
#-----------------------------------------------------------
# Error Codes for afs_AdminCommonErrors
#-----------------------------------------------------------
E17152 = couldn't allocate memory necessary to fulfill request
E17153 = insufficient privilege to complete operation
E17154 = failed to initialize a mutex
E17155 = failed to lock a mutex
E17156 = failed to unlock a mutex
E17157 = failed to destroy a mutex
E17158 = failed to initialize a condition variable
E17159 = failed to wait on a condition variable
E17160 = failed to destroy a condition variable
E17161 = failed to signal a condition variable
E17162 = failed to initialize a thread attribute
E17163 = failed to set thread detach state
E17164 = failed to create a thread
E17165 = failed to join a thread
E17166 = the iterator has been marked terminated (most likely by calling done). Next cannot be called after calling done.
E17167 = the iterator has been marked completed.
E17168 = the iterator parameter cannot be NULL.
E17169 = the rpc specific data parameter cannot be NULL.
E17170 = the iterator parameter failed to pass the magic number test. Most likely the iterator is invalid, or has been overwritten by mistake.
E17171 = the iterator parameter is marked invalid
E17172 = the iterator parameter cannot be NULL nor can it point to NULL
E17173 = the server name parameter cannot be NULL
E17174 = the server address parameter cannot be NULL
E17175 = the server name parameter cannot translated to an address
E17176 = unable to determine the name of the local host
E17177 = more data is available
E17178 = failed to create a socket
E17179 = the server type is invalid
#-----------------------------------------------------------
# Error Codes for afs_AdminKasErrors
#-----------------------------------------------------------
E19200 = the server handle parameter cannot be NULL
E19201 = the server handle parameter failed to pass the magic number test. Most likely the server handle is invalid, or has been overwritten by mistake.
E19202 = the server handle parameter is marked invalid
E19203 = the server handle parameter contains no servers
E19204 = the cell handle and the server handle parameter cannot both be NULL
E19205 = the cell handle and the server handle parameter cannot both be non-NULL
E19206 = the authentication server handle parameter cannot be NULL
E19207 = the from parameter cannot be NULL
E19208 = the to parameter cannot be NULL
E19209 = the server list parameter cannot be NULL
E19210 = the server list parameter contains too many servers
E19211 = the server handle parameter cannot be NULL nor can it point to NULL
E19212 = the who parameter cannot be NULL
E19213 = the password parameter cannot be NULL
E19214 = the authentication server parameter cannot be NULL
E19215 = the locked until parameter cannot be NULL
E19216 = the principal parameter cannot be NULL
E19217 = the key parameter cannot be NULL
E19218 = the lock end time parameter cannot be NULL
E19219 = the password expires parameter cannot be greater than 255
E19220 = the failed password attempts parameter cannot be greater than 255
E19221 = the failed password lock time parameter cannot be greater than 129600
E19222 = the stats parameter cannot be NULL
E19223 = the debug parameter cannot be NULL
E19224 = the server list parameter didn't contain any servers
E19225 = at least one principal field to set must be specified
#-----------------------------------------------------------
# Error Codes for afs_AdminMiscErrors
#-----------------------------------------------------------
E19712 = the directory parameter cannot be NULL.
E19713 = the user parameter cannot be NULL.
E19714 = the acl parameter cannot be NULL.
E19715 = this interface does not support changing DFS acls.
#-----------------------------------------------------------
# Error Codes for afs_AdminPtsErrors
#-----------------------------------------------------------
E20480 = the protection server parameter cannot be NULL
E20481 = the user name parameter cannot be NULL
E20482 = the user name parameter is too long
E20483 = the group name parameter cannot be NULL
E20484 = the group name parameter is too long
E20485 = failed to translate a name to an identifier
E20486 = the new owner parameter cannot be NULL
E20487 = the new owner parameter is too long
E20488 = the new group parameter cannot be NULL
E20489 = the new group id parameter cannot be positive
E20490 = the target group parameter cannot be NULL
E20491 = the target group parameter is too long
E20492 = the group parameter cannot be NULL
E20493 = the group membership list is longer than the maximum retrievable
E20494 = the member name parameter cannot be NULL
E20495 = the old name parameter cannot be NULL
E20496 = the old name is too long
E20497 = the new name parameter cannot be NULL
E20498 = the new name is too long
E20499 = PTS_GROUP_ANYUSER_ACCESS is an invalid value for the list delete parameter
E20500 = PTS_GROUP_OWNER_ACCESS is an invalid value for the list groups owned parameter
E20501 = PTS_USER_ANYUSER_ACCESS is an invalid value for the list groups owned parameter
E20502 = the new entry parameter cannot be NULL
E20503 = the user parameter cannot be NULL
E20504 = the new group id parameter cannot be NULL
E20505 = the maximum group id parameter cannot be NULL
E20506 = the new user id parameter cannot be NULL
E20507 = the maximum user id parameter cannot be NULL
#-----------------------------------------------------------
# Error Codes for afs_AdminUtilErrors
#-----------------------------------------------------------
E21760 = the server entry parameter cannot be NULL
E21761 = the server name parameter cannot be NULL
E21762 = the server address parameter cannot be NULL
E21763 = the server address parameter cannot be NULL
E21764 = the server name parameter cannot translated to an address
E21765 = failed to open the client CellServDB file
E21766 = the error text parameter cannot be NULL
E21767 = the cell name parameter cannot be NULL
E21768 = the rx connection parameter cannot be NULL
E21769 = the rpc function parameter cannot be NULL
E21770 = the rpc stats parameter cannot be NULL
E21771 = the state parameter cannot be NULL
E21772 = the rpc version parameter cannot be NULL
E21773 = the rxdebug handle parameter cannot be null
E21774 = the rxdebug version parameter cannot be null
E21775 = the rxdebug stats parameter cannot be null
#-----------------------------------------------------------
# Error Codes for afs_AdminVosErrors
#-----------------------------------------------------------
E22016 = the volume server parameter cannot be NULL
E22017 = the cell handle parameter cannot be NULL
E22018 = the cell handle parameter failed to pass the magic number test. Most likely the cell handle is invalid, or has been overwritten by mistake.
E22019 = the cell handle parameter is marked as invalid.
E22020 = the cell handle parameter is marked as invalid for volume server requests.
E22021 = the cell handle does not contain valid AFS tokens.
E22022 = the volume identifier parameter must be a read write volume in order to make a backup volume.
E22023 = a backup volume already exists for volume identifier, but it exists on a server different from the one that holds volumeidentifier.
E22024 = the server handle parameter cannot be NULL
E22025 = the server handle parameter is marked as invalid
E22026 = the server handle parameter failed the magic number test. Most likely the server handle is invalid, or has been overwritten by mistake.
E22027 = a connection with the server could not be established.
E22028 = the partition parameter cannot be NULL
E22029 = the partition parameter is too large
E22030 = the volume name parameter is too long
E22031 = the volume name parameter cannot be NULL
E22032 = the volume name parameter cannot end with .readonly or .backup
E22033 = the volume identifier parameter cannot be NULL
E22034 = the volume identifier parameter cannot exceed VOLMAXPARTS
E22035 = the volume identifier does not exist on the specified server and partition
E22036 = the volume name is already in use.
E22037 = the partition name parameter cannot be NULL
E22038 = the partition name parameter must start with /vicep
E22039 = the partition name parameter is too long.
E22040 = the partition name parameter is too short.
E22041 = the partition name parameter must be all lower case letters.
E22042 = the partition identifier parameter cannot be NULL
E22043 = the resulting partition identifier exceeds VOLMAXPARTS
E22044 = the volume prefix parameter cannot be NULL when the exclude prefix is VOS_EXCLUDE
E22045 = the server address parameter cannot be NULL
E22046 = the server entry parameter cannot be NULL
E22047 = the server transaction status parameter cannot be NULL
E22048 = the vldb entry parameter cannot be NULL
E22049 = at least one of the arguments must not be null - server handle, partition, volume identifier.
E22050 = the new volume name parameter cannot be NULL
E22051 = both the server handle and the paritiion parameters must be specified.
E22052 = the dump file parameter cannot be NULL
E22053 = an error occurred while trying to write more data to the dump file
E22054 = an error occurred while trying to open dump file
E22055 = the volume to be restored exists on a server different from the one specified and you specified an incremental restore. If you wish to restore this volume, specify a full restore.
E22056 = an error occurred while trying open restore file
E22057 = an error occurred while trying close restore file
E22058 = an error occurred while trying read the restore file
E22059 = an error occurred while trying send the contents of the restore file
E22060 = the volume name is too big
E22061 = either the volume name or the volume identifier parameter must not be NULL
E22062 = the volume parameter cannot be NULL
E22063 = only read write volumes can be moved
E22064 = only read write volumes can be released
E22065 = only replicated volumes can be released
E22066 = unable to create a backup volume because no read write volume exists
E22067 = unable to create a backup volume because the vldb entry is invalid
E22068 = unable to get server's address from vldb
E22069 = skipping volume since read write is in a different location
E22070 = there were no entries in the vldb retrieved.
#-----------------------------------------------------------
# Error Codes for pterror
#-----------------------------------------------------------
E267264 = Entry for name already exists
E267265 = Entry for id already exists
E267266 = Couldn't allocate an id for this entry
E267267 = Couldn't read/write the database
E267268 = User or group doesn't exist
E267269 = Permission denied
E267270 = No group specified
E267271 = No user specified
E267272 = Badly formed name (group prefix doesn't match owner?)
E267273 = argument illegal or out of range
E267274 = may not create more groups
E267275 = database needs rebuilding
E267276 = can't make owner an empty group
E267277 = database is inconsistent
E267278 = bad database address
E267279 = too many elements in group
E267280 = malloc failed to alloc enough memory
#-----------------------------------------------------------
# Error Codes for stress_errs
#-----------------------------------------------------------
E19059456 = process created, not yet started
E19059457 = process running, no error
E19059458 = arguments illegal or inconsistent
E19059459 = incorrect input checksum
E19059460 = incorrect output checksum
E19059461 = unexpected number of bytes returned by rx_Read
E19059462 = unexpected number of bytes sent by rx_Write
E19059463 = connection unauthenticated
E19059464 = unknown key version number
E19059465 = incorrect client name/instance/cell
E19059466 = increment operation produced wrong value
E19059467 = clock on client and server too far apart
E19059468 = couldn't make a new connection
E19059469 = connection has unexpected call numbers
E19059470 = failed to detect duplicate call
E19059471 = failed to detect bad cksum
E19059472 = whole connection is not in error
E19059473 = idle connection is acting as a challenge oracle
#-----------------------------------------------------------
# Error Codes for rxkad_errs
#-----------------------------------------------------------
E19270400 = Security module structure inconsistent
E19270401 = Packet too short for security challenge
E19270402 = Security level negotiation failed
E19270403 = Ticket length too long or too short
E19270404 = packet had bad sequence number
E19270405 = caller not authorized
E19270406 = illegal key: bad parity or weak
E19270407 = security object was passed a bad ticket
E19270408 = ticket contained unknown key version number
E19270409 = authentication expired
E19270410 = sealed data inconsistent
E19270411 = user data too long
E19270412 = caller not authorized to use encrypted connections
#-----------------------------------------------------------
# Error Codes for uerrors
#-----------------------------------------------------------
E5376 = no quorum elected
E5377 = not synchronization site (should work on sync site)
E5378 = too many hosts
E5379 = I/O error writing dbase or log
E5380 = mysterious internal error
E5381 = major synchronization error
E5382 = file not found when processing dbase
E5383 = bad lock range size (must be 1)
E5384 = read error reprocessing log
E5385 = problems with host name
E5386 = bad operation for this transaction type
E5387 = two commits or aborts done to transaction
E5388 = operation done after abort (or commmit)
E5389 = no servers appear to be up
E5390 = premature EOF
E5391 = error writing log file
E5392 = unsupported address family -- bogus error
E5393 = inconsistent cell name -- bogus error
E5394 = security group bad or missing -- bogus error
E5395 = server group name bad or missing -- bogus error
E5396 = server uuid bad or missing -- bogus error
E5397 = memory allocation failure -- bogus error
E5398 = host not a member of server group -- bogus error
E5399 = too many bindings per server -- bogus error
E5400 = inconsistent principal name from binding -- bogus error
E5401 = I/O error in ubik pipe -- bogus error
E5402 = operation aborted to prevent dead lock (two sync sites?)
E5403 = rpc runtime exception caught -- bogus error
E5404 = vote thread pool queue operation failed -- bogus error
E5405 = clock skew among servers too high -- bogus error
E5406 = repeatedly failed to obtain ubik lock -- bogus error
E5407 = permission denied for attempted operation -- bogus error
E5408 = no space left on database device -- bogus error
E5409 = invalid DB pathname -- bogus error
E5410 = bad file descriptor -- bogus error
E5411 = Reinitialize called before initialize
E5412 = failed to initialize per client mutex
E5413 = failed to destroy per client mutex
#-----------------------------------------------------------
# Error Codes for vl_errors
#-----------------------------------------------------------
E363520 = Volume Id entry exists in vl database
E363521 = I/O related error
E363522 = Volume name entry exists in vl database
E363523 = Internal creation failure
E363524 = No such entry
E363525 = Vl database is empty
E363526 = Entry is deleted (soft delete)
E363527 = Volume name is illegal
E363528 = Index is out of range
E363529 = Bad volume type
E363530 = Illegal server number (out of range)
E363531 = Bad partition number
E363532 = Run out of space for Replication sites
E363533 = No such Replication server site exists
E363534 = Replication site already exists
E363535 = Parent R/W entry not found
E363536 = Illegal Reference Count number
E363537 = Vl size for attributes exceeded
E363538 = Bad incoming vl entry
E363539 = Illegal max volid increment
E363540 = RO/BACK id already hashed
E363541 = Vl entry is already locked
E363542 = Bad volume operation code
E363543 = Bad release lock type
E363544 = Status report: last release was aborted
E363545 = Invalid replication site server flag
E363546 = No permission access
E363547 = malloc(realloc) failed to alloc enough memory
E363548 = Wrong vldb version
E363549 = Index out of range
E363550 = Servers have the same ip address
E363551 = Illegal attribute mask value
#-----------------------------------------------------------
# Error Codes for volerr
#-----------------------------------------------------------
E1492325120 = internal error releasing transaction
E1492325121 = unknown internal error
E1492325122 = badly formatted dump
E1492325123 = badly formatted dump(2)
E1492325124 = could not attach volume
E1492325125 = illegal partition
E1492325126 = could not detach volume
E1492325127 = insufficient privilege for volume operation
E1492325128 = error from volume location database
E1492325129 = bad volume name
E1492325130 = volume moved
E1492325131 = illegal volume operation
E1492325132 = volume release failed
E1492325133 = volume still in use by volserver
E1492325134 = out of virtual memory in volserver
E1492325135 = no such volume
E1492325136 = more than one read/write volume
E1492325137 = failed volume server operation

View File

@ -1,876 +0,0 @@
/*
* @(#)ACL.java 2.0 04/18/2001
*
* Copyright (c) 2001 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openafs.jafs;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.StringTokenizer;
/**
* An abstract representation of AFS file and directory pathnames.
*
* This class is an extension of the standard Java File class with file-based
* manipulation methods overridden by integrated AFS native methods.
*
* @version 2.0, 04/18/2001 - Completely revised class for efficiency.
*/
public class ACL implements Serializable, Comparable
{
protected ACL.Entry[] positiveEntries;
protected ACL.Entry[] negativeEntries;
protected String path;
public ACL(String path) throws AFSException
{
this(path,true);
}
public ACL(String path, boolean init) throws AFSException {
int numberPositiveEntries = 0;
int numberNegativeEntries = 0;
ACL.Entry aclEntry;
String buffer;
this.path = path;
if (init) {
StringTokenizer st = new StringTokenizer(getACLString(path), "\n\t");
buffer = st.nextToken();
numberPositiveEntries = new Integer(buffer).intValue();
positiveEntries = new ACL.Entry[numberPositiveEntries];
buffer = st.nextToken();
numberNegativeEntries = new Integer(buffer).intValue();
negativeEntries = new ACL.Entry[numberNegativeEntries];
for (int i = 0; i < numberPositiveEntries; i++) {
aclEntry = new ACL.Entry();
aclEntry.setUser(st.nextToken());
aclEntry.setPermissions(new Integer(st.nextToken()).intValue());
positiveEntries[i] = aclEntry;
}
for (int i = 0; i < numberNegativeEntries; i++) {
aclEntry = new ACL.Entry();
aclEntry.setUser(st.nextToken());
aclEntry.setPermissions(new Integer(st.nextToken()).intValue());
negativeEntries[i] = aclEntry;
}
}else{
positiveEntries = new ACL.Entry[numberPositiveEntries];
negativeEntries = new ACL.Entry[numberNegativeEntries];
}
}
public int getEntryCount()
{
return positiveEntries.length + positiveEntries.length;
}
public String getPath()
{
return path;
}
public void setPath(String path)
{
this.path= path;
}
public ACL.Entry[] getPositiveEntries()
{
return positiveEntries;
}
public void addPositiveEntry(ACL.Entry entry) throws AFSException
{
int n = positiveEntries.length;
ACL.Entry[] e = new ACL.Entry[n + 1];
System.arraycopy(positiveEntries, 0, e, 0, n);
e[n] = entry;
positiveEntries = e;
setACLString(path, getFormattedString());
}
public void setPositiveEntries(ACL.Entry[] entries) throws AFSException
{
this.positiveEntries = entries;
setACLString(path, getFormattedString());
}
public ACL.Entry[] getNegativeEntries()
{
return negativeEntries;
}
public void addNegativeEntry(ACL.Entry entry) throws AFSException
{
int n = negativeEntries.length;
ACL.Entry[] e = new ACL.Entry[n + 1];
System.arraycopy(negativeEntries, 0, e, 0, n);
e[n] = entry;
negativeEntries = e;
setACLString(path, getFormattedString());
}
public void addAllNegativeEntrys(ACL.Entry[] entry) throws AFSException
{
int n = negativeEntries.length;
ACL.Entry[] e = new ACL.Entry[n + entry.length];
System.arraycopy(negativeEntries, 0, e, 0, n);
System.arraycopy(entry,0,e,n,entry.length);
negativeEntries = e;
setACLString(path, getFormattedString());
}
public void addAllPositiveEntrys(ACL.Entry[] entry) throws AFSException
{
int n = positiveEntries.length;
ACL.Entry[] e = new ACL.Entry[n + entry.length];
System.arraycopy(positiveEntries, 0, e, 0, n);
System.arraycopy(entry,0,e,n,entry.length);
positiveEntries = e;
setACLString(path, getFormattedString());
}
public void setNegativeEntries(ACL.Entry[] entries) throws AFSException
{
this.negativeEntries = entries;
setACLString(path, getFormattedString());
}
/**
* Needs a AFS Connection
*/
public void flush() throws AFSException
{
setACLString(path, getFormattedString());
}
/**
* removes a ACL Entry from acl
*/
public void removeNegativeEntry(Entry entry) throws AFSException {
ArrayList arr = new ArrayList();
for (int i = 0; i < negativeEntries.length; i++) {
if(!negativeEntries[i].equals(entry)){
arr.add(negativeEntries[i]);
}
}
negativeEntries = (ACL.Entry[]) arr.toArray(new ACL.Entry[arr.size()]);
setACLString(path, getFormattedString());
}
/**
* removes all ACL Entrys from acl
*/
public void removeAllNegativeEntrys() throws AFSException {
negativeEntries = new Entry[0];
setACLString(path, getFormattedString());
}
/**
* removes all ACL Entrys from acl
*/
public void removeAllPositiveEntrys() throws AFSException {
positiveEntries = new Entry[0];
setACLString(path, getFormattedString());
}
public boolean containsNegative(Entry entry) {
for (int i = 0; i < negativeEntries.length; i++) {
if(negativeEntries[i].equals(entry)){
return true;
}
}
return false;
}
public Entry getNegative(String entryname) {
for (int i = 0; i < negativeEntries.length; i++) {
if(negativeEntries[i].getUser().equalsIgnoreCase(entryname)){
return negativeEntries[i];
}
}
return null;
}
public Entry getPositive(String entryname) {
for (int i = 0; i < positiveEntries.length; i++) {
if(positiveEntries[i].getUser().equalsIgnoreCase(entryname)){
return positiveEntries[i];
}
}
return null;
}
public boolean containsPositive(Entry entry) {
for (int i = 0; i < positiveEntries.length; i++) {
if(positiveEntries[i].equals(entry)){
return true;
}
}
return false;
}
/**
* removes a ACL Entry from acl
*/
public void removePositiveEntry(Entry entry) throws AFSException {
ArrayList arr = new ArrayList();
for (int i = 0; i < positiveEntries.length; i++) {
if(!positiveEntries[i].equals(entry)){
arr.add(positiveEntries[i]);
}
}
positiveEntries = (ACL.Entry[]) arr.toArray(new ACL.Entry[arr.size()]);
setACLString(path, getFormattedString());
}
private ACL.Entry[] getNonEmptyEntries(ACL.Entry[] entries)
{
ArrayList response = new ArrayList(entries.length);
for (int i = 0; i < entries.length; i++)
{
boolean isNonEmpty = entries[i].canRead() ||
entries[i].canLookup() ||
entries[i].canWrite() ||
entries[i].canInsert() ||
entries[i].canDelete() ||
entries[i].canLock() ||
entries[i].canAdmin();
if (isNonEmpty) response.add(entries[i]);
}
if (response.size() == entries.length) return entries;
return (ACL.Entry[])response.toArray(new ACL.Entry[response.size()]);
}
private void entriesToString(ACL.Entry[] entries, StringBuffer response)
{
for (int i = 0; i < entries.length; i++)
{
this.entryToString((ACL.Entry)entries[i], response);
}
}
private void entryToString(ACL.Entry entry, StringBuffer response)
{
response.append(entry.getUser() + '\t' + entry.getPermissionsMask() + '\n');
}
/**
* Returns a ViceIoctl formatted String representation of this
* <CODE>ACL</CODE>.
*
* @return a ViceIoctl formatted String representation of this
* <CODE>ACL</CODE>.
*/
private String getFormattedString()
{
StringBuffer out = null;
ACL.Entry[] nonEmptyPos = this.getNonEmptyEntries(this.getPositiveEntries());
ACL.Entry[] nonEmptyNeg = this.getNonEmptyEntries(this.getNegativeEntries());
out = new StringBuffer(nonEmptyPos.length + "\n" + nonEmptyNeg.length + "\n");
this.entriesToString(nonEmptyPos, out);
this.entriesToString(nonEmptyNeg, out);
return out.toString();
}
/////////////// custom override methods ////////////////////
/**
* Compares two ACL objects respective to their paths and does not
* factor any other attribute. Alphabetic case is significant in
* comparing names.
*
* @param acl The ACL object to be compared to this ACL
* instance
*
* @return Zero if the argument is equal to this ACL's path, a
* value less than zero if this ACL's path is
* lexicographically less than the argument, or a value greater
* than zero if this ACL's path is lexicographically
* greater than the argument
*/
public int compareTo(ACL acl)
{
return this.getPath().compareTo(acl.getPath());
}
/**
* Comparable interface method.
*
* @see #compareTo(ACL)
*/
public int compareTo(Object obj)
{
return compareTo((ACL)obj);
}
/**
* Tests whether two <code>ACL</code> objects are equal, based on their
* paths and permission bits.
*
* @param acl the ACL to test
* @return whether the specifed ACL is the same as this ACL
*/
public boolean equals( ACL acl )
{
return ( (this.getPath().equals(acl.getPath())) &&
(positiveEntries.equals(acl.getPositiveEntries())) &&
(negativeEntries.equals(acl.getNegativeEntries())) );
}
/**
* Returns a String representation of this <CODE>ACL</CODE>
*
* @return a String representation of this <CODE>ACL</CODE>
*/
public String toString()
{
ACL.Entry[] nonEmptyPos = this.getNonEmptyEntries(this.getPositiveEntries());
ACL.Entry[] nonEmptyNeg = this.getNonEmptyEntries(this.getNegativeEntries());
StringBuffer out = new StringBuffer("ACL for ");
out.append(path);
out.append("\n");
out.append("Positive Entries:\n");
for (int i = 0; i < nonEmptyPos.length; i++) {
out.append(" ");
out.append(nonEmptyPos[i].toString());
}
if (nonEmptyNeg.length > 0) {
out.append("Negative Entries:\n");
for (int i = 0; i < nonEmptyNeg.length; i++) {
out.append(" ");
out.append(nonEmptyNeg[i].toString());
}
}
return out.toString();
}
/////////////// native methods ////////////////////
/**
* Returns a formatted String representing the ACL for the specified path.
*
* The string format is in the form of a ViceIoctl and is as follows:
* printf("%d\n%d\n", positiveEntriesCount, negativeEntriesCount);
* printf("%s\t%d\n", userOrGroupName, rightsMask);
*
* @param path the directory path
* @returns a formatted String representing the ACL for the specified path.
* @throws an AFSException if an AFS or JNI exception is encountered.
*/
private native String getACLString(String path) throws AFSException;
/**
* Sets the ACL in the file system according to this abstract representation.
*
* @param path the directory path
* @param aclString string representation of ACL to be set
* @throws an AFSException if an AFS or JNI exception is encountered.
*/
private native void setACLString(String path, String aclString) throws AFSException;
/*====================================================================*/
/* INNER CLASSES */
/*====================================================================*/
/**
* AFS ACL Entry Class.
*
* <p> Documentation reference:
* <A HREF="http://www.transarc.com/Library/documentation/afs/3.6/unix/en_US/HTML/AdminGd/auagd020.htm#HDRWQ772">Managing Access Control Lists</A>
*
* @version 2.0, 04/18/2001 - Completely revised class for efficiency.
* @version 3.0, 05/01/2002 - Converted class to an inner class.
*/
public static final class Entry implements Serializable
{
/** ACL Mask read constant */
public static final int READ = 1;
/** ACL Mask write constant */
public static final int WRITE = 2;
/** ACL Mask insert constant */
public static final int INSERT = 4;
/** ACL Mask lookup constant */
public static final int LOOKUP = 8;
/** ACL Mask delete constant */
public static final int DELETE = 16;
/** ACL Mask lock constant */
public static final int LOCK = 32;
/** ACL Mask administer constant */
public static final int ADMIN = 64;
private String username;
private boolean r = false;
private boolean l = false;
private boolean i = false;
private boolean d = false;
private boolean w = false;
private boolean k = false;
private boolean a = false;
/**
* Constructs a new ACL entry with all permission bits set to <code>false</code>.
*/
public Entry()
{
}
/**
* Constructs a new ACL entry with all permission bits set to <code>false</code>
* and sets the associated user or group name.
*
* @param user The user or group name associated with this entry
*/
public Entry(String user)
{
this.setUser(user);
}
/**
* Constructs a new ACL entry setting each permission bit to its appropriate
* value according to the <code>permissionsMask</code> specified.
*
* @see #canRead
* @see #canWrite
* @see #canInsert
* @see #canLookup
* @see #canDelete
* @see #canLock
* @see #canAdmin
* @param permissionsMask An integer representation of the permissoin
* rights of this entry
*/
public Entry(int permissionsMask)
{
this.setPermissions(permissionsMask);
}
/**
* Constructs a new ACL entry setting each permission bit to its appropriate
* value according to the <code>permissionsMask</code> specified
* and sets the associated user or group name.
*
* @see #canRead
* @see #canWrite
* @see #canInsert
* @see #canLookup
* @see #canDelete
* @see #canLock
* @see #canAdmin
* @see #setUser
* @param permissionsMask An integer representation of the permissoin
* rights of this entry
* @param user The username or group associated with this entry
*/
public Entry(String user, int permissionsMask)
{
this.setUser(user);
this.setPermissions(permissionsMask);
}
/*-------------------------------------------------------------------------*/
/**
* Set this entry's permission bits according to the value of the
* <code>permissionsMask</code> specified.
*
* @see #getPermissionsMask
* @param permissionsMask An integer representation of the permissoin
* rights of this entry
*/
public void setPermissions(int permissionsMask)
{
if ((permissionsMask & READ) != 0) {
this.setRead(true);
}
if ((permissionsMask & LOOKUP) != 0) {
this.setLookup(true);
}
if ((permissionsMask & INSERT) != 0) {
this.setInsert(true);
}
if ((permissionsMask & DELETE) != 0) {
this.setDelete(true);
}
if ((permissionsMask & WRITE) != 0) {
this.setWrite(true);
}
if ((permissionsMask & LOCK) != 0) {
this.setLock(true);
}
if ((permissionsMask & ADMIN) != 0) {
this.setAdmin(true);
}
}
/**
* Returns this entry's permission mask.
*
* <p> <B>Permission Mask</B><BR>
* 01 - READ <BR>
* 02 - WRITE <BR>
* 04 - INSERT<BR>
* 08 - LOOKUP<BR>
* 16 - DELETE<BR>
* 32 - LOCK <BR>
* 64 - ADMIN <BR>
*
* <p> Any combination of the above mask values would equate to a valid combination of
* permission settings. For example, if the permission mask was <B>11</B>, the ACL permissions
* would be as follows: <code>read</code> (1), <code>write</code> (2), and <code>lookup</code> (8).<BR>
* [1 + 2 + 8 = 11]
*
* @return An integer representation (mask) of the permissoin rights of this entry
*/
public int getPermissionsMask()
{
int permissionsMask = 0;
if (canRead()) permissionsMask |= READ;
if (canWrite()) permissionsMask |= WRITE;
if (canInsert()) permissionsMask |= INSERT;
if (canLookup()) permissionsMask |= LOOKUP;
if (canDelete()) permissionsMask |= DELETE;
if (canLock()) permissionsMask |= LOCK;
if (canAdmin()) permissionsMask |= ADMIN;
return permissionsMask;
}
/**
* Returns the user <B>or</B> group name associated with this ACL entry.
*
* @return String representation of the user or group name associated with this entry.
*/
public String getUser()
{
return username;
}
/**
* Sets the user <B>or</B> group name associated with this ACL entry.
*
* @param user representation of the user or group name associated with this entry.
*/
public void setUser(String user)
{
username = user;
}
/**
* <IMG SRC="file.gif" ALT="File Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits <code>read</code> access.
*
* <p> This permission enables a user to read the contents of files in the directory
* and to obtain complete status information for the files (read/retrieve the file
* attributes).
*
* <p><FONT COLOR="666699"><IMG SRC="file.gif" ALT="File Permission" WIDTH="15" HEIGHT="15" BORDER="0"> <U><B>File Permission</B></U></FONT><BR>
* This permission is meaningful with respect to files in
* a directory, rather than the directory itself or its subdirectories.
*
* <p> Documentation reference:
* <A HREF="http://www.transarc.com/Library/documentation/afs/3.6/unix/en_US/HTML/AdminGd/auagd020.htm#HDRWQ782">The AFS ACL Permissions</A>
*
* @return <code>true</code> if and only if the ACL permits <code>read</code> access of
* files; <code>false</code> otherwise
*/
public boolean canRead()
{
return r;
}
/**
* Sets the ACL permission to accomodate <code>read</code> access for files.
*
* @see #canRead
* @param flag boolean flag that denotes the permission bit for <code>read</code> access.
*/
public void setRead(boolean flag)
{
r = flag;
}
/**
* <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits lookup access.
*
* <p> This permission functions as something of a gate keeper for access to the directory
* and its files, because a user must have it in order to exercise any other permissions.
* In particular, a user must have this permission to access anything in the directory's
* subdirectories, even if the ACL on a subdirectory grants extensive permissions.
*
* <p> This permission enables a user to list the names of the files and subdirectories in
* the directory (this does not permit read access to its respective entries), obtain
* complete status information for the directory element itself, and examine the directory's
* ACL.
*
* <p> This permission does not enable a user to read the contents of a file in the
* directory.
*
* <p> Similarly, this permission does not enable a user to lookup the contents of,
* obtain complete status information for, or examine the ACL of the subdirectory of
* the directory. Those operations require the <code>lookup</code> permission on the ACL
* of the subdirectory itself.
*
* <p><FONT COLOR="666699"><IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> <U><B>Directory Permission</B></U></FONT><BR>
* This permission is meaningful with respect to the
* directory itself. For example, the <code>insert</code> permission (see: {@link #canInsert})
* does not control addition of data to a file, but rather creation of a new file or
* subdirectory.
*
* <p> Documentation reference:
* <A HREF="http://www.transarc.com/Library/documentation/afs/3.6/unix/en_US/HTML/AdminGd/auagd020.htm#HDRWQ782">The AFS ACL Permissions</A>
*
* @return <code>true</code> if and only if the ACL permits <code>lookup</code> access for
* directories; <code>false</code> otherwise
*/
public boolean canLookup()
{
return l;
}
/**
* Sets the ACL permission to accomodate <code>lookup</code> access for directories.
*
* @see #canLookup
* @param flag boolean flag that denotes the permission bit for <code>lookup</code> access.
*/
public void setLookup(boolean flag)
{
l = flag;
}
/**
* <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits <code>insert</code> access.
*
* <p> This permission enables a user to add new files to the directory, either by creating
* or copying, and to create new subdirectories. It does not extend into any subdirectories,
* which are protected by their own ACLs.
*
* <p><FONT COLOR="666699"><IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> <U><B>Directory Permission</B></U></FONT><BR>
* This permission is meaningful with respect to the
* directory itself. For example, the <code>insert</code> permission (see: {@link #canInsert})
* does not control addition of data to a file, but rather creation of a new file or
* subdirectory.
*
* <p> Documentation reference:
* <A HREF="http://www.transarc.com/Library/documentation/afs/3.6/unix/en_US/HTML/AdminGd/auagd020.htm#HDRWQ782">The AFS ACL Permissions</A>
*
* @return <code>true</code> if and only if the ACL permits <code>insert</code> access for
* directories; <code>false</code> otherwise
*/
public boolean canInsert()
{
return i;
}
/**
* Sets the ACL permission to accomodate <code>insert</code> access for directories.
*
* @see #canInsert
* @param flag boolean flag that denotes the permission bit for <code>insert</code> access.
*/
public void setInsert(boolean flag)
{
i = flag;
}
/**
* <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits <code>delete</code> access.
*
* <p> This permission enables a user to remove files and subdirectories from the directory
* or move them into other directories (assuming that the user has the <code>insert</code>
* (see: {@link #canInsert}) permission on the ACL of the other directories).
*
* <p><FONT COLOR="666699"><IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> <U><B>Directory Permission</B></U></FONT><BR>
* This permission is meaningful with respect to the
* directory itself. For example, the <code>insert</code> permission (see: {@link #canInsert})
* does not control addition of data to a file, but rather creation of a new file or
* subdirectory.
*
* <p> Documentation reference:
* <A HREF="http://www.transarc.com/Library/documentation/afs/3.6/unix/en_US/HTML/AdminGd/auagd020.htm#HDRWQ782">The AFS ACL Permissions</A>
*
* @return <code>true</code> if and only if the ACL permits <code>delete</code> access for
* directories; <code>false</code> otherwise
*/
public boolean canDelete()
{
return d;
}
/**
* Sets the ACL permission to accomodate <code>delete</code> access for directories.
*
* @see #canDelete
* @param flag boolean flag that denotes the permission bit for <code>delete</code> rights.
*/
public void setDelete(boolean flag)
{
d = flag;
}
/**
* <IMG SRC="file.gif" ALT="File Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits <code>write</code> access.
*
* <p> This permission enables a user to modify the contents of files in the directory
* and to change their operating system specific mode bits.
*
* <p><FONT COLOR="666699"><IMG SRC="file.gif" ALT="File Permission" WIDTH="15" HEIGHT="15" BORDER="0"> <U><B>File Permission</B></U></FONT><BR>
* This permission is meaningful with respect to files in
* a directory, rather than the directory itself or its subdirectories.
*
* <p> Documentation reference:
* <A HREF="http://www.transarc.com/Library/documentation/afs/3.6/unix/en_US/HTML/AdminGd/auagd020.htm#HDRWQ782">The AFS ACL Permissions</A>
*
* @return <code>true</code> if and only if the ACL permits <code>write</code> access for
* files; <code>false</code> otherwise
*/
public boolean canWrite()
{
return w;
}
/**
* Sets the ACL permission to accomodate <code>write</code> access for files.
*
* @see #canWrite
* @param flag boolean flag that denotes the permission bit for <code>write</code> access.
*/
public void setWrite(boolean flag)
{
w = flag;
}
/**
* <IMG SRC="file.gif" ALT="File Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits the <code>lock</code> authority.
*
* <p> This permission enables the user to run programs that issue system calls to
* lock files in the directory.
*
* <p><FONT COLOR="666699"><IMG SRC="file.gif" ALT="File Permission" WIDTH="15" HEIGHT="15" BORDER="0"> <U><B>File Permission</B></U></FONT><BR>
* This permission is meaningful with respect to files in
* a directory, rather than the directory itself or its subdirectories.
*
* <p> Documentation reference:
* <A HREF="http://www.transarc.com/Library/documentation/afs/3.6/unix/en_US/HTML/AdminGd/auagd020.htm#HDRWQ782">The AFS ACL Permissions</A>
*
* @return <code>true</code> if and only if the ACL permits <code>lock</code> authority for
* files; <code>false</code> otherwise
*/
public boolean canLock()
{
return k;
}
/**
* Sets the ACL permission to accomodate <code>lock</code> access for files.
*
* @see #canLock
* @param flag boolean flag that denotes the permission bit for <code>lock</code> rights.
*/
public void setLock(boolean flag)
{
k = flag;
}
/**
* <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits <code>administer</code> access.
*
* <p> This permission enables a user to change the directory's ACL. Members of the
* <code>system:administrators</code> group implicitly have this permission on every
* directory (that is, even if that group does not appear on the ACL). Similarly, the
* owner of a directory implicitly has this permission on its ACL and those of all
* directories below it that he or she owns.
*
* <p><FONT COLOR="666699"><IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> <U><B>Directory Permission</B></U></FONT><BR>
* This permission is meaningful with respect to the
* directory itself. For example, the <code>insert</code> permission (see: {@link #canInsert})
* does not control addition of data to a file, but rather creation of a new file or
* subdirectory.
*
* <p> Documentation reference:
* <A HREF="http://www.transarc.com/Library/documentation/afs/3.6/unix/en_US/HTML/AdminGd/auagd020.htm#HDRWQ782">The AFS ACL Permissions</A>
*
* @return <code>true</code> if and only if the ACL permits <code>administer</code> access for
* directories; <code>false</code> otherwise
*/
public boolean canAdmin()
{
return a;
}
/**
* Sets the ACL permission to accomodate <code>administer</code> rights for directories.
*
* @see #canAdmin
* @param flag boolean flag that denotes the permission bit for <code>administer</code> rights.
*/
public void setAdmin(boolean flag)
{
a = flag;
}
/////////////// custom override methods ////////////////////
/**
* Tests whether two <code>ACL.Entry</code> objects are equal, based on associated
* username and permission bits.
*
* @param entry the ACL.Entry to test
* @return whether the specifed ACL.Entry is the same as this ACL.Entry
*/
public boolean equals( ACL.Entry entry )
{
return ( (this.getUser().equals( entry.getUser() )) &&
(this.getPermissionsMask() == entry.getPermissionsMask()) );
}
/**
* Returns a String representation of this <CODE>ACL.Entry</CODE>
*
* @return a String representation of this <CODE>ACL.Entry</CODE>
*/
public String toString()
{
StringBuffer out = new StringBuffer(username);
out.append("\t");
if (r) out.append("r");
if (l) out.append("l");
if (i) out.append("i");
if (d) out.append("d");
if (w) out.append("w");
if (k) out.append("k");
if (a) out.append("a");
out.append("\n");
return out.toString();
}
}
}

View File

@ -1,204 +0,0 @@
/*
* @(#)AFSException.java 2.0 01/04/16
*
* Copyright (c) 2001 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openafs.jafs;
import java.util.Locale;
/**
* An exception indicating that an error has occurred in the Java AFS
* API, in the Java AFS JNI, or in the AFS file system.
*
* @version 1.0, 04/16/2001
* @see java.lang.Exception
*/
public class AFSException extends Exception
{
/**
* The AFS specific error number (code).
* @see #getErrorCode()
*/
protected int errno;
/**
* Constructs an <code>AFSException</code> with the specified detail
* message.
*
* @param reason the detail message.
*/
public AFSException(String reason)
{
super(reason);
}
/**
* Constructs an <code>AFSException</code> with the specified error code.
* This constructor will also generate the appropriate error message
* respective to the specified error code.
*
* @param errno the AFS error number (error code).
*/
public AFSException(int errno)
{
super(ErrorTable.getMessage( (errno == 0) ? ErrorTable.UNKNOWN : errno ));
this.errno = (errno == 0) ? ErrorTable.UNKNOWN : errno;
}
/**
* Constructs an <code>AFSException</code> with the specified detail message
* and specified error code. In this constructor the specified detail message
* overrides the default AFS error message defined by the
* <code>ErrorTable</code> class. Therefore, to retrieve the AFS specific
* error message, you must use the <code>{@link #getAFSMessage}</code> method.
* The <code>{@link #getMessage}</code> method will return the message specified
* in this constructor.
*
* @param reason the detail message.
* @param errno the AFS error number (error code).
*/
public AFSException(String reason, int errno)
{
super(reason);
this.errno = errno;
}
/*-----------------------------------------------------------------------*/
/**
* Returns the AFS specific error number (code). This code can be interpreted
* by use of the <code>{@link ErrorTable}</code> class method
* <code>{@link ErrorTable#getMessage(int)}</code>.
*
* @return the AFS error code of this <code>AFSException</code>
* object.
* @see ErrorTable#getMessage(int)
*/
public int getErrorCode()
{
return errno;
}
/*-----------------------------------------------------------------------*/
/**
* Returns the error message string of this exception.
*
* @return the error message string of this exception object.
*
* @see #getAFSMessage()
*/
public String getMessage()
{
String msg = super.getMessage();
return (msg == null) ? ErrorTable.getMessage(errno) : msg;
}
/*-----------------------------------------------------------------------*/
/**
* Returns the locale specific error message string of this exception.
*
* @return the error message string of this exception object.
* @param locale the locale for which this message will be displayed
*
* @see #getAFSMessage()
*/
public String getMessage(Locale locale)
{
String msg = super.getMessage();
return (msg == null) ? ErrorTable.getMessage(errno, locale) : msg;
}
/*-----------------------------------------------------------------------*/
/**
* Returns the AFS error message string defined by the <code>ErrorTable
* </code> class. The message will be formatted according to the default
* Locale.
*
* <P> This message is also available from this object's super class
* method <code>getMessage</code>. However, this method will always return
* the string message associated with the actual AFS error code/number
* specified, whereas the {@link #getMessage()} method will return the
* string message intended for this Exception object, which may be
* an overridden message defined in the constructor of this Exception.
*
* @return the AFS error message string of this exception object.
*
* @see #getAFSMessage(Locale)
* @see AFSException#AFSException(String, int)
* @see ErrorTable#getMessage(int)
* @see java.lang.Exception#getMessage()
*/
public String getAFSMessage()
{
return ErrorTable.getMessage(errno);
}
/*-----------------------------------------------------------------------*/
/**
* Returns the AFS error message defined by the <code>ErrorTable</code>
* class. The message will be formatted according to the specified Locale.
*
* <P> This message is also available from this object's super class
* method <code>getMessage</code>. However, this method will always return
* the string message associated with the actual AFS error code/number
* specified, whereas the {@link #getMessage()} method will return the
* string message intended for this Exception object, which may be
* an overridden message defined in the constructor of this Exception.
*
* @return the AFS error message string of this exception object.
* @param locale the locale for which this message will be displayed
*
* @see #getAFSMessage()
* @see AFSException#AFSException(String, int)
* @see ErrorTable#getMessage(int, Locale)
* @see java.lang.Exception#getMessage()
*/
public String getAFSMessage(Locale locale)
{
return ErrorTable.getMessage(errno, locale);
}
/*-----------------------------------------------------------------------*/
/**
* Returns a string representation of this AFS Exception.
*
* <P> The message will be formatted according to the specified Locale.
*
* @return the AFS error message string of this exception object.
*
* @see #getAFSMessage()
* @see ErrorTable#getMessage(int)
* @see java.lang.Exception#getMessage()
*/
public String toString()
{
return "AFSException: Error Code: " + errno + "; Message: " +
getMessage();
}
/*-----------------------------------------------------------------------*/
}

View File

@ -1,195 +0,0 @@
/*
* @(#)AFSFileException.java 2.0 01/04/16
*
* Copyright (c) 2001 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openafs.jafs;
import java.util.Locale;
/**
* An exception indicating that a file related error has occured in the
* Java AFS API, in the Java AFS JNI, or in the AFS file system.
*
* <P> This exception extends Java's <code>java.io.IOException</code>
* and is therefore often used as a substitution for
* {@link java.io.IOException}.
*
* @version 2.0, 04/16/2001
* @version 1.0, 05/25/2000
* @see AFSException
* @see java.io.IOException
*/
public class AFSFileException extends java.io.IOException
{
/**
* The AFS specific error number (code).
* @see #getErrorCode()
*/
protected int errno;
/**
* Constructs an <code>AFSFileException</code> with the specified detail
* message.
*
* @param reason the detail message.
*/
public AFSFileException (String reason)
{
super(reason);
}
/*-----------------------------------------------------------------------*/
/**
* Returns the AFS specific error number (code). This code can be interpreted
* by use of the <code>{@link ErrorTable}</code> class method
* <code>{@link ErrorTable#getMessage(int)}</code>.
*
* @return the AFS error code of this <code>AFSException</code>
* object.
* @see ErrorTable#getMessage(int)
*/
public int getErrorCode()
{
return errno;
}
/*-----------------------------------------------------------------------*/
/**
* Returns the error message string of this exception.
*
* @return the error message string of this exception object.
*
* @see #getAFSMessage()
*/
public String getMessage()
{
String msg = super.getMessage();
return (msg == null) ? ErrorTable.getMessage(errno) : msg;
}
/*-----------------------------------------------------------------------*/
/**
* Returns the locale specific error message string of this exception.
*
* @return the error message string of this exception object.
* @param locale the locale for which this message will be displayed
*
* @see #getAFSMessage()
*/
public String getMessage(Locale locale)
{
String msg = super.getMessage();
return (msg == null) ? ErrorTable.getMessage(errno, locale) : msg;
}
/**
* Constructs an <code>AFSFileException</code> with the specified error
* code. This constructor will also generate the appropriate error message
* respective to the specified error code.
*
* @param errno the AFS error number (error code).
*/
public AFSFileException (int errno)
{
super(ErrorTable.getMessage( (errno == 0) ? ErrorTable.UNKNOWN : errno ));
this.errno = (errno == 0) ? ErrorTable.UNKNOWN : errno;
}
/**
* Constructs an <code>AFSFileException</code> with the specified detail
* message and specified error code. In this constructor the specified
* detail message overrides the default AFS error message defined by the
* <code>ErrorTable</code> class. Therefore, to retrieve the AFS specific
* error message, you must use the <code>{@link #getAFSMessage}
* </code> method. The <code>{@link #getMessage}</code> method will return
* the message specified in this constructor.
*
* @param reason the detail message.
* @param errno the AFS error number (error code).
* @see #getAFSMessage()
*/
public AFSFileException (String reason, int errno)
{
super( (reason == null) ? ErrorTable.getMessage( errno ) : reason );
this.errno = errno;
}
/*-----------------------------------------------------------------------*/
/**
* Returns the AFS error message string defined by the <code>ErrorTable
* </code> class. The message will be formatted according to the default
* Locale.
*
* <P> This message is also available from this object's super class
* method <code>getMessage</code>. However, this method will always return
* the string message associated with the actual AFS error code/number
* specified, whereas the {@link #getMessage()} method will return the
* string message intended for this Exception object, which may be
* an overridden message defined in the constructor of this Exception.
*
* @return the AFS error message string of this exception object.
*
* @see #getAFSMessage(Locale)
* @see AFSFileException#AFSFileException(String, int)
* @see ErrorTable#getMessage(int)
* @see java.lang.Exception#getMessage()
*/
public String getAFSMessage()
{
return ErrorTable.getMessage(errno);
}
/*-----------------------------------------------------------------------*/
/**
* Returns the AFS error message defined by the <code>ErrorTable</code>
* class. The message will be formatted according to the specified Locale.
*
* <P> This message is also available from this object's super class
* method <code>getMessage</code>. However, this method will always return
* the string message associated with the actual AFS error code/number
* specified, whereas the {@link #getMessage()} method will return the
* string message intended for this Exception object, which may be
* an overridden message defined in the constructor of this Exception.
*
* @return the AFS error message string of this exception object.
* @param locale the locale for which this message will be displayed
*
* @see #getAFSMessage()
* @see AFSFileException#AFSFileException(String, int)
* @see ErrorTable#getMessage(int, Locale)
* @see java.lang.Exception#getMessage()
*/
public String getAFSMessage(Locale locale)
{
return ErrorTable.getMessage(errno, locale);
}
/*-----------------------------------------------------------------------*/
/**
* Returns a string representation of this AFS Exception.
*
* @return the AFS error message string of this
* <code>AFSFileException</code> object.
*
* @see #getMessage()
*/
public String toString()
{
return "AFSFileException: Error Code: " + errno + "; Message: " +
getMessage();
}
/*-----------------------------------------------------------------------*/
}

View File

@ -1,202 +0,0 @@
/*
* @(#)AFSSecurityException.java 2.0 01/04/16
*
* Copyright (c) 2001 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openafs.jafs;
import java.util.Locale;
/**
* An exception indicating that a security related error has occured in the
* Java AFS API, in the Java AFS JNI, or in the AFS file system.
*
* @version 1.0, 04/16/2001
* @see AFSException
*/
public class AFSSecurityException extends SecurityException
{
/**
* The AFS specific error number (code).
* @see #getErrorCode()
*/
protected int errno;
/**
* Constructs an <code>AFSSecurityException</code> with the specified detail
* message.
*
* @param reason the detail message.
*/
public AFSSecurityException (String reason)
{
super(reason);
}
/**
* Constructs an <code>AFSSecurityException</code> with the specified error
* code. This constructor will also generate the appropriate error message
* respective to the specified error code.
*
* @param errno the AFS error number (error code).
*/
public AFSSecurityException (int errno)
{
super(ErrorTable.getMessage( (errno == 0) ? ErrorTable.UNKNOWN : errno ));
this.errno = (errno == 0) ? ErrorTable.UNKNOWN : errno;
}
/**
* Constructs an <code>AFSFileException</code> with the specified detail
* message and specified error code. In this constructor the specified
* detail message overrides the default AFS error message defined by the
* <code>ErrorTable</code> class. Therefore, to retrieve the AFS specific
* error message, you must use the <code>{@link #getAFSMessage}
* </code> method. The <code>{@link #getMessage}</code> method will return
* the message specified in this constructor.
*
* @param reason the detail message.
* @param errno the AFS error number (error code).
* @see #getAFSMessage()
*/
public AFSSecurityException (String reason, int errno)
{
super( (reason == null) ? ErrorTable.getMessage( errno ) : reason );
this.errno = errno;
}
/*-----------------------------------------------------------------------*/
/**
* Returns the AFS specific error number (code). This code can be interpreted
* by use of the <code>{@link ErrorTable}</code> class method
* <code>{@link ErrorTable#getMessage(int)}</code>.
*
* @return the AFS error code of this <code>AFSException</code>
* object.
* @see ErrorTable#getMessage(int)
*/
public int getErrorCode()
{
return errno;
}
/*-----------------------------------------------------------------------*/
/**
* Returns the error message string of this exception.
*
* @return the error message string of this exception object.
*
* @see #getAFSMessage()
*/
public String getMessage()
{
String msg = super.getMessage();
return (msg == null) ? ErrorTable.getMessage(errno) : msg;
}
/*-----------------------------------------------------------------------*/
/**
* Returns the locale specific error message string of this exception.
*
* @return the error message string of this exception object.
* @param locale the locale for which this message will be displayed
*
* @see #getAFSMessage()
*/
public String getMessage(Locale locale)
{
String msg = super.getMessage();
return (msg == null) ? ErrorTable.getMessage(errno, locale) : msg;
}
/*-----------------------------------------------------------------------*/
/**
* Returns the AFS error message string defined by the <code>ErrorTable
* </code> class. The message will be formatted according to the default
* Locale.
*
* <P> This message is also available from this object's super class
* method <code>getMessage</code>. However, this method will always return
* the string message associated with the actual AFS error code/number
* specified, whereas the {@link #getMessage()} method will return the
* string message intended for this Exception object, which may be
* an overridden message defined in the constructor of this Exception.
*
* @return the AFS error message string of this exception object.
*
* @see #getAFSMessage(Locale)
* @see AFSSecurityException#AFSSecurityException(String, int)
* @see ErrorTable#getMessage(int)
* @see java.lang.Exception#getMessage()
*/
public String getAFSMessage()
{
return ErrorTable.getMessage(errno);
}
/*-----------------------------------------------------------------------*/
/**
* Returns the AFS error message defined by the <code>ErrorTable</code>
* class. The message will be formatted according to the specified Locale.
*
* <P> This message is also available from this object's super class
* method <code>getMessage</code>. However, this method will always return
* the string message associated with the actual AFS error code/number
* specified, whereas the {@link #getMessage()} method will return the
* string message intended for this Exception object, which may be
* an overridden message defined in the constructor of this Exception.
*
* @return the AFS error message string of this exception object.
* @param locale the locale for which this message will be displayed
*
* @see #getAFSMessage()
* @see AFSSecurityException#AFSSecurityException(String, int)
* @see ErrorTable#getMessage(int, Locale)
* @see java.lang.Exception#getMessage()
*/
public String getAFSMessage(Locale locale)
{
return ErrorTable.getMessage(errno, locale);
}
/*-----------------------------------------------------------------------*/
/**
* Returns a string representation of this AFS Exception.
*
* @return the AFS error message string of this
* <code>AFSSecurityException</code> object.
*
* @see #getMessage()
*/
public String toString()
{
return "AFSSecurityException: Error Code: " + errno + "; Message: " +
getMessage();
}
/*-----------------------------------------------------------------------*/
}

File diff suppressed because it is too large Load Diff

View File

@ -1,203 +0,0 @@
/*
* @(#)ErrorTable.java 2.0 11/06/2000
*
* Copyright (c) 2001 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openafs.jafs;
import java.util.ResourceBundle;
import java.util.Locale;
/**
* Static class for error code message management.
*
* <P>Simply translates all error codes returned by the AFS native library
* to literal string messages according to the defined locale.
*
* @version 2.0, 11/06/2000
*/
public final class ErrorTable
{
/* Undefined Error Constants */
public static final int UNKNOWN = -3;
public static final int SPECIAL_CASE = -2;
public static final int GENERAL_FAILURE = -1;
/* Java Application Error Constants */
public static final int NULL = 1000;
public static final int INVALID_SESSION = 1001;
public static final int EXPIRED_SESSION = 1002;
public static final int OPERATION_ABORTED = 1003;
public static final int FORCED_ABORT = 1004;
/* General UNIX Error Constants */
public static final int NOT_PERMITTED = 1;
public static final int NOT_FOUND = 2;
public static final int IO_ERROR = 5;
public static final int NO_DEVICE_ADDRESS = 6;
public static final int BAD_FILE = 9;
public static final int TRY_AGAIN = 11;
public static final int OUT_OF_MEMORY = 12;
public static final int PERMISSION_DENIED = 13;
public static final int BAD_ADDRESS = 14;
public static final int DEVICE_BUSY = 16;
public static final int FILE_EXISTS = 17;
public static final int NO_DEVICE = 19;
public static final int NOT_DIRECTORY = 20;
public static final int IS_DIRECTORY = 21;
public static final int INVALID_ARG = 22;
public static final int FILE_OVERFLOW = 23;
public static final int FILE_BUSY = 26;
public static final int NAME_TOO_LONG = 36;
public static final int DIRECTORY_NOT_EMPTY = 39;
public static final int CONNECTION_TIMED_OUT = 110;
public static final int QUOTA_EXCEEDED = 122;
/* AFS Error Constants */
public static final int BAD_USERNAME = 180486;
public static final int BAD_PASSWORD = 180490;
public static final int EXPIRED_PASSWORD = 180519;
public static final int SKEWED_CLOCK = 180514;
public static final int ID_LOCKED = 180522;
public static final int CELL_NOT_FOUND = 180501;
public static final int USERNAME_EXISTS = 180481;
public static final int USER_DOES_NOT_EXIST = 180484;
/* AFS Authentication Error Constants */
public static final int PRPERM = 267269;
public static final int UNOACCESS = 5407;
public static final int BZACCESS = 39430;
public static final int KANOAUTH = 180488;
public static final int RXKADNOAUTH = 19270405;
private static java.util.Hashtable bundles;
static
{
bundles = new java.util.Hashtable(2);
try {
bundles.put(Locale.US,
ResourceBundle.getBundle("ErrorMessages", Locale.US));
bundles.put(Locale.SIMPLIFIED_CHINESE,
ResourceBundle.getBundle("ErrorMessages", Locale.SIMPLIFIED_CHINESE));
} catch (Exception e) {
bundles.put(Locale.getDefault(),
ResourceBundle.getBundle("ErrorMessages"));
}
}
/*-----------------------------------------------------------------------*/
/**
* Tests to identify if the return code is a "Permission Denied" error.
*
* <P> This method will qualify <CODE>errno</CODE> against:
* <LI><CODE>ErrorTable.PERMISSION_DENIED</CODE>
* <LI><CODE>ErrorTable.PRPERM</CODE>
* <LI><CODE>ErrorTable.UNOACCESS</CODE>
* <LI><CODE>ErrorTable.BZACCESS</CODE>
* <LI><CODE>ErrorTable.KANOAUTH</CODE>
* <LI><CODE>ErrorTable.RXKADNOAUTH</CODE>
*
* @param errno Error Code/Number
* @return boolean If <CODE>errno</CODE> is a "Permission Denied"
* error.
*/
public static boolean isPermissionDenied(int errno)
{
return (errno == PERMISSION_DENIED || errno == PRPERM ||
errno == UNOACCESS || errno == BZACCESS || errno == KANOAUTH
|| errno == RXKADNOAUTH);
}
/*-----------------------------------------------------------------------*/
/**
* Returns a String message representing the error code (number) provided.
*
* <P> If the error code provided is out of range of the library of defined
* error codes, this method will return <CODE>Error number [###] unknown
* </CODE>. If an exception is thrown, this method will return either:
* <CODE>Unknown error</CODE>, <CODE>Special case error</CODE>, or
* <CODE>Invalid error code: ###</CODE>.
*
* @param errno Error Code/Number
* @return String Interpreted error message derived from
* <CODE>errno</CODE>.
*/
public static String getMessage(int errno)
{
return getMessage(errno, Locale.getDefault());
}
/*-----------------------------------------------------------------------*/
/**
* Returns a String message, respective to the provided locale, representing
* the error code (number) provided.
*
* <P> If the error code provided is out of range of the library of defined
* error codes, this method will return <CODE>Error number [###] unknown
* </CODE>. If an exception is thrown, this method will return either:
* <CODE>Unknown error</CODE>, <CODE>Special case error</CODE>, or
* <CODE>Invalid error code: ###</CODE>.
*
* @param errno Error Code/Number
* @param locale Locale of to be used for translating the message.
* @return String Interpreted error message derived from
* <CODE>errno</CODE>.
*/
public static String getMessage(int errno, Locale locale)
{
String msg = "Error number [" + errno + "] unknown.";
try {
msg = getBundle(locale).getString("E" + errno);
} catch (Exception e) {
try {
if (errno == 0) {
msg = "";
} else if (errno == GENERAL_FAILURE) {
msg = getBundle(locale).getString("GENERAL_FAILURE");
} else if (errno == UNKNOWN) {
msg = getBundle(locale).getString("UNKNOWN");
} else if (errno == SPECIAL_CASE) {
msg = getBundle(locale).getString("SPECIAL_CASE");
} else {
System.err.println("ERROR in ErrorCode getMessage(): " + e);
msg = "Invaid error code: " + errno;
}
} catch (Exception e2) {
//INGORE
}
} finally {
return msg;
}
}
/*-----------------------------------------------------------------------*/
private static ResourceBundle getBundle(Locale locale) throws Exception
{
if (locale == null) return getBundle(Locale.getDefault());
ResourceBundle rb = (ResourceBundle)bundles.get(locale);
if (rb == null) {
rb = ResourceBundle.getBundle("ErrorMessages", locale);
bundles.put(locale, rb);
}
return rb;
}
}

View File

@ -1,942 +0,0 @@
/*
* @(#)File.java 1.3 10/12/2000
*
* Copyright (c) 2001 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openafs.jafs;
import java.io.IOException;
import java.util.ArrayList;
/*****************************************************************************/
/**
*
* An abstract representation of AFS file and directory pathnames.
*
* This class is an extension of the standard Java File class with file-based
* manipulation methods overridden by integrated AFS native methods.
*
* <p> Extension methods include:
*
* <ol>
* <li> <code>{@link #isMountPoint}</code>
* <li> <code>{@link #isLink}</code>
* <li> <code>{@link #isValidated}</code>
* <li> <code>{@link #validate}</code>
* <li> <code>{@link #refresh}</code>
* <li> <code>{@link #getErrorCode}</code>
* <li> <code>{@link #getErrorMessage}</code>
* </ol>
*
* <p> For performance optimization, all newly constructed <code>File</code>
* objects are only validated once. Furthermore, if an abstract pathname
* denotes a symbolic-link, then the {@link #isLink} attribute is set
* to true and the {@link #getTarget} field member is populated with
* this symbolic-link's target resource. (see {@link #getTarget})
*
* <p> If you are interested in validating the target resource, simply
* call {@link #validate} before calling any of the attribute accessors.
* This action will <code>stat</code> the target resource, identifying
* its associated attributes and populating them in this objects field
* members.
*
* <p> Following is an example of how to construct a new AFS File Object:
* <p><blockquote><pre>
* try {
* File file = new File("/afs/mycell.com/proj/");
* if (file.isDirectory()) {
* System.out.println("This is a directory.");
* } else if (file.isLink()) {
* System.out.println("This is a symbolic-link.");
* System.out.println(" Its target is: " + file.getTarget());
* file.validate();
* if (file.isFile()) {
* System.out.println(" This object is now a file!");
* } else if (file.isDirectory()) {
* System.out.println(" This object is now a directory!");
* } else if (file.isMountPoint()) {
* System.out.println(" This object is now a volume mount point!");
* }
* } else if (file.isMountPoint()) {
* System.out.println("This is a volume mount point.");
* } else if (file.isFile()) {
* System.out.println("This is file.");
* System.out.println(" its size is: " + file.length());
* }
* } catch (AFSFileException ae) {
* System.out.println("AFS Exception: " + ae.getMessage());
* System.out.println("AFS Error Code: " + ae.getErrorCode());
* } catch (Exception e) {
* System.out.println("Exception: " + e.getMessage());
* e.printStackTrace();
* }
* </pre></blockquote>
*
* @version 2.0, 04/16/2001 - Completely revised class for efficiency.
* @version 1.3, 10/12/2000 - Introduced error code capture from native methods.
* @version 1.2, 05/30/2000
*/
public class File extends java.io.File implements Comparable
{
private String path;
private String type;
private String target;
/** Each member is mutually exclusive */
private boolean isMountPoint = false;
private boolean isDirectory = false;
private boolean isFile = false;
private boolean isLink = false;
private boolean exists;
private long lastModified;
private long length;
private ACL.Entry acl;
private boolean validated = false;
private long dirHandle;
private int permissionsMask;
private int errno;
/**
* Creates a new <code>File</code> instance by converting the given
* pathname string into an abstract pathname and validating it against
* the file system. If the given string is an empty string, then the
* result is the empty abstract pathname; otherwise the abstract pathname
* is <code>validated</code> to represent a qualified file object.
*
* @param pathname A pathname string
* @throws NullPointerException
* If the <code>pathname</code> argument is <code>null</code>
* @throws AFSFileException
* If the user constructing this AFS file object is denied
* access to stat the file or simply a stat cannot be performed
* on the file. The reason code and message will be available
* from {@link org.openafs.jafs.AFSFileException#getErrorCode} and
* {@link org.openafs.jafs.AFSFileException#getMessage} respectively.
* <p> This exception <U>will not</U> be thrown if the file does not
* exist. Rather, the {@link #exists} attribute will be set to
* <code>false</code>.
* @see #validate()
*/
public File(String pathname) throws AFSFileException
{
super(pathname);
path = getAbsolutePath();
validated = setAttributes();
if (!validated) throw new AFSFileException(errno);
}
/**
* Creates a new <code>File</code> instance by converting the given
* pathname string into an abstract pathname. If the given string is
* an empty string, then the result is the empty abstract pathname.
*
* <p> The abstract pathname will remain <B>abstract</B> unless the
* <code>validate</code> parameter is set to <code>true</code>. This
* means that the abstract pathname will <U>not</U> be <code>validated</code>
* and therefore the file object will not represent a qualified, attributed,
* AFS file resource. Rather, this constructor provides a method by which
* you can construct a non-validated <code>File</code> object (one that
* does not contain the file's complete status information).
*
* <p> This constructor is useful for creating file objects of file/path names
* that you know exist, however are unauthorized to <code>validate</code> (or
* <code>stat</code> - to obtain complete status information). For example,
* if you are permitted to <code>lookup</code> (see: {@link #canLookup}) the
* contents of a given directory yet <U>not</U> permitted to <code>read</code>
* (see: {@link #canRead}), then this constructor would enable you to render the
* contents of the directory without validating each entry.
*
* <p> <B>Please note:</B> this is the only constructor that does not throw an AFSFileException.
*
* @param pathname A pathname string
* @param validate A boolean flag to indicate if this abstract path
* should be validated.
* @throws NullPointerException
* If the <code>pathname</code> argument is <code>null</code>
* @see #File(String)
* @see #validate()
*/
public File(String pathname, boolean validate)
{
super(pathname);
path = getAbsolutePath();
if (validate) validated = setAttributes();
}
/**
* Creates a new <code>File</code> instance from a parent pathname string
* and a child pathname string and validates it against the file system.
*
* <p> If <code>parent</code> is <code>null</code> then the new
* <code>File</code> instance is created as if by invoking the
* single-argument <code>File</code> constructor on the given
* <code>filename</code> string (child pathname).
*
* <p> Otherwise the <code>parent</code> pathname string is taken to denote
* a directory, and the <code>filename</code> string is taken to
* denote either a directory or a file. The directory or file will then be
* <code>validated</code> to represent a qualified file object.
*
* @param parent The parent pathname string
* @param filename This file's pathname string (child of specified parent)
* @throws NullPointerException
* If <code>child</code> is <code>null</code>
* @throws AFSFileException
* If the user constructing this AFS file object is denied
* access to stat the file or simply a stat cannot be performed
* on the file. The reason code and message will be available
* from {@link org.openafs.jafs.AFSFileException#getErrorCode} and
* {@link org.openafs.jafs.AFSFileException#getMessage} respectively.
* <p> This exception <U>will not</U> be thrown if the file does not
* exist. Rather, the {@link #exists} attribute will be set to
* <code>false</code>.
* @see #validate()
*/
public File(String parent, String filename) throws AFSFileException
{
super(parent, filename);
path = getAbsolutePath();
validated = setAttributes();
if (!validated) throw new AFSFileException(errno);
}
/**
* Creates a new <code>File</code> instance from a parent pathname string
* and a child pathname string.
*
* <p> If <code>parent</code> is <code>null</code> then the new
* <code>File</code> instance is created as if by invoking the
* single-argument <code>File</code> constructor on the given
* <code>filename</code> string (child pathname).
*
* <p> Otherwise the <code>parent</code> pathname string is taken to denote
* a directory, and the <code>filename</code> string is taken to
* denote either a directory or a file.
*
* <p> The abstract pathname will remain <B>abstract</B> unless the
* <code>validate</code> parameter is set to <code>true</code>. This
* means that the abstract pathname will <U>not</U> be <code>validated</code>
* and therefore the file object will not represent a qualified, attributed,
* AFS file resource. Rather, this constructor provides a method by which
* you can construct a non-validated <code>File</code> object (one that
* does not contain the file's complete status information).
*
* <p> This constructor is useful for creating file objects of file/path names
* that you know exist, however are unauthorized to <code>validate</code> (or
* <code>stat</code> - to obtain complete status information). For example,
* if you are permitted to <code>lookup</code> (see: {@link #canLookup}) the
* contents of a given directory yet <U>not</U> permitted to <code>read</code>
* (see: {@link #canRead}), then this constructor would enable you to render the
* contents of the directory without validating each entry.
*
* @param parent The parent pathname string
* @param filename This file's pathname string (child of specified parent)
* @param validate A boolean flag to indicate if this abstract path
* should be validated.
* @throws NullPointerException
* If <code>child</code> is <code>null</code>
* @throws AFSFileException
* If the user constructing this AFS file object is denied
* access to stat the file or simply a stat cannot be performed
* on the file. The reason code and message will be available
* from {@link org.openafs.jafs.AFSFileException#getErrorCode} and
* {@link org.openafs.jafs.AFSFileException#getMessage} respectively.
* <p> This exception <U>will not</U> be thrown if the file does not
* exist. Rather, the {@link #exists} attribute will be set to
* <code>false</code>.
* @see #File(String, String)
* @see #validate()
*/
public File(String parent, String filename, boolean validate) throws AFSFileException
{
super(parent, filename);
path = getAbsolutePath();
if (validate) {
validated = setAttributes();
if (!validated) throw new AFSFileException(errno);
}
}
/**
* Creates a new <code>File</code> instance from a parent abstract
* pathname and a child pathname string and validates it against the file system.
*
* <p> If <code>parent</code> is <code>null</code> then the new
* <code>File</code> instance is created as if by invoking the
* single-argument <code>File</code> constructor on the given
* <code>filename</code> string (child pathname).
*
* <p> Otherwise the <code>parent</code> abstract pathname is taken to
* denote a directory, and the <code>filename</code> string is taken
* to denote either a directory or a file. The directory or file will then be
* <code>validated</code> to represent a qualified file object.
*
* @param parent The parent abstract pathname
* @param filename This file's pathname string (child of specified parent)
* @param validate A boolean flag to indicate if this abstract path
* should be validated.
* @throws NullPointerException
* If <code>child</code> is <code>null</code>
* @throws AFSFileException
* If the user constructing this AFS file object is denied
* access to stat the file or simply a stat cannot be performed
* on the file. The reason code and message will be available
* from {@link org.openafs.jafs.AFSFileException#getErrorCode} and
* {@link org.openafs.jafs.AFSFileException#getMessage} respectively.
* <p> This exception <U>will not</U> be thrown if the file does not
* exist. Rather, the {@link #exists} attribute will be set to
* <code>false</code>.
* @see #validate()
*/
public File(File parent, String filename) throws AFSFileException
{
super(parent, filename);
path = getAbsolutePath();
validated = setAttributes();
if (!validated) throw new AFSFileException(errno);
}
/**
* Creates a new <code>File</code> instance from a parent abstract
* pathname and a child pathname string.
*
* <p> If <code>parent</code> is <code>null</code> then the new
* <code>File</code> instance is created as if by invoking the
* single-argument <code>File</code> constructor on the given
* <code>filename</code> string (child pathname).
*
* <p> Otherwise the <code>parent</code> abstract pathname is taken to
* denote a directory, and the <code>filename</code> string is taken
* to denote either a directory or a file.
*
* <p> The abstract pathname will remain <B>abstract</B> unless the
* <code>validate</code> parameter is set to <code>true</code>. This
* means that the abstract pathname will <U>not</U> be <code>validated</code>
* and therefore the file object will not represent a qualified, attributed,
* AFS file resource. Rather, this constructor provides a method by which
* you can construct a non-validated <code>File</code> object (one that
* does not contain the file's complete status information).
*
* <p> This constructor is useful for creating file objects of file/path names
* that you know exist, however are unauthorized to <code>validate</code> (or
* <code>stat</code> - to obtain complete status information). For example,
* if you are permitted to <code>lookup</code> (see: {@link #canLookup}) the
* contents of a given directory yet <U>not</U> permitted to <code>read</code>
* (see: {@link #canRead}), then this constructor would enable you to render the
* contents of the directory without validating each entry.
*
* @param parent The parent abstract pathname
* @param filename This file's pathname string (child of specified parent)
* @param validate A boolean flag to indicate if this abstract path
* should be validated.
* @throws NullPointerException
* If <code>child</code> is <code>null</code>
* @throws AFSFileException
* If the user constructing this AFS file object is denied
* access to stat the file or simply a stat cannot be performed
* on the file. The reason code and message will be available
* from {@link org.openafs.jafs.AFSFileException#getErrorCode} and
* {@link org.openafs.jafs.AFSFileException#getMessage} respectively.
* <p> This exception <U>will not</U> be thrown if the file does not
* exist. Rather, the {@link #exists} attribute will be set to
* <code>false</code>.
* @see #validate()
* @see #File(File, String)
*/
public File(File parent, String filename, boolean validate) throws AFSFileException
{
super(parent, filename);
path = getAbsolutePath();
if (validate) {
validated = setAttributes();
if (!validated) throw new AFSFileException(errno);
}
}
/*****************************************************************************/
/**
* Validates this abstract pathname as an attributed AFS file object.
* This method will, if authorized, perform a <code>stat</code> on the
* actual AFS file and update its respective field members; defining
* this file object's attributes.
*
* @throws AFSSecurityException
* If an AFS exception occurs while attempting to stat and set this
* AFS file object's attributes.
*/
public void validate() throws AFSSecurityException
{
validated = setAttributes();
if (!validated) throw new AFSSecurityException(errno);
}
/**
* Tests whether the file denoted by this abstract pathname has
* been validated.
*
* <P> Validation is always attempted upon construction of the file object,
* therefore if this method returns false, then you are not permitted to
* <code>validate</code> this file and consequently all attribute accessors
* will be invalid.
*
* <P> This method should return <code>true</code> even if this abstract
* pathname does not exist. If this is abstract pathname does not exist then
* the <code>{@link #exists}</code> method should return false, however this
* implies that the attribute accessors are valid and accurate; thus implying
* successful validation.
*
* <P> This method is useful before calling any of the attribute accessors
* to ensure a valid response.
*
* @return <code>true</code> if and only if the file denoted by this
* abstract pathname has been validated during or after object construction;
* <code>false</code> otherwise
*/
public boolean isValidated()
{
return validated;
}
/**
* Refreshes this AFS file object by updating its attributes.
* This method currently provides the same functionality as
* {@link #validate}.
*
* @throws AFSSecurityException
* If an AFS exception occurs while attempting to stat and update this
* AFS file object's attributes.
* @see #validate()
*/
public void refresh() throws AFSSecurityException
{
validate();
}
/*-------------------------------------------------------------------------*/
/**
* Tests whether the file denoted by this abstract pathname is a
* directory.
*
* @return <code>true</code> if and only if the file denoted by this
* abstract pathname exists <em>and</em> is a directory;
* <code>false</code> otherwise
*/
public boolean isDirectory()
{
return (isDirectory || isMountPoint) ? true : false;
}
/**
* Tests whether the file denoted by this abstract pathname is a normal
* file. A file is <em>normal</em> if it is not a directory and, in
* addition, satisfies other system-dependent criteria. Any non-directory
* file created by a Java application is guaranteed to be a normal file.
*
* @return <code>true</code> if and only if the file denoted by this
* abstract pathname exists <em>and</em> is a normal file;
* <code>false</code> otherwise
*/
public boolean isFile()
{
return isFile;
}
/**
* Tests whether the file denoted by this abstract pathname is an
* AFS Volume Mount Point.
*
* @return <code>true</code> if and only if the file denoted by this
* abstract pathname exists <em>and</em> is a mount point;
* <code>false</code> otherwise
*/
public boolean isMountPoint()
{
return isMountPoint;
}
/**
* Tests whether the file denoted by this abstract pathname is a
* symbolic-link.
*
* @return <code>true</code> if and only if the file denoted by this
* abstract pathname exists <em>and</em> is a symbolic-link;
* <code>false</code> otherwise
*/
public boolean isLink()
{
return isLink;
}
/*-------------------------------------------------------------------------*/
/**
* Tests whether the file denoted by this abstract pathname exists.
*
* @return <code>true</code> if and only if the file denoted by this
* abstract pathname exists; <code>false</code> otherwise
*/
public boolean exists()
{
return exists;
}
/**
* Returns the time that the file denoted by this abstract pathname was
* last modified.
*
* @return A <code>long</code> value representing the time the file was
* last modified, measured in milliseconds since the epoch
* (00:00:00 GMT, January 1, 1970), or <code>0L</code> if the
* file does not exist or if an I/O error occurs
*/
public long lastModified()
{
return lastModified;
}
/**
* Returns the length of the file denoted by this abstract pathname.
*
* @return The length, in bytes, of the file denoted by this abstract
* pathname, or <code>0L</code> if the file does not exist
*/
public long length()
{
return length;
}
/**
* Returns an abstract pathname string that represents the target resource of
* of this file, if it is a symbolic-link.
*
* <p> If this abstract pathname <B>does not</B> denote a symbolic-link, then this
* method returns <code>null</code>. Otherwise a string is
* returned that represents the target resource of this symbolic-link.
*
* @return A string representation of this symbolic-link's target resource.
* @see #isLink()
*/
public String getTarget()
{
return target;
}
/**
* Returns an array of strings naming the files and directories in the
* directory denoted by this abstract pathname.
*
* <p> If this abstract pathname does not denote a directory, then this
* method returns <code>null</code>. Otherwise an array of strings is
* returned, one for each file or directory in the directory. Names
* denoting the directory itself and the directory's parent directory are
* not included in the result. Each string is a file name rather than a
* complete path.
*
* <p> There is no guarantee that the name strings in the resulting array
* will appear in any specific order; they are not, in particular,
* guaranteed to appear in alphabetical order.
*
* @return An array of strings naming the files and directories in the
* directory denoted by this abstract pathname. The array will be
* empty if the directory is empty. Returns <code>null</code> if
* this abstract pathname does not denote a directory, or if an
* I/O error occurs.
*/
public String[] list()
{
try {
if (isFile()) {
errno = ErrorTable.NOT_DIRECTORY;
return null;
}
ArrayList buffer = new ArrayList();
dirHandle = listNative(buffer);
if (dirHandle == 0) {
return null;
} else {
return (String[])buffer.toArray(new String[0]);
}
} catch (Exception e) {
System.out.println(e);
return null;
}
}
/**
* Returns an ArrayList object containing strings naming the files and
* directories in the directory denoted by this abstract pathname.
*
* <p> If this abstract pathname does not denote a directory, then this
* method returns <code>null</code>. Otherwise an array of strings is
* returned, one for each file or directory in the directory. Names
* denoting the directory itself and the directory's parent directory are
* not included in the result. Each string is a file name rather than a
* complete path.
*
* <p> There is no guarantee that the name strings in the resulting array
* will appear in any specific order; they are not, in particular,
* guaranteed to appear in alphabetical order.
*
* @return An array of strings naming the files and directories in the
* directory denoted by this abstract pathname. The array will be
* empty if the directory is empty. Returns <code>null</code> if
* this abstract pathname does not denote a directory, or if an
* I/O error occurs.
* @throws AFSSecurityException
* If you are not authorized to list the contents of this directory
* @throws AFSFileException
* If this file object is not a <code>mount point</code>, <code>link
* </code>, or <code>directory</code> <B>or</B> an unexpected AFS
* error occurs.
* @see #list()
*/
public ArrayList listArray() throws AFSFileException
{
try {
if (isFile()) throw new AFSFileException(ErrorTable.NOT_DIRECTORY);
ArrayList buffer = new ArrayList();
dirHandle = listNative(buffer);
if (dirHandle == 0) {
if (errno == ErrorTable.PERMISSION_DENIED) {
throw new AFSSecurityException(errno);
} else {
throw new AFSFileException(errno);
}
} else {
return buffer;
}
} catch (Exception e) {
System.out.println(e);
throw new AFSFileException(errno);
}
}
/*-------------------------------------------------------------------------*/
/**
* Deletes the file or directory denoted by this abstract pathname. If
* this pathname denotes a directory, then the directory must be empty in
* order to be deleted.
*
* @return <code>true</code> if and only if the file or directory is
* successfully deleted; <code>false</code> otherwise
*/
public boolean delete()
{
try {
if(this.isDirectory()) {
return this.rmdir();
} else if(this.isFile() || this.isLink()) {
return this.rmfile();
}
return false;
} catch (Exception e) {
System.out.println(e);
return false;
}
}
/**
* Copies the file denoted by this abstract pathname to the destination
* file provided. Then checks the newly copied file's size to
* test for file size consistency.
*
* @param dest The new abstract pathname for the named file
*
* @return <code>true</code> if and only if the file that was copied
* reports the same file size (length) as that of this file;
* <code>false</code> otherwise
*
* @throws AFSFileException
* If an I/O or AFS exception is encountered while copying the file.
*/
public boolean copyTo(File dest) throws AFSFileException
{
FileInputStream fis = new FileInputStream(this);
FileOutputStream fos = new FileOutputStream(dest);
byte[] buf = new byte[1024];
int i = 0;
while((i=fis.read(buf))!=-1) {
fos.write(buf, 0, i);
}
fis.close();
fos.close();
dest.validate();
return (dest.length() == this.length());
}
/*-------------------------------------------------------------------------*/
/**
* Returns the permissions mask of the ACL for this object relative to the user accessing it.
*
* @return the permissions mask of this object based upon the current user.
* @see org.openafs.jafs.ACL.Entry#getPermissionsMask()
*/
public int getPermissionsMask()
{
return getRights();
}
/**
* Tests whether the user can administer the ACL (see: {@link org.openafs.jafs.ACL}
* of the directory denoted by this abstract pathname.
*
* @see org.openafs.jafs.ACL.Entry#canAdmin
* @return <code>true</code> if and only if the directory specified by this
* abstract pathname exists <em>and</em> can be administered by the
* current user; <code>false</code> otherwise
*/
public boolean canAdmin()
{
if (acl == null) acl = new ACL.Entry(getRights());
return acl.canAdmin();
}
/**
* Tests whether the current user can delete the files or subdirectories of
* the directory denoted by this abstract pathname.
*
* @see org.openafs.jafs.ACL.Entry#canDelete
* @return <code>true</code> if and only if the directory specified by this
* abstract pathname exists <em>and</em> permits deletion of its files
* and subdirectories by the current user; <code>false</code> otherwise
*/
public boolean canDelete()
{
if (acl == null) acl = new ACL.Entry(getRights());
return acl.canDelete();
}
/**
* Tests whether the current user can insert a file into the directory
* denoted by this abstract pathname.
*
* @see org.openafs.jafs.ACL.Entry#canInsert
* @return <code>true</code> if and only if the directory specified by this
* abstract pathname exists <em>and</em> a file can be inserted by the
* current user; <code>false</code> otherwise
*/
public boolean canInsert()
{
if (acl == null) acl = new ACL.Entry(getRights());
return acl.canInsert();
}
/**
* Tests whether the current user can lock the file denoted by this
* abstract pathname.
*
* @see org.openafs.jafs.ACL.Entry#canLock
* @return <code>true</code> if and only if the file specified by this
* abstract pathname exists <em>and</em> can be locked by the
* current user; <code>false</code> otherwise
*/
public boolean canLock()
{
if (acl == null) acl = new ACL.Entry(getRights());
return acl.canLock();
}
/**
* Tests whether the current user can lookup the contents of the directory
* denoted by this abstract pathname.
*
* @see org.openafs.jafs.ACL.Entry#canLookup
* @return <code>true</code> if and only if the directory specified by this
* abstract pathname exists <em>and</em> its contents can be listed by the
* current user; <code>false</code> otherwise
*/
public boolean canLookup()
{
if (acl == null) acl = new ACL.Entry(getRights());
return acl.canLookup();
}
/**
* Tests whether the current user can read the file denoted by this
* abstract pathname.
*
* @see org.openafs.jafs.ACL.Entry#canRead
* @return <code>true</code> if and only if the file specified by this
* abstract pathname exists <em>and</em> can be read by the
* current user; <code>false</code> otherwise
*/
public boolean canRead()
{
if (acl == null) acl = new ACL.Entry(getRights());
return acl.canRead();
}
/**
* Tests whether the current user can modify to the file denoted by this
* abstract pathname.
*
* @see org.openafs.jafs.ACL.Entry#canWrite
* @return <code>true</code> if and only if the file system actually
* contains a file denoted by this abstract pathname <em>and</em>
* the current user is allowed to write to the file;
* <code>false</code> otherwise.
*/
public boolean canWrite()
{
if (acl == null) acl = new ACL.Entry(getRights());
return acl.canWrite();
}
/*-------------------------------------------------------------------------*/
/**
* Closes the directory denoted by this abstract pathname.
*
* @return <code>true</code> if and only if the directory is
* successfully closed; <code>false</code> otherwise
*/
public boolean close()
{
if (dirHandle == 0) {
return false;
}
return closeDir(dirHandle);
}
/*-------------------------------------------------------------------------*/
/**
* Returns the AFS specific error number (code). This code can be interpreted
* by use of <code>{@link org.openafs.jafs.ErrorTable}</code> static class method
* <code>{@link org.openafs.jafs.ErrorTable#getMessage}</code>
*
* @return the AFS error code (number) associated with the last action performed
* on this object.
* @see org.openafs.jafs.ErrorTable#getMessage(int)
*/
public int getErrorCode()
{
return errno;
}
/**
* Returns the AFS error message string defined by the <code>{@link org.openafs.jafs.ErrorTable}</code>
* class.
*
* @return the AFS error message string associated with the last action performed
* on this object.
* @see org.openafs.jafs.ErrorTable#getMessage(int)
*/
public String getErrorMessage()
{
return ErrorTable.getMessage(errno);
}
/////////////// custom override methods ////////////////////
/**
* Compares two File objects relative to their filenames and <B>does not</B>
* compare their respective absolute paths. Alphabetic case is significant in
* comparing filenames.
*
* @param file The File object to be compared to this file's filename
*
* @return Zero if the argument is equal to this file's filename, a
* value less than zero if this file's filename is
* lexicographically less than the argument, or a value greater
* than zero if this file's filename is lexicographically
* greater than the argument
*
* @since JDK1.2
*/
public int compareTo(File file) {
return this.getName().compareTo(file.getName());
}
/**
* Compares this file to another File object. If the other object
* is an abstract pathname, then this function behaves like <code>{@link
* #compareTo(File)}</code>. Otherwise, it throws a
* <code>ClassCastException</code>, since File objects can only be
* compared to File objects.
*
* @param o The <code>Object</code> to be compared to this abstract pathname
*
* @return If the argument is an File object, returns zero
* if the argument is equal to this file's filename, a value
* less than zero if this file's filename is lexicographically
* less than the argument, or a value greater than zero if this
* file's filename is lexicographically greater than the
* argument
*
* @throws <code>ClassCastException</code> if the argument is not an
* File object
*
* @see java.lang.Comparable
* @since JDK1.2
*/
public int compareTo(Object o) throws ClassCastException
{
File file = (File)o;
return compareTo(file);
}
/////////////// public native methods ////////////////////
/**
* Creates the directory named by this abstract pathname.
*
* @return <code>true</code> if and only if the directory was
* created; <code>false</code> otherwise
*/
public native boolean mkdir();
/**
* Renames the file denoted by this abstract pathname.
*
* @param dest The new abstract pathname for the named file
*
* @return <code>true</code> if and only if the renaming succeeded;
* <code>false</code> otherwise
*
* @throws NullPointerException
* If parameter <code>dest</code> is <code>null</code>
*/
public native boolean renameTo(File dest);
/**
* Performs a file <code>stat</code> on the actual AFS file and populates
* this object's respective field members with the appropriate values.
* method will, if authorized, perform a <code>stat</code> on the
* actual AFS file and update its respective field members; defining
* this file object's attributes.
*
* <P><B>This method should not be used directly for refreshing or validating
* this AFS file object. Please use {@link #validate} instead.</B>
*
* @return <code>true</code> if and only if the current user is allowed to stat the file;
* <code>false</code> otherwise.
* @see #validate()
*/
public native boolean setAttributes() throws AFSSecurityException;
/////////////// private native methods ////////////////////
/**
* List the contents of this directory.
*
* @return the directory handle
*/
private native long listNative(ArrayList buffer) throws AFSSecurityException;
/**
* Close the currently open directory using a previously obtained handle.
*
* @return true if the directory closes without error
*/
private native boolean closeDir(long dp) throws AFSSecurityException;
/**
* Removes/deletes the current directory.
*
* @return true if the directory is removed without error
*/
private native boolean rmdir() throws AFSSecurityException;
/**
* Removes/deletes the current file.
*
* @return true if the file is removed without error
*/
private native boolean rmfile() throws AFSSecurityException;
/**
* Returns the permission/ACL mask for this directory
*
* @return permission/ACL mask
*/
private native int getRights() throws AFSSecurityException;
/*-------------------------------------------------------------------------*/
}

View File

@ -1,167 +0,0 @@
/*
* @(#)FilterInputStream.java 1.0 00/10/10
*
* Copyright (c) 2001 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openafs.jafs;
import java.io.InputStream;
/**
* This class is a file input stream for files within AFS.
* It is an input stream for reading data from a
* <code>{@link org.openafs.jafs.File}</code>.
*
* @version 2.1, 08/03/2001
* @see org.openafs.jafs.File
* @see org.openafs.jafs.FileOutputStream
* @see java.io.FileInputStream
*/
public class FileInputStream extends InputStream
{
/** Status indicator for the current state of this file input stream */
private int fileDescriptor;
/**
* Creates a <code>FileInputStream</code> by
* opening a connection to an actual AFS file,
* the file named by the path name <code>name</code>
* in the AFS file system.
*
* @param name the name of the file to read from
* @exception AFSFileException If an AFS specific error occurs,
* if the file does not, or cannot be opened for any
* other reason, including authorization.
*/
public FileInputStream(String name) throws AFSFileException
{
this.fileDescriptor = this.openReadOnly(name);
}
/**
* Creates a <code>FileInputStream</code> by
* opening a connection to an actual AFS file,
* the file represented by file <code>file</code>
* in the AFS file system.
*
* @param file an AFS file object representing a file to read from
* @exception AFSFileException If an AFS specific error occurs,
* if the file does not, or cannot be opened for any
* other reason, including authorization.
*/
public FileInputStream(File file) throws AFSFileException
{
this(file.getPath());
}
/*-------------------------------------------------------------------------*/
/**
* Reads the next byte of data from this input stream. The value
* byte is returned as an <code>int</code> in the range
* <code>0</code> to <code>255</code>. If no byte is available
* because the end of the stream has been reached, the value
* <code>-1</code> is returned. This method blocks until input data
* is available, the end of the stream is detected, or an exception
* is thrown.
*
* <p>This method simply performs <code>in.read()</code> and returns
* the result.
*
* @return the next byte of data, or <code>-1</code> if the end of the
* stream is reached.
* @exception AFSFileException if an I/O or other file related error occurs.
* @see java.io.FileInputStream#read
*/
public int read() throws AFSFileException
{
byte[] bytes = new byte[1];
this.read(bytes, 0, 1);
return bytes[0];
}
/**
* Reads up to <code>b.length</code> bytes of data from this input
* stream into an array of bytes. This method blocks until some input
* is available.
*
* @param b the buffer into which the data is read.
* @return the total number of bytes read into the buffer, or
* <code>-1</code> if there is no more data because the end of
* the file has been reached.
* @exception AFSFileException if an I/O or other file related error occurs.
*/
public int read(byte[] b) throws AFSFileException
{
return this.read(b, 0, b.length);
}
/////////////// public native methods ////////////////////
/**
* Reads up to <code>len</code> bytes of data from this input stream
* into an array of bytes. This method blocks until some input is
* available.
*
* @param b the buffer into which the data is read.
* @param off the start offset of the data.
* @param len the maximum number of bytes read.
* @return the total number of bytes read into the buffer, or
* <code>-1</code> if there is no more data because the end of
* the file has been reached.
* @exception AFSFileException if an I/O or other file related error occurs.
*/
public native int read(byte[] b, int off, int len) throws AFSFileException;
/**
* Skips over and discards <code>n</code> bytes of data from the
* input stream. The <code>skip</code> method may, for a variety of
* reasons, end up skipping over some smaller number of bytes,
* possibly <code>0</code>. The actual number of bytes skipped is returned.
*
* @param n the number of bytes to be skipped.
* @return the actual number of bytes skipped.
* @exception AFSFileException if an I/O or other file related error occurs.
*/
public native long skip(long n) throws AFSFileException;
/**
* Closes this file input stream and releases any system resources
* associated with the stream.
*
* @exception AFSFileException if an I/O or other file related error occurs.
*/
public native void close() throws AFSFileException;
/////////////// private native methods ////////////////////
/**
* Opens the specified AFS file for reading.
*
* @param name fileName of file to be opened
* @return file descriptor
* @exception AFSFileException if an I/O or other file related error occurs.
*/
private native int openReadOnly(String fileName) throws AFSFileException;
/*-------------------------------------------------------------------------*/
}

View File

@ -1,217 +0,0 @@
/*
* @(#)FilterOutputStream.java 1.0 00/10/10
*
* Copyright (c) 2001 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openafs.jafs;
import java.io.OutputStream;
/**
* This class is a file output stream for files within AFS.
* It is an output stream for writing data to a
* <code>{@link org.openafs.jafs.File}</code>.
*
* @version 2.1, 08/03/2001
* @see org.openafs.jafs.File
* @see org.openafs.jafs.FileInputStream
* @see java.io.FileOutputStream
*/
public class FileOutputStream extends OutputStream
{
/** Status indicator for the current state of this file output stream */
private int fileDescriptor;
/**
* Creates an output file stream to write to the AFS file with the
* specified name.
* <p>
* If the file exists but is a directory rather than a regular file, does
* not exist but cannot be created, or cannot be opened for any other
* reason then a <code>AFSFileException</code> is thrown.
*
* @param name the name of the file to write to
* @exception AFSFileException If an AFS specific error occurs,
* if the file exists but is a directory
* rather than a regular file, does not exist but cannot
* be created, or cannot be opened for any other reason, including
* authorization.
*/
public FileOutputStream(String name) throws AFSFileException
{
this(name, false);
}
/**
* Creates an output file stream to write to the AFS file with the specified
* <code>name</code>. If the second argument is <code>true</code>, then
* bytes will be written to the end of the file rather than the beginning.
* <p>
* If the file exists but is a directory rather than a regular file, does
* not exist but cannot be created, or cannot be opened for any other
* reason then a <code>AFSFileException</code> is thrown.
*
* @param name the name of the file to write to
* @param append if <code>true</code>, then bytes will be written
* to the end of the file rather than the beginning
* @exception AFSFileException If an AFS specific error occurs,
* if the file exists but is a directory
* rather than a regular file, does not exist but cannot
* be created, or cannot be opened for any other reason, including
* authorization.
*/
public FileOutputStream(String name, boolean append) throws AFSFileException
{
if (append) {
fileDescriptor = this.openAppend(name);
} else {
fileDescriptor = this.openWrite(name);
}
}
/**
* Creates a file output stream to write to the AFS file represented by
* the specified <code>File</code> object.
* <p>
* If the file exists but is a directory rather than a regular file, does
* not exist but cannot be created, or cannot be opened for any other
* reason then a <code>AFSFileException</code> is thrown.
*
* @param file the AFS file to be opened for writing.
* @exception AFSFileException If an AFS specific error occurs,
* if the file exists but is a directory
* rather than a regular file, does not exist but cannot
* be created, or cannot be opened for any other reason, including
* authorization.
* @see org.openafs.jafs.File#getPath()
*/
public FileOutputStream(File file) throws AFSFileException
{
this(file.getPath(), false);
}
/**
* Creates a file output stream to write to the AFS file represented by
* the specified <code>File</code> object.
* <p>
* If the file exists but is a directory rather than a regular file, does
* not exist but cannot be created, or cannot be opened for any other
* reason then a <code>AFSFileException</code> is thrown.
*
* @param file the AFS file to be opened for writing.
* @param append if <code>true</code>, then bytes will be written
* to the end of the file rather than the beginning
* @exception AFSFileException If an AFS specific error occurs,
* if the file exists but is a directory
* rather than a regular file, does not exist but cannot
* be created, or cannot be opened for any other reason, including
* authorization.
* @see org.openafs.jafs.File#getPath()
*/
public FileOutputStream(File file, boolean append) throws AFSFileException
{
this(file.getPath(), append);
}
/*-------------------------------------------------------------------------*/
/**
* Writes the specified <code>byte</code> to this file output stream.
* <p>
* Implements the abstract <tt>write</tt> method of <tt>OutputStream</tt>.
*
* @param b the byte to be written.
* @exception AFSFileException if an error occurs.
*/
public void write(int b) throws AFSFileException
{
byte[] bytes = new byte[1];
bytes[0] = (byte) b;
this.write(bytes, 0, 1);
}
/**
* Writes <code>b.length</code> bytes from the specified byte array
* to this file output stream.
* <p>
* Implements the <code>write</code> method of three arguments with the
* arguments <code>b</code>, <code>0</code>, and
* <code>b.length</code>.
* <p>
* Note that this method does not call the one-argument
* <code>write</code> method of its underlying stream with the single
* argument <code>b</code>.
*
* @param b the data to be written.
* @exception AFSFileException if an error occurs.
* @see #write(byte[], int, int)
* @see java.io.FilterOutputStream#write(byte[], int, int)
*/
public void write(byte[] b) throws AFSFileException
{
this.write(b, 0, b.length);
}
/////////////// public native methods ////////////////////
/**
* Writes <code>len</code> bytes from the specified
* <code>byte</code> array starting at offset <code>off</code> to
* this file output stream.
*
* @param b the data to be written
* @param off the start offset in the data
* @param len the number of bytes that are written
* @exception AFSFileException if an I/O or other file related error occurs.
* @see java.io.FilterOutputStream#write(int)
*/
public native void write(byte[] b, int off, int len) throws AFSFileException;
/**
* Closes this file output stream and releases any system resources
* associated with this stream. This file output stream may no longer
* be used for writing bytes.
*
* @exception AFSFileException if an I/O or other file related error occurs.
*/
public native void close() throws AFSFileException;
/////////////// private native methods ////////////////////
/**
* Opens an AFS file, with the specified name, for writing.
*
* @param filename name of file to be opened
* @return file descriptor
* @exception AFSFileException if an I/O or other file related error occurs.
*/
private native int openWrite(String filename) throws AFSFileException;
/**
* Opens an AFS file, with the specified name, for appending.
*
* @param filename name of file to be opened
* @return file descriptor
* @exception AFSFileException if an I/O or other file related error occurs.
*/
private native int openAppend(String filename) throws AFSFileException;
/*-------------------------------------------------------------------------*/
}

File diff suppressed because it is too large Load Diff

View File

@ -1,467 +0,0 @@
/*
* @(#)Key.java 1.0 6/29/2001
*
* Copyright (c) 2001 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openafs.jafs;
import java.util.GregorianCalendar;
import java.util.Date;
import java.io.Serializable;
/**
* An abstract representation of an AFS key. It holds information about
* the key, such as what its version is.
* <BR><BR>
*
* Constructing an instance of a <code>Key</code> does not mean an actual
* AFS key is created on a server -- usually a <code>Key</code>
* object is a representation of an already existing AFS key. If,
* however, the <code>Key</code> is constructed with the version number of a
* key that does not exist on the server represented by the provided
* <code>Server</code>, a new key with that version number can be
* created on that server by calling the {@link #create(String)} methods If
* such a key does already exist when this method is called,
* an exception will be thrown.<BR><BR>
*
* <!--Example of how to use class-->
* The following is a simple example of how to construct and use a
* <code>Key</code> object. It obtains the list of <code>Key</code>s from
* a specified server, and prints the string representation of each key.
* <PRE>
* import org.openafs.jafs.Cell;
* import org.openafs.jafs.AFSException;
* import org.openafs.jafs.Key;
* import org.openafs.jafs.Server;
* ...
* public class ...
* {
* ...
* private Cell cell;
* private Server server;
* ...
* public static void main(String[] args) throws Exception
* {
* String username = arg[0];
* String password = arg[1];
* String cellName = arg[2];
* String serverName = arg[3];
*
* token = new Token(username, password, cellName);
* cell = new Cell(token);
* server = new Server(serverName, cell);
*
* System.out.println("Keys in Server " + server.getName() + ":");
* Key[] keys = server.getKeys();
* for (int i = 0; i < keys.length; i++) {
* System.out.println(" -> " + keys[i] );
* }
* }
* ...
* }
* </PRE>
*
*/
public class Key implements Serializable, Comparable
{
protected Server server;
protected int version;
protected long checkSum;
protected String encryptionKey;
protected int lastModDate;
protected int lastModMs;
protected GregorianCalendar lastModDateDate;
protected boolean cachedInfo;
/**
* Constructs a new <CODE>Key</CODE> object instance given the version of
* the AFS key and the AFS server, represented by <CODE>server</CODE>,
* to which it belongs. This does not actually
* create a new AFS key, it just represents one.
* If <code>version</code> is not an actual AFS key, exceptions
* will be thrown during subsequent method invocations on this
* object, unless the {@link #create(String)}
* method is explicitly called to create it.
*
* @exception AFSException If an error occurs in the native code
* @param version the version of the key to represent
* @param server the server to which the key belongs.
*/
public Key( int version, Server server ) throws AFSException
{
this.server = server;
this.version = version;
lastModDateDate = null;
cachedInfo = false;
}
/**
* Constructs a new <CODE>Key</CODE> object instance given the version of
* the AFS key and the AFS server, represented by <CODE>server</CODE>,
* to which it belongs. This does not actually
* create a new AFS key, it just represents one.
* If <code>version</code> is not an actual AFS key, exceptions
* will be thrown during subsequent method invocations on this
* object, unless the {@link #create(String)}
* method is explicitly called to create it. Note that if the key does not
* exist and <code>preloadAllMembers</code> is true, an exception will
* be thrown.
*
* <P> This constructor is ideal for point-in-time representation and
* transient applications. It ensures all data member values are set and
* available without calling back to the filesystem at the first request
* for them. Use the {@link #refresh()} method to address any coherency
* concerns.
*
* @param version the version of the key to represent
* @param server the server to which the key belongs.
* @param preloadAllMembers true will ensure all object members are set
* upon construction; otherwise members will be
* set upon access, which is the default behavior.
* @exception AFSException If an error occurs in the native code
* @see #refresh
*/
public Key( int version, Server server, boolean preloadAllMembers )
throws AFSException
{
this(version, server);
if (preloadAllMembers) refresh(true);
}
/**
* Creates a blank <code>Key</code> given the server to which the key
* belongs. This blank object can then be passed into other methods to
* fill out its properties.
*
* @exception AFSException If an error occurs in the native code
* @param server the server to which the key belongs.
*/
Key( Server server ) throws AFSException
{
this( -1, server );
}
/*-------------------------------------------------------------------------*/
/**
* Refreshes the properties of this Key object instance with values from
* the AFS key it represents. All properties that have been initialized
* and/or accessed will be renewed according to the values of the AFS key
* this Key object instance represents.
*
* <P>Since in most environments administrative changes can be administered
* from an AFS command-line program or an alternate GUI application, this
* method provides a means to refresh the Java object representation and
* thereby ascertain any possible modifications that may have been made
* from such alternate administrative programs. Using this method before
* an associated instance accessor will ensure the highest level of
* representative accuracy, accommodating changes made external to the
* Java application space. If administrative changes to the underlying AFS
* system are only allowed via this API, then the use of this method is
* unnecessary.
*
* @exception AFSException If an error occurs in the native code
*/
public void refresh() throws AFSException
{
refresh(false);
}
/**
* Refreshes the properties of this Key object instance with values from
* the AFS key it represents. If <CODE>all</CODE> is <CODE>true</CODE>
* then <U>all</U> of the properties of this Key object instance will be
* set, or renewed, according to the values of the AFS key it represents,
* disregarding any previously set properties.
*
* <P> Thus, if <CODE>all</CODE> is <CODE>false</CODE> then properties that
* are currently set will be refreshed and properties that are not set will
* remain uninitialized. See {@link #refresh()} for more information.
*
* @param all if true set or renew all object properties; otherwise renew
* all set properties
* @exception AFSException If an error occurs in the native code
* @see #refresh()
*/
protected void refresh(boolean all) throws AFSException
{
if( all || cachedInfo ) {
refreshInfo();
}
}
/**
* Refreshes the information fields of this <code>Key</code> to reflect the
* current state of the AFS server key. These inlclude the last
* modification time, etc.
*
* @exception AFSException If an error occurs in the native code
*/
protected void refreshInfo() throws AFSException
{
getKeyInfo( server.getBosHandle(), version, this );
cachedInfo = true;
lastModDateDate = null;
}
/**
* Creates a key with this <code>Key's</code> version number at the server,
* using the specified <code>String</code> for the key.
*
* @param keyString the string to use for the encryption key
* @exception AFSException If an error occurs in the native code
*/
public void create( String keyString ) throws AFSException
{
create( server.getCell().getCellHandle(), server.getBosHandle(), version,
keyString );
}
/**
* Removes the key with this <code>Key's</code> version number from
* the server.
*
* @exception AFSException If an error occurs in the native code
*/
public void delete( ) throws AFSException
{
delete( server.getBosHandle(), version );
encryptionKey = null;
cachedInfo = false;
}
//////////////// accessors: ////////////////////////
/**
* Returns the version of this key in primitive form.
*
* @return the version number of this key
*/
public int getVersion()
{
return version;
}
/**
* Returns the server this key is associated with.
*
* @return this key's server
*/
public Server getServer()
{
return server;
}
/**
* Returns the encrypted key as a string in octal form. This is how AFS
* prints it out on the command line. An example would be:
* '\040\205\211\241\345\002\023\211'.
*
* @return the encrypted key
* @exception AFSException If an error occurs in the native code
*/
public String getEncryptionKey() throws AFSException
{
if (!cachedInfo) refreshInfo();
return encryptionKey;
}
/**
* Returns the check sum of this key.
*
* @return the check sum of this key
* @exception AFSException If an error occurs in the native code
*/
public long getCheckSum() throws AFSException
{
if (!cachedInfo) refreshInfo();
return checkSum;
}
/**
* Returns the last modification date of this key.
*
* @return the last modification date of this key
* @exception AFSException If an error occurs in the native code
*/
public GregorianCalendar getLastModDate() throws AFSException
{
if (!cachedInfo) refreshInfo();
if ( lastModDateDate == null && cachedInfo ) {
// make it into a date . . .
lastModDateDate = new GregorianCalendar();
long longTime = ((long) lastModDate)*1000;
Date d = new Date( longTime );
lastModDateDate.setTime( d );
}
return lastModDateDate;
}
/////////////// information methods ////////////////////
/**
* Returns a <code>String</code> representation of this <code>Key</code>.
* Contains the information fields.
*
* @return a <code>String</code> representation of the <code>Key</code>
*/
public String getInfo()
{
String r;
try {
r = "Key version number: " + getVersion() + "\n";
r += "\tencrypted key: " + getEncryptionKey() + "\n";
r += "\tcheck sum: " + getCheckSum() + "\n";
r += "\tlast mod time: " + getLastModDate().getTime() + "\n";
} catch( Exception e ) {
return e.toString();
}
return r;
}
/////////////// override methods ////////////////////
/**
* Compares two Key objects respective to their key version and does not
* factor any other attribute.
*
* @param key The Key object to be compared to this Key instance
*
* @return Zero if the argument is equal to this Key's version, a
* value less than zero if this Key's version is less than
* the argument, or a value greater than zero if this Key's
* version is greater than the argument
*/
public int compareTo(Key key)
{
return (this.getVersion() - key.getVersion());
}
/**
* Comparable interface method.
*
* @see #compareTo(Key)
*/
public int compareTo(Object obj)
{
return compareTo((Key)obj);
}
/**
* Tests whether two <code>Key</code> objects are equal, based on their
* encryption key, version, and associated Server.
*
* @param otherKey the Key to test
* @return whether the specifed Key is the same as this Key
*/
public boolean equals( Key otherKey )
{
try {
return ( this.getEncryptionKey().equals(otherKey.getEncryptionKey()) ) &&
( this.getVersion() == otherKey.getVersion() ) &&
( this.getServer().equals(otherKey.getServer()) );
} catch (Exception e) {
return false;
}
}
/**
* Returns the name of this <CODE>Key</CODE>
*
* @return the name of this <CODE>Key</CODE>
*/
public String toString()
{
try {
return getVersion() + " - " + getEncryptionKey() + " - " + getCheckSum();
} catch (Exception e) {
return e.toString();
}
}
/////////////// native methods ////////////////////
/**
* Fills in the information fields of the provided <code>Key</code>.
*
* @param serverHandle the bos handle of the server to which the key
* belongs
* @see Server#getBosServerHandle
* @param version the version of the key for which to get the information
* @param key the <code>Key</code> object in which to fill in the
* information
* @see Server
* @exception AFSException If an error occurs in the native code
*/
protected static native void getKeyInfo( long serverHandle, int version,
Key key )
throws AFSException;
/**
* Create a server key.
*
* @param cellHandle the handle of the cell to which the server belongs
* @see Cell#getCellHandle
* @param serverHandle the bos handle of the server to which the key will
* belong
* @see Server#getBosServerHandle
* @param versionNumber the version number of the key to create (0 to 255)
* @param keyString the <code>String</code> version of the key that will
* be encrypted
* @exception AFSException If an error occurs in the native code
*/
protected static native void create( long cellHandle, long serverHandle, int versionNumber, String keyString )
throws AFSException;
/**
* Delete a server key.
*
* @param serverHandle the bos handle of the server to which the key belongs
* @see Server#getBosServerHandle
* @param versionNumber the version number of the key to remove (0 to 255)
* @exception AFSException If an error occurs in the native code
*/
protected static native void delete( long serverHandle, int versionNumber )
throws AFSException;
/**
* Reclaims all memory being saved by the key portion of the native library.
* This method should be called when no more <code>Key</code> objects are
* expected to be
* used.
*/
protected static native void reclaimKeyMemory();
}

View File

@ -1,99 +0,0 @@
/*
* @(#)PTSEntry.java 1.2 10/23/2001
*
* Copyright (c) 2001 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openafs.jafs;
/**
* An interface representation of a PTS entry as it applies to
* AFS users and groups. This interface is implemented in both
* {@link User} and {@link Group} object abstractions.
* <BR><BR>
*
*
* @version 1.0, 3/31/02
* @see User
* @see Group
*/
public interface PTSEntry
{
/**
* Constant for {@link User} object implementers,
* used with {@link #getType()}
*/
public static final short PTS_USER = 0;
/**
* Constant for {@link Group} object implementers,
* used with {@link #getType()}
*/
public static final short PTS_GROUP = 1;
/**
* Returns the Cell this PTS user or group belongs to.
*
* @return the Cell this PTS user or group belongs to
*/
public Cell getCell();
/**
* Returns the creator of this PTS user or group.
*
* @return the creator of this PTS user or group
* @exception AFSException If an error occurs in the native code
*/
public PTSEntry getCreator() throws AFSException;
/**
* Returns the name of this PTS user or group.
*
* @return the name of this PTS user or group
*/
public String getName();
/**
* Returns the owner of this PTS user or group.
*
* @return the owner of this PTS user or group
* @exception AFSException If an error occurs in the native code
*/
public PTSEntry getOwner() throws AFSException;
/**
* Returns the type of PTS entry the implementing object represents.
*
* <P>Possible values are:<BR>
* <ul>
* <li><code>{@link #PTS_USER}</code>
* -- a {@link User} object</li>
* <li><code>{@link #PTS_GROUP}</code>
* -- a {@link Group} object</li>
* </ul>
*
* @return the name of this PTS user or group
*/
public short getType();
/**
* Returns the numeric AFS id of this user or group.
*
* @return the AFS id of this user/group
* @exception AFSException If an error occurs in the native code
*/
public int getUID() throws AFSException;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,953 +0,0 @@
/*
* @(#)Process.java 1.0 6/29/2001
*
* Copyright (c) 2001 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openafs.jafs;
import java.util.GregorianCalendar;
import java.util.Date;
import java.io.Serializable;
/**
* An abstract representation of an AFS process. It holds information about
* the server, such as what its state is.
* <BR><BR>
*
* Constructing an instance of a <code>Process</code> does not mean an actual
* AFS process is created on a server -- usually a <code>Process</code>
* object is a representation of an already existing AFS process. If,
* however, the <code>Process</code> is constructed with the name of a
* process that does not exist in the server represented by the provided
* <code>Server</code>, a new process with that name can be
* created on that server by calling one of the {@link #createSimple(String)},
* {@link #createFS(String)}, or {@link #createCron(String,String)} methods. If
* such a process does already exist when one of these methods are called,
* an exception will be thrown.<BR><BR>
*
* <!--Information on how member values are set-->
*
* <!--Example of how to use class-->
* The following is a simple example of how to construct and use a
* <code>Process</code> object. This example obtains the list of all
* <code>Process</code> objects on a particular server and prints out the
* name of each one along with its start time.<BR><BR>
*
* <PRE>
* import org.openafs.jafs.Cell;
* import org.openafs.jafs.AFSException;
* import org.openafs.jafs.Process;
* import org.openafs.jafs.Server;
* ...
* public class ...
* {
* ...
* private Cell cell;
* private Server server;
* ...
* public static void main(String[] args) throws Exception
* {
* String username = arg[0];
* String password = arg[1];
* String cellName = arg[2];
* String serverName = arg[3];
*
* token = new Token(username, password, cellName);
* cell = new Cell(token);
* server = new Server(serverName, cell);
*
* System.out.println("Processes in Server " + server.getName() + ":");
* Process[] processes = server.getProcesss();
* for (int i = 0; i < processes.length; i++) {
* System.out.print("Process " + processes[i].getName());
* System.out.print("was started: " +
* processes[i].getStartTimeDate().getTime() + "\n");
* }
* }
* ...
* }
* </PRE>
*
*/
public class Process implements Serializable, Comparable
{
/**
* Any standard type of process except for fs (such as kaserver,
* upclientbin, etc.)
*/
public static final int SIMPLE_PROCESS = 0;
/**
* Combination of File Server, Volume Server, and Salvager processes
*/
public static final int FS_PROCESS = 1;
/**
* A process that should be restarted at a specific time either daily
* or weekly.
*/
public static final int CRON_PROCESS = 2;
/**
* Process execution state stopped
*/
public static final int STOPPED = 0;
/**
* Process execution state running
*/
public static final int RUNNING = 1;
/**
* Process execution state stopping
*/
public static final int STOPPING = 2;
/**
* Process execution state starting
*/
public static final int STARTING = 3;
protected String name;
protected Server server;
protected long serverHandle;
protected int type;
protected int state;
protected int goal;
protected long startTime;
protected long numberStarts;
protected long exitTime;
protected long exitErrorTime;
protected long errorCode;
protected long errorSignal;
protected boolean stateOk;
protected boolean stateTooManyErrors;
protected boolean stateBadFileAccess;
protected GregorianCalendar startTimeDate;
protected GregorianCalendar exitTimeDate;
protected GregorianCalendar exitErrorTimeDate;
protected boolean cachedInfo;
/**
* Constructs a new <code>Process</code> object instance given the name
* of the AFS process and the AFS server, represented by
* <CODE>server</CODE>, to which it belongs. This does not actually
* create a new AFS process, it just represents one.
* If <code>name</code> is not an actual AFS process, exceptions
* will be thrown during subsequent method invocations on this
* object, unless one of the {@link #createSimple(String)},
* {@link #createFS(String)}, or {@link #createCron(String,String)}
* methods are explicitly called to create it.
*
* @param name the name of the server to represent
* @param server the server on which the process resides
* @exception AFSException If an error occurs in the native code
*/
public Process( String name, Server server ) throws AFSException
{
this.name = name;
this.server = server;
serverHandle = server.getBosHandle();
startTimeDate = null;
exitTimeDate = null;
exitErrorTimeDate = null;
cachedInfo = false;
}
/**
* Constructs a new <CODE>Process</CODE> object instance given the name
* of the AFS process and the AFS server, represented by
* <CODE>server</CODE>, to which it belongs. This does not actually
* create a new AFS process, it just represents one.
* If <code>name</code> is not an actual AFS process, exceptions
* will be thrown during subsequent method invocations on this
* object, unless one of the {@link #createSimple(String)},
* {@link #createFS(String)}, or {@link #createCron(String,String)}
* methods are explicitly called to create it. Note that if he process
* doesn't exist and <code>preloadAllMembers</code> is true, an exception
* will be thrown.
*
* <P> This constructor is ideal for point-in-time representation and
* transient applications. It ensures all data member values are set and
* available without calling back to the filesystem at the first request
* for them. Use the {@link #refresh()} method to address any coherency
* concerns.
*
* @param name the name of the process to represent
* @param server the server to which the process belongs.
* @param preloadAllMembers true will ensure all object members are
* set upon construction; otherwise members will
* be set upon access, which is the default
* behavior.
* @exception AFSException If an error occurs in the native code
* @see #refresh
*/
public Process( String name, Server server, boolean preloadAllMembers )
throws AFSException
{
this(name, server);
if (preloadAllMembers) refresh(true);
}
/**
* Creates a blank <code>Process</code> given the server to which the process
* belongs. This blank object can then be passed into other methods to fill
* out its properties.
*
* @param server the server to which the process belongs.
* @exception AFSException If an error occurs in the native code
*/
Process( Server server ) throws AFSException
{
this( null, server );
}
/*-------------------------------------------------------------------------*/
/**
* Refreshes the properties of this Process object instance with values
* from the AFS process it represents. All properties that have been
* initialized and/or accessed will be renewed according to the values of
* the AFS process this Process object instance represents.
*
* <P>Since in most environments administrative changes can be administered
* from an AFS command-line program or an alternate GUI application, this
* method provides a means to refresh the Java object representation and
* thereby ascertain any possible modifications that may have been made
* from such alternate administrative programs. Using this method before
* an associated instance accessor will ensure the highest level of
* representative accuracy, accommodating changes made external to the
* Java application space. If administrative changes to the underlying AFS
* system are only allowed via this API, then the use of this method is
* unnecessary.
*
* @exception AFSException If an error occurs in the native code
*/
public void refresh() throws AFSException
{
refresh(false);
}
/**
* Refreshes the properties of this Process object instance with values from
* the AFS process it represents. If <CODE>all</CODE> is <CODE>true</CODE>
* then <U>all</U> of the properties of this Process object instance will be
* set, or renewed, according to the values of the AFS process it represents,
* disregarding any previously set properties.
*
* <P> Thus, if <CODE>all</CODE> is <CODE>false</CODE> then properties that
* are currently set will be refreshed and properties that are not set will
* remain uninitialized. See {@link #refresh()} for more information.
*
* @param all if true set or renew all object properties; otherwise renew
* all set properties
* @exception AFSException If an error occurs in the native code
* @see #refresh()
*/
protected void refresh(boolean all) throws AFSException
{
if (all || cachedInfo) refreshInfo();
}
/**
* Refreshes the information fields of this <code>Process</code> to reflect
* the current state of the AFS process, such as the start time, the state,
* etc.
*
* @exception AFSException If an error occurs in the native code
*/
protected void refreshInfo() throws AFSException
{
getProcessInfo( server.getBosHandle(), name, this );
cachedInfo = true;
startTimeDate = null;
exitTimeDate = null;
exitErrorTimeDate = null;
}
/**
* Creates this process as a simple process on the server.
*
* @param executionPath the path to the process's executable
* @exception AFSException If an error occurs in the native code
*/
public void createSimple( String executionPath ) throws AFSException
{
create( server.getBosHandle(), name, SIMPLE_PROCESS, executionPath, null,
null );
}
/**
* Creates this process as a file server process on the server.
*
* @param executionPath the path to the process's executable
* @exception AFSException If an error occurs in the native code
*/
public void createFS( String executionPath ) throws AFSException
{
create( server.getBosHandle(), name, FS_PROCESS, executionPath, null,
null );
}
/**
* Creates this process as a cron process on the server.
*
* @param executionPath the path to the process's executable
* @param cronTime a String representing the time a cron process is
* to be run. Acceptable formats are:<ul>
* <li>for daily restarts: "23:10" or "11:10 pm"</li>
* <li>for weekly restarts: "sunday 11:10pm" or
* "sun 11:10pm"</li>
* </ul>
* @exception AFSException If an error occurs in the native code
*/
public void createCron( String executionPath, String cronTime )
throws AFSException
{
create( server.getBosHandle(), name, CRON_PROCESS, executionPath,
cronTime, null );
}
/**
* Removes this process from the bos server
*
* @exception AFSException If an error occurs in the native code
*/
public void delete() throws AFSException
{
delete( server.getBosHandle(), name );
}
/**
* Stops this process.
*
* @exception AFSException If an error occurs in the native code
*/
public void stop() throws AFSException
{
state = STOPPING;
goal = STOPPED;
stop( server.getBosHandle(), name );
}
/**
* Starts this process
*
* @exception AFSException If an error occurs in the native code
*/
public void start() throws AFSException
{
state = STARTING;
start( server.getBosHandle(), name );
}
/**
* Restarts this process
*
* @exception AFSException If an error occurs in the native code
*/
public void restart() throws AFSException
{
state = STARTING;
restart( server.getBosHandle(), name );
}
//////////////// accessors: ////////////////////////
/**
* Returns the name of this process.
*
* @return the name of this process
*/
public String getName()
{
return name;
}
/**
* Returns the server hosting this process.
*
* @return this process' server
*/
public Server getServer()
{
return server;
}
/**
* Returns the process type. Possible values are:<ul>
* <li>{@link #SIMPLE_PROCESS}</li>
* <li>{@link #FS_PROCESS}</li>
* <li>{@link #CRON_PROCESS}</li></ul>
*
* @return the process type
* @exception AFSException If an error occurs in the native code
*/
public int getType() throws AFSException
{
if (!cachedInfo) refreshInfo();
return type;
}
/**
* Returns the process goal. Possible values are:<ul>
* <li>{@link #STOPPED}</li>
* <li>{@link #RUNNING}</li>
* <li>{@link #STARTING}</li>
* <li>{@link #STOPPING}</li></ul>
* After this method is called once, it saves the value
* and returns that value on subsequent calls,
* until the {@link #refresh()} method is called and a more current
* value is obtained.
*
* @return the process goal
* @exception AFSException If an error occurs in the native code
*/
public int getGoal() throws AFSException
{
if (!cachedInfo) refreshInfo();
return goal;
}
/**
* Returns the process execution state. Possible values are:<ul>
* <li>{@link #STOPPED}</li>
* <li>{@link #RUNNING}</li>
* <li>{@link #STARTING}</li>
* <li>{@link #STOPPING}</li></ul>
* After this method is called once, it saves the value
* and returns that value on subsequent calls,
* until the {@link #refresh()} method is called and a more current
* value is obtained.
*
* @return the process execution state
* @exception AFSException If an error occurs in the native code
*/
public int getState() throws AFSException
{
if (!cachedInfo) refreshInfo();
return state;
}
/**
* Returns the most recent start time of this process. A
* <code>null</code> value
* indicates no start time.
* After this method is called once, it saves the value
* and returns that value on subsequent calls,
* until the {@link #refresh()} method is called and a more current
* value is obtained.
*
* @return the start time
* @exception AFSException If an error occurs in the native code
*/
public long getStartTime() throws AFSException
{
if (!cachedInfo) refreshInfo();
return startTime;
}
/**
* Returns the most recent start time of this process. A <code>null</code>
* value indicates no start time.
* After this method is called once, it saves the value
* and returns that value on subsequent calls,
* until the {@link #refresh()} method is called and a more current
* value is obtained.
*
* @return the start time
* @exception AFSException If an error occurs in the native code
*/
public GregorianCalendar getStartTimeDate() throws AFSException
{
if (!cachedInfo) {
refreshInfo();
}
if( startTimeDate == null && startTime != 0 ) {
// make it into a date . . .
startTimeDate = new GregorianCalendar();
long longTime = startTime * 1000;
Date d = new Date( longTime );
startTimeDate.setTime( d );
}
return startTimeDate;
}
/**
* Returns the number of starts of the process.
* After this method is called once, it saves the value
* and returns that value on subsequent calls,
* until the {@link #refresh()} method is called and a more current
* value is obtained.
*
* @return the number of starts
* @exception AFSException If an error occurs in the native code
*/
public long getNumberOfStarts() throws AFSException
{
if (!cachedInfo) refreshInfo();
return numberStarts;
}
/**
* Returns the most recent exit time of this process. A <code>null</code>
* value indicates no exit time.
* After this method is called once, it saves the value
* and returns that value on subsequent calls,
* until the {@link #refresh()} method is called and a more current
* value is obtained.
*
* @return the exit time
* @exception AFSException If an error occurs in the native code
*/
public long getExitTime() throws AFSException
{
if (!cachedInfo) refreshInfo();
return exitTime;
}
/**
* Returns the most recent exit time of this process. A <code>null</code>
* value indicates no exit time
* After this method is called once, it saves the value
* and returns that value on subsequent calls,
* until the {@link #refresh()} method is called and a more current
* value is obtained.
*
* @return the exit time
* @exception AFSException If an error occurs in the native code
*/
public GregorianCalendar getExitTimeDate() throws AFSException
{
if (!cachedInfo) refreshInfo();
if( exitTimeDate == null && exitTime != 0 ) {
// make it into a date . . .
exitTimeDate = new GregorianCalendar();
long longTime = exitTime*1000;
Date d = new Date( longTime );
exitTimeDate.setTime( d );
}
return exitTimeDate;
}
/**
* Returns the most recent time this process exited with an error. A
* <code>null</code> value indicates no exit w/ error time.
* After this method is called once, it saves the value
* and returns that value on subsequent calls,
* until the {@link #refresh()} method is called and a more current
* value is obtained.
*
* @return the exit w/ error time
* @exception AFSException If an error occurs in the native code
*/
public long getExitErrorTime() throws AFSException
{
if (!cachedInfo) refreshInfo();
return exitErrorTime;
}
/**
* Returns the most recent time this process exited with an error. A <
* code>null</code> value indicates no exit w/ error time.
* After this method is called once, it saves the value
* and returns that value on subsequent calls,
* until the {@link #refresh()} method is called and a more current
* value is obtained.
*
* @return the exit w/ error time
* @exception AFSException If an error occurs in the native code
*/
public GregorianCalendar getExitErrorTimeDate() throws AFSException
{
if (!cachedInfo) refreshInfo();
if (exitErrorTimeDate == null && exitErrorTime != 0) {
// make it into a date . . .
exitErrorTimeDate = new GregorianCalendar();
long longTime = exitErrorTime*1000;
Date d = new Date( longTime );
exitErrorTimeDate.setTime( d );
}
return exitErrorTimeDate;
}
/**
* Returns the error code of the process. A value of 0 indicates
* no error code.
* After this method is called once, it saves the value
* and returns that value on subsequent calls,
* until the {@link #refresh()} method is called and a more current
* value is obtained.
*
* @return the error code
* @exception AFSException If an error occurs in the native code
*/
public long getErrorCode() throws AFSException
{
if (!cachedInfo) refreshInfo();
return errorCode;
}
/**
* Returns the error signal of the process. A value of 0 indicates no
* error signal.
* After this method is called once, it saves the value
* and returns that value on subsequent calls,
* until the {@link #refresh()} method is called and a more current
* value is obtained.
*
* @return the error signal
* @exception AFSException If an error occurs in the native code
*/
public long getErrorSignal() throws AFSException
{
if (!cachedInfo) refreshInfo();
return errorSignal;
}
/**
* Returns whether or not the state of the process is ok. A value of
* <code>false</code> indicates there has been a core dump.
* After this method is called once, it saves the value
* and returns that value on subsequent calls,
* until the {@link #refresh()} method is called and a more current
* value is obtained.
*
* @return whether or not the state is ok
* @exception AFSException If an error occurs in the native code
*/
public boolean getStateOk() throws AFSException
{
if (!cachedInfo) refreshInfo();
return stateOk;
}
/**
* Returns whether or not the state of the process indicates too many errors.
* After this method is called once, it saves the value
* and returns that value on subsequent calls,
* until the {@link #refresh()} method is called and a more current
* value is obtained.
*
* @return whether or not the state indicates too many errors
* @exception AFSException If an error occurs in the native code
*/
public boolean getStateTooManyErrors() throws AFSException
{
if (!cachedInfo) refreshInfo();
return stateTooManyErrors;
}
/**
* Returns whether or not the state of the process indicates bad file access.
* After this method is called once, it saves the value
* and returns that value on subsequent calls,
* until the {@link #refresh()} method is called and a more current
* value is obtained.
*
* @return whether or not the state indicates bad file access
* @exception AFSException If an error occurs in the native code
*/
public boolean getStateBadFileAccess() throws AFSException
{
if (!cachedInfo) refreshInfo();
return stateBadFileAccess;
}
/////////////// custom information methods ////////////////////
/**
* Returns a <code>String</code> representation of this <code>Process</code>.
* Contains the information fields.
*
* @return a <code>String</code> representation of the <code>Process</code>
*/
public String getInfo()
{
String r;
try {
r = "Process: " + name + "\n";
r += "\ttype: ";
switch( getType() ) {
case SIMPLE_PROCESS:
r += "simple";
break;
case FS_PROCESS:
r += "fs";
break;
case CRON_PROCESS:
r += "cron";
break;
default:
r += "other - " + getType();
}
r += "\n";
r += "\tstate: ";
switch( getState() ) {
case STOPPED:
r += "stopped";
break;
case RUNNING:
r += "running";
break;
case STOPPING:
r += "stopping";
break;
case STARTING:
r += "starting";
break;
default:
r += "other - " + getState();
}
r += "\n";
r += "\tgoal: ";
switch( getGoal() ) {
case STOPPED:
r += "stopped";
break;
case RUNNING:
r += "running";
break;
case STOPPING:
r += "stopping";
break;
case STARTING:
r += "starting";
break;
default:
r += "other - " + getGoal();
}
r += "\n";
r += "\tstartTime: ";
if( getStartTime() == 0) {
r += "0";
} else {
r += getStartTimeDate().getTime();
}
r += "\n";
r += "\tnumberStarts: " + getNumberOfStarts() + "\n";
r += "\texitTime: ";
if( getExitTime() == 0 ) {
r += "0";
} else {
r += getExitTimeDate().getTime();
}
r += "\n";
r += "\texitErrorTime: ";
if( getExitErrorTimeDate() == null ) {
r += "0";
} else {
r += getExitErrorTimeDate().getTime();
}
r += "\n";
r += "\terrorCode: " + getErrorCode() + "\n";
r += "\terrorSignal: " + getErrorSignal() + "\n";
r += "\tstateOk: " + getStateOk() + "\n";
r += "\tstateTooManyErrors: " + getStateTooManyErrors() + "\n";
r += "\tstateBadFileAccess: " + getStateBadFileAccess() + "\n";
} catch( Exception e ) {
return e.toString();
}
return r;
}
/////////////// custom override methods ////////////////////
/**
* Compares two Process objects respective to their names and does not
* factor any other attribute. Alphabetic case is significant in
* comparing names.
*
* @param process The Process object to be compared to this Process
* instance
*
* @return Zero if the argument is equal to this Process' name, a
* value less than zero if this Process' name is
* lexicographically less than the argument, or a value greater
* than zero if this Process' name is lexicographically
* greater than the argument
*/
public int compareTo(Process process)
{
return this.getName().compareTo(process.getName());
}
/**
* Comparable interface method.
*
* @see #compareTo(Process)
*/
public int compareTo(Object obj)
{
return compareTo((Process)obj);
}
/**
* Tests whether two <code>Process</code> objects are equal, based on their
* names and hosting server.
*
* @param otherProcess the Process to test
* @return whether the specifed Process is the same as this Process
*/
public boolean equals( Process otherProcess )
{
return ( name.equals(otherProcess.getName()) ) &&
( this.getServer().equals(otherProcess.getServer()) );
}
/**
* Returns the name of this <CODE>Process</CODE>
*
* @return the name of this <CODE>Process</CODE>
*/
public String toString()
{
return getName();
}
/////////////// native methods ////////////////////
/**
* Fills in the information fields of the provided <code>Process</code>.
*
* @param cellHandle the handle of the cell to which the process belongs
* @see Cell#getCellHandle
* @param processName the instance name of the process for which to get
* the information
* @param theProcess the {@link Process Process} object in which to fill
* in the information
* @exception AFSException If an error occurs in the native code
*/
protected static native void getProcessInfo( long cellHandle,
String processName,
Process theProcess )
throws AFSException;
/**
* Creates a processes on a server.
*
* @param serverHandle the bos handle of the server to which the key will
* belong
* @see Server#getBosServerHandle
* @param processName the instance name to give the process. See AFS
* documentation for a standard list of instance names
* @param processType the type of process this will be.
* Acceptable values are:<ul>
* <li>{@link #SIMPLE_PROCESS}</li>
* <li>{@link #FS_PROCESS}</li>
* <li>{@link #CRON_PROCESS}</li></ul>
* @param executionPath the execution path process to create
* @param cronTime a String representing the time a cron process is to
* be run. Acceptable formats are:<ul>
* <li>for daily restarts: "23:10" or "11:10 pm"</li>
* <li>for weekly restarts: "sunday 11:10pm" or
* "sun 11:10pm"</li>
* </ul>
* Can be <code>null</code> for non-cron processes.
* @param notifier the execution path to a notifier program that should
* be called when the process terminates. Can be
* <code>null</code>
* @exception AFSException If an error occurs in the native code
*/
protected static native void create( long serverHandle, String processName,
int processType, String executionPath,
String cronTime, String notifier )
throws AFSException;
/**
* Removes a process from a server.
*
* @param serverHandle the bos handle of the server to which the process
* belongs
* @see Server#getBosServerHandle
* @param processName the name of the process to remove
* @exception AFSException If an error occurs in the native code
*/
protected static native void delete( long serverHandle, String processName )
throws AFSException;
/**
* Start this process.
*
* @param serverHandle the bos handle of the server to which the process
* belongs
* @see Server#getBosServerHandle
* @param processName the name of the process to start
* @exception AFSException If an error occurs in the native code
*/
protected static native void start( long serverHandle, String processName )
throws AFSException;
/**
* Retart this process.
*
* @param serverHandle the bos handle of the server to which the process
* belongs
* @see Server#getBosServerHandle
* @param processName the name of the process to restart
* @exception AFSException If an error occurs in the native code
*/
protected static native void restart( long serverHandle, String processName )
throws AFSException;
/**
* Stop this process.
*
* @param serverHandle the bos handle of the server to which the process
* belongs
* @see Server#getBosServerHandle
* @param processName the name of the process to stop
* @exception AFSException If an error occurs in the native code
*/
protected static native void stop( long serverHandle, String processName )
throws AFSException;
/**
* Reclaims all memory being saved by the process portion of the native
* library. This method should be called when no more <code>Process</code>
* objects are expected to be used.
*/
protected static native void reclaimProcessMemory();
}

File diff suppressed because it is too large Load Diff

View File

@ -1,507 +0,0 @@
/*
* @(#)Token.java 1.2 05/06/2002
*
* Copyright (c) 2001 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openafs.jafs;
import java.io.Serializable;
/**
* An abstract representation of an AFS authentication token. It conveniently
* maintains the handle associated with token and the cell to which the token
* is authenticated.
* <BR><BR>
*
* Constructing a <code>Token</code> object results in an immediate attempt to
* authenticate the user within the specified cell. If this attempt fails, an
* <code>{@link AFSException}</code> will be thrown. Therefore, if the
* construction of the object succeeds without an exception, then the
* <code>Token</code> is considered authenticated.
*
* The construction of a <code>Token</code> object acts as an entry point
* for authentication into the AFS system. Thus, when you construct a
* <code>{@link Cell}</code> object, you must pass in an instance of a
* <code>Token</code> that has been authenticated within the AFS cell that
* <code><I>Cell</I></code> is intended to represent. You will only be
* allowed to perform actions that the user, used to authenticate
* <code>Token</code>, is authorized to perform. You must construct a
* <code>Token</code> object before constructing a <code>Cell</code> object,
* which is required by all other objects within this package either directly
* or indirectly.<BR><BR>
*
* If an error occurs during a method call, an
* <code>AFSException</code> will be thrown. This class is the Java
* equivalent of errors thrown by AFS; see {@link AFSException}
* for a complete description.<BR><BR>
*
* <!--Example of how to use class-->
* The following is a simple example of how to construct and use a
* <code>Token</code> object. It shows how to construct a <code>Cell</code>
* using a <code>Token</code>. See {@link Cell} for a more detailed example
* of constructing and using a <code>Cell</code> object.<BR><BR>
*
* <PRE>
* import org.openafs.jafs.AFSException;
* import org.openafs.jafs.Cell;
* import org.openafs.jafs.Token;
* ...
* public class ...
* {
* ...
* private Cell cell;
* private Token token;
* ...
* public static void main(String[] args) throws Exception
* {
* String username = arg[0];
* String password = arg[1];
* String cellName = arg[2];
* String serverName = arg[3];
*
* token = new Token(username, password, cellName);
* cell = new Cell(token);
* ...
* }
* ...
* }
* </PRE>
*
*/
public class Token implements Serializable, Comparable
{
public static int ANYUSER_PAG_ID;
protected long tokenHandle;
protected int pagID = -1;
protected int errno;
protected String cellName;
protected String username;
private String password;
private boolean hasInitialized = false;
/**
* Load the native libraries <code>libjafs</code> and
* <code>libjafs</code>.
*/
static
{
try {
Class.forName("org.openafs.jafs.AFSLibraryLoader");
try {
initializeAdminClient();
} catch (Exception e) {
System.err.println(e);
}
} catch (ClassNotFoundException e) {
/* Most likely running on a client, do nothing */
}
}
/**
* Constructs a new <CODE>Token</CODE> object instance given
* the name of the AFS cell it represents and the username and password
* of the user to be Tokend for
* administrative access.
*
* @param username the name of the user to Token with
* @param password the password of that user
* @param cellName the name of the cell to Token into
* @param login if true, automatically login upon construction
* @exception AFSException If an error occurs in the native code
*/
protected Token( String username, String password, String cellName,
boolean automaticallyLogin )
throws AFSException
{
this.username = username;
this.password = password;
this.cellName = cellName;
/* By default lets authenticate the user using libafsauthent.a */
if (automaticallyLogin) login();
}
/**
* Constructs a new <CODE>Token</CODE> object instance given the
* name of the AFS cell it represents; the token for administrative
* access will be extracted from the kernel cache manager if possible.
*
* @param cellName the name of the cell to Token into
* @exception AFSException If an error occurs in the native code
*/
public Token(String cellName)
throws AFSException
{
this(null, null, cellName);
}
/**
* Constructs a new <CODE>Token</CODE> object instance given
* the name of the AFS cell it represents and the username and password
* of the user to be Tokend for
* administrative access.
*
* @param username the name of the user to Token with
* @param password the password of that user
* @param cellName the name of the cell to Token into
* @exception AFSException If an error occurs in the native code
*/
public Token( String username, String password, String cellName )
throws AFSException
{
this.username = username;
this.password = password;
this.cellName = cellName;
//System.out.println(username + ", " + cellName);
/* By default lets authenticate the user using libafsauthent.a */
login();
}
/**
* Returns the name of the AFS cell that this <code>Token</code> was
* authenticated against.
*
* @exception AFSException If an error occurs in the native code
* @return the name of the AFS cell associated with this <code>Token</code>.
*/
public String getCellName()
{
return cellName;
}
/**
* Returns the username of user to whom this token belongs.
*
* @exception AFSException If an error occurs in the native code
* @return the username of the user represented by this Token
*/
public String getUsername()
{
return username;
}
/**
* Returns a token handle that can be used to prove this authentication
* later.
*
* @exception AFSException If an error occurs in the native code
* @return a token representing the authentication
*/
protected long getHandle()
{
return tokenHandle;
}
/**
* Closes the given currently open token.
*
* @exception AFSException If an error occurs in the native code
*/
public void close() throws AFSException
{
close(tokenHandle);
}
/**
* Gets the expiration time for a given token.
*
* @return a long representing the UTC time for the token expiration
* @exception AFSException If an error occurs in the native code
*/
public long getExpiration() throws AFSException
{
return getExpiration(tokenHandle);
}
/**
* Authenticates a user in kas, and binds that authentication
* to the current process.
*
* @exception AFSException If an error occurs in the native code
*/
public void klog() throws AFSException
{
if (!hasInitialized) {
initializeUserSpace();
hasInitialized = true;
}
if (pagID > -1) {
relog(pagID);
} else {
pagID = klog(username, password, cellName, pagID);
}
}
/**
* Authenticates a user in KAS, and binds that authentication
* to the current process.
*
* @exception AFSException If an error occurs in the native code
*/
public void login() throws AFSException
{
this.tokenHandle = this.getToken(cellName, username, password);
//System.out.println("Token handle -> " + tokenHandle);
}
/**
* Initialize the user space AFS client (libjafs).
*
* <P> The user space client must be initialized prior to any
* user space related methods, including: klog, unlog, relog,
* and shutdown.
*
* @exception AFSException If an error occurs in the native code
*/
protected static void initializeUserSpace() throws AFSException
{
try {
Token.initUserSpace();
} catch (AFSException e) {
System.err.println(e.getMessage());
}
try {
Runtime.getRuntime().addShutdownHook(new AFSShutdownHandler());
} catch (Exception e) {
System.err.println("Could not register shutdown hook: " + e.toString());
}
}
/////////////// custom override methods ////////////////////
/**
* Compares two ACL objects respective to their paths and does not
* factor any other attribute. Alphabetic case is significant in
* comparing names.
*
* @param acl The ACL object to be compared to this ACL
* instance
*
* @return Zero if the argument is equal to this ACL's path, a
* value less than zero if this ACL's path is
* lexicographically less than the argument, or a value greater
* than zero if this ACL's path is lexicographically
* greater than the argument
*/
public int compareTo(Token token)
{
return this.toString().compareTo(token.toString());
}
/**
* Comparable interface method.
*
* @see #compareTo(Token)
*/
public int compareTo(Object obj)
{
return compareTo((Token)obj);
}
/**
* Tests whether two <code>Cell</code> objects are equal, based on their
* names. Does not test whether the objects are actually the same
* representational instance of the AFS cell.
*
* @param otherCell the <code>Cell</code> to test
* @return whether the specifed user is the same as this user
*/
public boolean equals( Token token )
{
return this.toString().equals( token.toString() );
}
/**
* Returns the name of this <CODE>Cell</CODE>
*
* @return the name of this <CODE>Cell</CODE>
*/
public String toString()
{
return username + "@" + cellName + ":" + tokenHandle;
}
/////////////// native methods found in *Token.c ////////////////////
/**
* Initialize the user space library.
*
* @exception AFSException If an error occurs in the native code
*/
private static native void initUserSpace() throws AFSException;
/**
* Initialize the administrative library.
*
* @exception AFSException If an error occurs in the native code
*/
protected static native void initializeAdminClient() throws AFSException;
/**
* Returns a token handle that can be used to prove this authentication
* later.
*
* @param cellName the name of the cell in which to Token this user
* @param userName the name of the user to Token
* @param password the password of the user
* @exception AFSException If an error occurs in the native code
* @return a token representing the authentication
*/
protected native long getToken( String cellName, String username,
String password )
throws AFSException;
/**
* Closes the given currently open token.
*
* @param tokenHandle the token to close
* @exception AFSException If an error occurs in the native code
*/
protected native void close( long tokenHandle ) throws AFSException;
/**
* Gets the expiration time for a given token.
*
* @param tokenHandle a token handle previously returned by a call
* to {@link #getToken}
* @see #getToken
* @return a long representing the UTC time for the token expiration
* @exception AFSException If an error occurs in the native code
*/
protected native long getExpiration( long tokenHandle )
throws AFSException;
/**
* Authenticates a user in KAS, and binds that authentication
* to the current thread or native process.
*
* @param username the login to authenticate
* (expected as username@cellname)
* @param password the password of the login
* @param cellName the name of the cell to authenticate into
* @param id the existing pag (or 0)
*
* @return the assigned pag
* @exception AFSException If an error occurs in the native code
*/
protected native int klog(String username, String password,
String cellName, int id)
throws AFSException;
/**
* Authenticates a user in KAS by a previously acquired PAG ID, and binds
* that authentication to the current thread or native process.
*
* <P> This method does not require the user's username and password to
* fully authenticate their request. Rather it utilizes the user's PAG ID
* to recapture the user's existing credentials.
*
* <P> This method is called by the public <code>klog</code> method, which
* internally manages the PAG ID. Additionally, an application needs only
* call <code>klog</code>, this reduces the amount of complexity and ensures
* that <code>relog</code> is never called before a <code>klog</code>.
*
* @param int User's current PAG (process authentication group) ID
* @exception AFSException If an error occurs in the native code
*/
protected native void relog(int id) throws AFSException;
/**
* Manually discards all AFS credentials associated with the bound user.
*
* @exception AFSException If an error occurs in the native code
*/
public native void unlog() throws AFSException;
/**
* Inform the native library that the application is
* shutting down and will be unloading.
*
* <p> The library will make a call informing the file server that it will
* no longer be available for callbacks.
*/
protected static native void shutdown();
/**
* Reclaims all memory being saved by the authentication portion of
* the native library.
* This method should be called when no more authentications are expected.
*/
protected static native void reclaimAuthMemory();
}
/*=======================================================================*/
/**
* Class that loads the native libraries required for direct communication with
* AFS. Since the Token class is serializable the function of loading the
* native libraries must be performed in a non-serialized class, one that will
* not be included in any client side application packages.
*
* @version 1.0, 06/13/2001
*/
class AFSLibraryLoader
{
static
{
System.loadLibrary("jafs");
System.loadLibrary("jafsadm");
}
}
/*=======================================================================*/
/**
* Class that handles graceful AFS application shutdown procedures by
* instructing the native library to inform the file system server that
* it is shutting down.
*
* @version 1.0, 06/13/2001
*/
class AFSShutdownHandler extends Thread
{
public AFSShutdownHandler() {}
/**
* This is the execution method satisfying the interface requirement as a
* stand alone runnable thread.
*
* <p> This method will automatically be invoked by the Thread instantiator.
*
* @see Token#shutdown()
*/
public void run()
{
System.out.println("Shutting down Java AFS library...");
org.openafs.jafs.Token.shutdown();
}
}
/*=======================================================================*/

File diff suppressed because it is too large Load Diff

View File

@ -1,72 +0,0 @@
/*
* @(#)VersionInfo.java 1.0 05/09/2005
*
* Copyright (c) 2001 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openafs.jafs;
/**
* Provides version information about the native C library and the JAVA side.
*
* At least a <<Class.forName("org.openafs.jafs.Token");>> is necessary before using these methods.
* Perhaps a redesign would be required because the library initialization occures only in Token.java.
*/
public class VersionInfo
{
/**
* Returns java interface version string
* the native library version should be higher
*/
public static String getVersionOfJavaInterface() {return "20050905";}
/**
* Returns the native library version
*
* @exception AFSException if internal (libjafs, libjafsadmin) versions differ
*/
public static String getVersionOfLibrary() throws AFSException
{
String ver = getVersionOfLibjafs();
if (!ver.equals(getVersionOfLibjafsadm()))
throw new AFSException("library versions differ", 0);
return ver;
}
/**
* Returns build information of the native library.
* This information is autogenerated by the openafs make system.
* Example: "@(#) OpenAFS 1.3.87 built 2005-09-06 "
*
* @exception AFSException if internal (libjafs, libjafsadmin) versions differ
*/
public static String getBuildInfo() throws AFSException
{
String info = getBuildInfoOfLibjafs();
if (!info.equals(getBuildInfoOfLibjafsadm()))
throw new AFSException("library build info differ", 0);
return info;
}
private static native String getVersionOfLibjafs();
private static native String getVersionOfLibjafsadm();
private static native String getBuildInfoOfLibjafs();
private static native String getBuildInfoOfLibjafsadm();
}

File diff suppressed because it is too large Load Diff

View File

@ -1,684 +0,0 @@
import java.io.File;
import java.util.GregorianCalendar;
import org.openafs.jafs.*;
/**
* @version 1.0
* @author
*/
public class testAFS
{
public class TesterThread implements Runnable
{
private String user = null;
private String pass = null;
private String cell = null;
private boolean letItRun = true;
public TesterThread(String user, String pass, String cell)
{
this.user = user;
this.pass = pass;
this.cell = cell;
}
public void finish()
{
letItRun = false;
}
public void run()
{
while(letItRun)
{
try
{
Token t = new Token(user, pass, cell);
Cell c = new Cell(t, false);
c.getInfo();
for(int j=0; j<100; j++)
{
ACL acl = new ACL("/afs/." + cell, true);
}
c.close();
} catch(Exception e) {
e.printStackTrace();
}
Thread.yield();
}
}
}
static java.io.PrintStream out = System.out;
static String firstCellPathRW = null;
static boolean allowDump = true;
static int ident = 0;
static void DumpBegin()
{
if (allowDump)
{
for(int i=0; i<ident; i++)
out.print(" ");
}
}
static void Dump(String str)
{
if (allowDump)
out.print(str);
}
static void DumpEnd()
{
if (allowDump)
out.println();
}
static void DumpLn(String str)
{
DumpBegin();
Dump(str);
DumpEnd();
}
public static String getGregDateStr(GregorianCalendar gc)
{
if (gc==null)
return "null";
else
return gc.getTime().toString();
}
public static void DumpToken(Token t)
{
try
{
DumpLn("Token: user=" + t.getUsername() +
" cell=" + t.getCellName() + " expiration=" + t.getExpiration());
} catch(AFSException e) {
e.printStackTrace();
}
}
public static void DumpFile(org.openafs.jafs.File f)
{
try
{
DumpBegin();
f.refresh();
Dump("File name: " + f.getPath() + ": ");
if (f.isDirectory()) {
Dump("This is a directory.");
} else if (f.isLink()) {
Dump("This is a symbolic-link.");
Dump(" Its target is: " + f.getTarget());
f.validate();
if (f.isFile()) {
Dump(" This object is now a file!");
} else if (f.isDirectory()) {
Dump(" This object is now a directory!");
} else if (f.isMountPoint()) {
Dump(" This object is now a volume mount point!");
}
} else if (f.isMountPoint()) {
Dump(" This is a volume mount point.");
} else if (f.isFile()) {
Dump(" This is a file. Size: " + f.length());
}
DumpEnd();
ACL acl = new ACL(f.getPath());
ident++;
DumpLn(acl.toString());
ident--;
} catch(AFSException e) {
e.printStackTrace();
}
}
public static void DumpCell(Cell cell)
{
try
{
DumpLn("Cell: " + cell.getName());
ident++;
DumpLn("MaxGroupID: " + cell.getMaxGroupID());
DumpLn("MaxUserID: " + cell.getMaxUserID());
ident--;
//test some queries, don't write to output
cell.getInfo();
cell.getInfoGroups();
cell.getInfoServers();
cell.getInfoUsers();
} catch(AFSException e) {
e.printStackTrace();
}
}
public static void DumpServer(Server s)
{
DumpLn("Server: " + s.getName());
ident++;
try
{
try //pServer'SLES9 bug:
{
DumpLn("BinaryRestartTime: " + s.getBinaryRestartTime());
} catch(AFSException e) {
e.printStackTrace();
}
DumpLn("TotalFreeSpace:" + s.getTotalFreeSpace());
DumpLn("TotalSpace:" + s.getTotalSpace());
DumpLn("TotalUsedSpace:" + s.getTotalUsedSpace());
DumpLn("GeneralRestartTime:" + s.getGeneralRestartTime());
DumpBegin();
Dump("ip addresses: ");
String[] ipAddrs = s.getIPAddresses();
for(int i=0; i<ipAddrs.length; i++)
{
Dump(ipAddrs[i] + " ");
}
DumpEnd();
DumpBegin();
Dump("isFileServer: " + s.isFileServer());
Dump(" isBadFileserver: " + s.isBadFileServer());
Dump(" isDatabase: " + s.isDatabase());
Dump(" isBadDatabase: " + s.isBadDatabase());
} catch(AFSException e) {
e.printStackTrace();
}
ident--;
try
{
//test some queries, don't write to output
s.getInfo();
try
{
s.getInfoKeys();
} catch(AFSException e) {
e.printStackTrace();
}
try //is there any partitions? why parts can be null...
{ //wrong programming concept: null instead of an empty array !!!
s.getInfoPartitions();
} catch(Exception e) {
e.printStackTrace();
}
s.getInfoProcesses();
} catch(AFSException e) {
e.printStackTrace();
}
}
public static void DumpVolume(Volume v)
{
try
{
DumpBegin();
Dump("Volume name: " + v.getName());
Dump(" ID: " + v.getID());
DumpEnd();
} catch(AFSException e) {
e.printStackTrace();
}
ident++;
try
{
DumpBegin();
Dump("BackupID: " + v.getBackupID());
Dump(" ReadOnlyID: " + v.getReadOnlyID());
Dump(" ReadWriteID: " + v.getReadWriteID());
DumpEnd();
DumpBegin();
Dump("LastUpdateDate: " + getGregDateStr(v.getLastUpdateDate()));
Dump(" CreationDate: " + getGregDateStr(v.getCreationDate()));
Dump(" AccessesSinceMidnight: " + v.getAccessesSinceMidnight());
DumpEnd();
DumpBegin();
Dump("FileCount: " + v.getFileCount());
Dump(" CurrentSize: " + v.getCurrentSize());
Dump(" TotalFreeSpace: " + v.getTotalFreeSpace());
DumpEnd();
DumpBegin();
Dump("Type: " + v.getType());
Dump(" Disposition: " + v.getDisposition());
DumpEnd();
//test some queries, don't write to output
v.getInfo();
} catch(AFSException e) {
e.printStackTrace();
}
ident--;
}
public static void DumpPartition(Partition p)
{
try
{
DumpBegin();
Dump("Partition name: " + p.getName());
Dump(" ID: " + p.getID());
Dump(" DeviceName: " + p.getDeviceName());
DumpEnd();
} catch(AFSException e) {
e.printStackTrace();
}
ident++;
try
{
DumpBegin();
Dump("TotalFreeSpace: " + p.getTotalFreeSpace());
Dump(" TotalQuota: " + p.getTotalQuota());
Dump(" TotalTotalSpace: " + p.getTotalSpace());
DumpEnd();
//test some queries, don't write to output
p.getInfo();
p.getInfoVolumes();
} catch(AFSException e) {
e.printStackTrace();
}
ident--;
}
public static void DumpGroup(Group g)
{
try
{
DumpBegin();
Dump("Group name: " + g.getName());
Dump(" Type: " + g.getType());
Dump(" UID: " + g.getUID());
DumpEnd();
//test some queries, don't write to output
g.getInfo();
} catch(AFSException e) {
e.printStackTrace();
}
}
public static void DumpUser(User u)
{
DumpLn("User name: " + u.getName());
ident++;
try
{
DumpLn("EncryptionKey" + u.getEncryptionKey());
DumpBegin();
Dump("DaysToPasswordExpire: " + u.getDaysToPasswordExpire());
Dump(" FailLoginCount: " + u.getFailLoginCount());
Dump(" KeyCheckSum: " + u.getKeyCheckSum());
DumpEnd();
DumpBegin();
Dump("UserExpirationDate: " + getGregDateStr(u.getUserExpirationDate()));
Dump(" MaxTicketLifetime: " + u.getMaxTicketLifetime());
Dump(" LockedUntilDate: " + getGregDateStr(u.getLockedUntilDate()));
DumpEnd();
//test some queries, don't write to output
u.getInfo();
u.getInfoGroups();
u.getInfoGroupsOwned();
} catch(AFSException e) {
e.printStackTrace();
}
ident--;
}
static void DumpProcess(org.openafs.jafs.Process p)
{
DumpLn("Process name: " + p.getName());
ident++;
try
{
DumpBegin();
Dump("StartTimeDate: " + getGregDateStr(p.getStartTimeDate()));
Dump(" ExitTimeDate: " + getGregDateStr(p.getExitTimeDate()));
DumpEnd();
//test some queries, don't write to output
p.getInfo();
} catch(AFSException e) {
e.printStackTrace();
}
ident--;
}
public static Token testToken(String user, String pass, String cell)
{
Token token = null;
try
{
token = new Token(user, pass, cell);
DumpToken(token);
testCell(token);
} catch(AFSException e) {
e.printStackTrace();
}
return token;
}
public static void testFilesRecursive(File dir)
{
try
{
java.io.File fj = new java.io.File(dir.getPath());
String[] strSubdirs = fj.list();
for(int i=0; i<strSubdirs.length; i++)
{
org.openafs.jafs.File f = new org.openafs.jafs.File(
dir.getPath() + "/" + strSubdirs[i]);
DumpFile(f);
f.validate();
if (f.isDirectory() || f.isMountPoint() || f.isLink())
{
testFilesRecursive(dir);
}
}
} catch(AFSFileException e) {
e.printStackTrace();
}
}
public static void testFiles()
throws AFSException, AFSFileException
{
org.openafs.jafs.File f = new org.openafs.jafs.File(firstCellPathRW);
DumpFile(f);
testFilesRecursive(f);
}
public static void testCell(Token token)
{
Cell cell = null;
try
{
cell = new Cell(token, false);
DumpCell(cell);
} catch(AFSException e) {
e.printStackTrace();
}
if (cell==null)
return;
ident++;
try
{
Group[] groups = cell.getGroups();
for(int i=0; i<groups.length; i++)
{
testGroup(groups[i]);
}
Server[] servers = cell.getServers();
for(int j=0; j<servers.length; j++)
{
testServer(servers[j]);
}
} catch(AFSException e) {
e.printStackTrace();
}
ident--;
try
{
if (cell!=null)
cell.close();
} catch(AFSException e) {
e.printStackTrace();
}
}
public static void testServer(Server server)
throws AFSException
{
DumpServer(server);
ident++;
try
{
Partition[] parts = server.getPartitions();
if (parts!=null)
{
for(int i=0; i<parts.length; i++)
{
testPartition(parts[i]);
}
}
org.openafs.jafs.Process[] procs = server.getProcesses();
if (procs!=null)
{
for(int i=0; i<procs.length; i++)
{
DumpProcess(procs[i]);
}
}
DumpLn("salvage...");
server.salvage();
DumpLn("getLog...");
try
{
server.getLog("/var/log/openafs/BosLog");
} catch(AFSException e) {
e.printStackTrace();
}
//DumpLn("stopAllProcesses...");
//server.stopAllProcesses();
//DumpLn("startAllProcesses...");
//server.startAllProcesses();
DumpLn("syncServer...");
server.syncServer();
DumpLn("syncVLDB...");
server.syncVLDB();
DumpLn("ok.");
} catch(AFSException e) {
e.printStackTrace();
}
ident--;
}
public static void testProcess(org.openafs.jafs.Process p)
throws AFSException
{
DumpProcess(p);
}
public static void testPartition(Partition part)
throws AFSException
{
DumpPartition(part);
ident++;
Volume[] vols = part.getVolumes();
for(int i=0; i<vols.length; i++)
{
testVolume(vols[i]);
}
ident--;
}
public static void testVolume(Volume vol)
throws AFSException
{
DumpVolume(vol);
}
public static void testGroup(Group group)
throws AFSException
{
DumpGroup(group);
ident++;
User[] users = group.getMembers();
for(int i=0; i<users.length; i++)
{
testUser(users[i]);
}
ident--;
}
public static void testUser(User user)
throws AFSException
{
DumpUser(user);
}
public static void testNewVolume(String cellName, String userName, String passString)
{
if (firstCellPathRW==null)
{
System.err.println("testNewVolume cannot be executed (null args).");
return;
}
String volName = "myTestJafsVolume92834";
String mpName = firstCellPathRW + "/" + volName;
try
{
Token token = new Token(cellName, userName, passString);
Cell cell = new Cell(token, false);
Server[] servers = cell.getServers();
if (servers.length==0)
{
System.err.println("Error: failed to run\"testNewVolume\"!");
return;
}
Partition firstPart = null;
int i;
for(i=0; i<servers.length; i++)
{
Partition[] parts = servers[i].getPartitions();
if (parts==null)
continue;
if (parts.length!=0)
{
firstPart = parts[0];
break;
}
}
if (firstPart==null)
{
System.err.println("Error: failed to find any partition on any server - \"testNewVolume\" couldn't be tested!");
return;
}
Volume v = new Volume(volName, firstPart);
DumpLn("Creating a new volume " + volName + " ...");
v.create(0);
v.lock();
v.unlock();
volName = "myTestJafsVolume2389";
DumpLn("Renaming volume to " + volName + " ...");
v.rename(volName);
DumpLn("Creating an rw mount point " + mpName + " ...");
v.createMountPoint(mpName, true);
DumpLn("Deleting mount point...");
java.lang.Runtime.getRuntime().exec("fs rmmount " + mpName);
DumpLn("Creating RO...");
Volume volRO = v.createReadOnly(firstPart);
DumpLn("Creating backup...");
v.createBackup();
DumpLn("Releaseing volume...");
v.release();
//v.moveTo(); //needs a more careful test env
DumpLn("Salvaging volume...");
v.salvage();
DumpLn("Deleting volume...");
v.delete();
DumpLn("Deleting RO site...");
volRO.delete();
DumpLn("OK.");
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args)
{
try
{
if (args.length<4)
{
System.err.println("testAFS <user> <pass> <cell_name> <# of cycles>");
return;
}
Class.forName("org.openafs.jafs.Token"); //initialization...
System.out.println("Java interface version: " + VersionInfo.getVersionOfJavaInterface());
System.out.println("Library version: " + VersionInfo.getVersionOfLibrary());
System.out.println("Build info: " + VersionInfo.getBuildInfo());
//first test whether token is valid
//and load libraries with it
Token t0 = new Token(args[0], args[1], args[2]);
t0.close();
System.out.print("Starting another tester thread...");
testAFS ta = new testAFS();
TesterThread tt = ta.new TesterThread(args[0], args[1], args[2]);
Thread tTest = new Thread(tt);
tTest.start();
System.out.println("started.");
firstCellPathRW = "/afs/." + args[2];
int numOfCycles = Integer.parseInt(args[3]);
for(int i=0; i<numOfCycles || numOfCycles==0; i++)
{
testToken(args[0], args[1], args[2]);
testFiles();
testNewVolume(args[0], args[1], args[2]);
System.out.print("ACL excercising...");
allowDump = false;
for(int j=0; j<100; j++)
{
testFiles();
System.out.print(".");
}
System.out.println();
allowDump = true;
AFSException afs = new AFSException(1);
System.out.println("cycle #" + (i+1) + "/" + numOfCycles + " done.");
}
tt.finish();
System.out.println("All done.");
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -1,237 +0,0 @@
/*
* Copyright (c) 2001-2002 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <afsconfig.h>
#include <afs/param.h>
#include <afs/stds.h>
#include <errno.h>
#include "Internal.h"
#include "org_openafs_jafs_ACL.h"
#include <stdio.h>
#include <sys/ioctl.h>
#include <afs/vice.h>
#include <netinet/in.h>
#include <afs/venus.h>
#include <afs/afs_consts.h>
#include <afs/afs_args.h>
#include "GetNativeString.h"
/*
#include <afs/afs_osi.h>
*/
/* just for debugging */
#define MAXNAME 100
#define MAXINSIZE 1300 /* pioctl complains if data is larger than this */
#define VMSGSIZE 128 /* size of msg buf in volume hdr */
static char space[AFS_PIOCTL_MAXSIZE];
#ifdef DMALLOC
#include "dmalloc.h"
#endif
#define ACL_LEN 1024
#ifndef ERROR_H
#define ERROR_H
#endif
extern int error_intr;
extern int error_nomem;
/**
* Returns a formatted string representing the ACL for the specified path.
*
* path the directory path
* returns NULL if an exception is encountered.
*/
char* getACL(char *path)
{
struct ViceIoctl params;
char *buffer;
int rval1=0;
buffer = malloc(ACL_LEN);
params.in = NULL;
params.out = NULL;
params.in_size = params.out_size = 0;
if (!buffer) {
fprintf(stderr, "ERROR: ACL::getACL -> could not allocate buffer\n");
return NULL;
}
params.out = buffer;
params.out_size = ACL_LEN;
#if defined(AFS_PPC64_LINUX_ENV) || defined(AFS_S390X_LINUX_ENV)
if(pioctl(path, VIOCGETAL, &params, 1)) {
#else /* AFS_PPC_LINUX_ENV */
if(syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, VIOCGETAL, &params, 1)) {
#endif /* AFS_PPC_LINUX_ENV */
fprintf(stderr, "ERROR: ACL::getACL -> VIOCGETAL failed: %d, path: %s\n", errno, path);
free(buffer);
return NULL;
}
return params.out;
}
/**
* Sets the ACL for the specified path using the provided string
* representation.
*
* path the directory path
* aclString string representation of ACL to be set
* returns TRUE if the operation succeeds; otherwise FALSE;
*/
jboolean setACL(char *path, char *aclString)
{
struct ViceIoctl params;
char *redirect, *parentURI, *cptr;
params.in = aclString;
params.in_size = strlen(aclString) + 1;
params.out = NULL;
params.out_size = 0;
#if defined(AFS_PPC64_LINUX_ENV) || defined(AFS_S390X_LINUX_ENV)
if(pioctl(path, VIOCSETAL, &params, 1)) {
#else /* AFS_PPC_LINUX_ENV */
if(syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, VIOCSETAL, &params, 1)) {
#endif /* AFS_PPC_LINUX_ENV */
fprintf(stderr, "ERROR: ACL::setACL -> VIOCSETAL failed: %d, path: %s\n", errno, path);
return JNI_FALSE;
}
return JNI_TRUE;
}
/**
* Returns a formatted string representing the ACL for the specified path.
*
* The string format is in the form of a ViceIoctl and is as follows:
* printf("%d\n%d\n", positiveEntriesCount, negativeEntriesCount);
* printf("%s\t%d\n", userOrGroupName, rightsMask);
*
* path the directory path
* returns NULL if an exception is encountered.
*/
JNIEXPORT jstring JNICALL Java_org_openafs_jafs_ACL_getACLString
(JNIEnv *env, jobject obj, jstring pathUTF)
{
char *path, *acl;
jstring answer = NULL;
/*jchar* wpath;
path = (char*) (*env)->GetStringUTFChars(env, pathUTF, 0);
wpath=(jchar*) (*env)->GetStringChars(env,pathUTF,0);*/
path = GetNativeString(env,pathUTF);
if(path == NULL) {
fprintf(stderr, "ERROR: ACL::getACLString ->");
fprintf(stderr, "path = NULL\n");
throwMessageException( env, "Path is NULL" );
return NULL;
}
acl = getACL(path);
if(acl) {
answer = (*env) -> NewStringUTF(env, acl);
free(acl);
} else {
throwAFSException( env, errno );
}
/*(*env)->ReleaseStringUTFChars(env, pathUTF, path);
(*env)->ReleaseStringChars(env, pathUTF, (jchar*)wpath);*/
free(path); //psomogyi memory leak - added
return answer;
}
/**
* Sets the ACL for the specified path using the provided string
* representation.
*
* The string format is in the form of a ViceIoctl and is as follows:
* printf("%d\n%d\n", positiveEntriesCount, negativeEntriesCount);
* printf("%s\t%d\n", userOrGroupName, rightsMask);
*
* path the directory path
* aclString string representation of ACL to be set
* throws an afsAdminExceptionName if an internal exception is encountered.
*/
JNIEXPORT void JNICALL Java_org_openafs_jafs_ACL_setACLString
(JNIEnv *env, jobject obj, jstring pathUTF, jstring aclStringUTF)
{
char *path, *aclString;
if(!pathUTF) {
fprintf(stderr, "ERROR: ACL::setACLString -> pathUTF == NULL\n");
throwMessageException( env, "pathUTF == NULL" );
return;
}
/*path = (char*) (*env)->GetStringUTFChars(env, pathUTF, 0);*/
path = GetNativeString(env,pathUTF);
if(path == NULL) {
fprintf(stderr, "ERROR: ACL::setACLString -> failed to get path\n");
throwMessageException( env, "Failed to get path" );
return;
}
if(!aclStringUTF) {
fprintf(stderr, "ERROR: ACL::setACLString -> aclStringUTF == NULL\n");
throwMessageException( env, "aclStringUTF == NULL" );
return;
}
/*aclString = (char*) (*env)->GetStringUTFChars(env, aclStringUTF, 0);*/
aclString = GetNativeString(env,aclStringUTF);
if(aclString == NULL) {
fprintf(stderr, "ERROR: ACL::setACLString -> failed to get aclString\n");
(*env)->ReleaseStringUTFChars(env, pathUTF, path);
throwMessageException( env, "aclString == NULL" );
return;
}
if (!setACL(path, aclString)) {
throwAFSException( env, errno );
}
/*(*env)->ReleaseStringUTFChars(env, pathUTF, path);
(*env)->ReleaseStringUTFChars(env, aclStringUTF, aclString);*/
free(path);
free(aclString);
}

View File

@ -1,421 +0,0 @@
/*
* Copyright (c) 2001-2002 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "Internal.h"
#include "org_openafs_jafs_Cell.h"
#include "org_openafs_jafs_Token.h"
#include <stdio.h>
#include <afs_kasAdmin.h>
#include <afs_ptsAdmin.h>
#include <afs_clientAdmin.h>
#include <kautils.h>
#include <cellconfig.h>
#include <afs_AdminClientErrors.h>
#include <rx/rxkad.h>
/**
* Static function used to initialize the client library and the
* jafs library.
*
* env the Java environment
* obj the current Java object
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Token_initializeAdminClient(JNIEnv *env, jclass cls)
{
afs_status_t ast;
if( !afsclient_Init( &ast ) ) {
throwAFSException( env, ast );
return;
}
}
/**
* Authenticates the given user and password in the cell. Returns
* a token that can be used to prove this authentication later.
*
* env the Java environment
* obj the current Java object
* jcellName the name of the cell in which to authenticate this user
* juserName the name of the user to authenticate
* jpassword the password of the user
* returns a token representing the authentication
*/
JNIEXPORT jlong JNICALL
Java_org_openafs_jafs_Token_getToken
(JNIEnv *env, jobject obj, jstring jcellName, jstring juserName,
jstring jpassword)
{
afs_status_t ast;
const char *cellName;
const char *userName;
const char *password;
void *tokenHandle;
int rc;
int err;
// convert java strings
if( jcellName != NULL ) {
cellName = (*env)->GetStringUTFChars(env, jcellName, 0);
if( !cellName ) {
throwAFSException( env, JAFSADMNOMEM );
return 0;
}
} else {
cellName = NULL;
}
if( juserName != NULL ) {
userName = (*env)->GetStringUTFChars(env, juserName, 0);
if( !userName ) {
throwAFSException( env, JAFSADMNOMEM );
return 0;
}
} else {
userName = NULL;
}
if( jpassword != NULL ) {
password = (*env)->GetStringUTFChars(env, jpassword, 0);
if( !password ) {
throwAFSException( env, JAFSADMNOMEM );
return 0;
}
} else {
password = NULL;
}
err = (password==NULL || userName==NULL)
? afsclient_TokenGetExisting( cellName, &tokenHandle, &ast)
: afsclient_TokenGetNew( cellName, userName, password, &tokenHandle, &ast);
if ( !err ) {
// release converted strings
if( cellName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jcellName, cellName);
}
if( userName != NULL ) {
(*env)->ReleaseStringUTFChars(env, juserName, userName);
}
if( password != NULL ) {
(*env)->ReleaseStringUTFChars(env, jpassword, password);
}
throwAFSException( env, ast );
return 0;
}
// release converted strings
if( cellName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jcellName, cellName);
}
if( userName != NULL ) {
(*env)->ReleaseStringUTFChars(env, juserName, userName);
}
if( password != NULL ) {
(*env)->ReleaseStringUTFChars(env, jpassword, password);
}
return (jlong) tokenHandle;
}
/**
* Closes the given currently open token.
*
* env the Java environment
* obj the current Java object
* tokenHandle the token to close
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Token_close
(JNIEnv *env, jobject obj, jlong tokenHandle)
{
afs_status_t ast;
if( !afsclient_TokenClose( (void *) tokenHandle, &ast ) ) {
throwAFSException( env, ast );
return;
}
}
/**
* Opens a cell for administrative use, based on the token provided.
* Returns a cell handle to be used by other methods as a means of
* authentication.
*
* env the Java environment
* obj the current Java object
* jcellName the name of the cell for which to get the handle
* tokenHandle a token handle previously returned by a call to getToken
* returns a handle to the open cell
*/
JNIEXPORT jlong JNICALL
Java_org_openafs_jafs_Cell_getCellHandle
(JNIEnv *env, jobject obj, jstring jcellName, jlong tokenHandle)
{
afs_status_t ast;
const char *cellName;
void *cellHandle;
if( jcellName != NULL ) {
cellName = (*env)->GetStringUTFChars(env, jcellName, 0);
if( !cellName ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
cellName = NULL;
}
if( !afsclient_CellOpen( cellName, (void *) tokenHandle,
&cellHandle, &ast ) ) {
if( cellName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jcellName, cellName);
}
throwAFSException( env, ast );
return;
}
if( cellName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jcellName, cellName);
}
return (jlong) cellHandle;
}
/**
* Closes the given currently open cell handle.
*
* env the Java environment
* obj the current Java object
* cellHandle the cell handle to close
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Cell_closeCell (JNIEnv *env, jobject obj,
jlong cellHandle)
{
afs_status_t ast;
if( !afsclient_CellClose( (void *) cellHandle, &ast ) ) {
throwAFSException( env, ast );
return;
}
}
/**
* Opens a server for administrative vos use, based on the cell handle
* provided. Returns a vos server handle to be used by other
* methods as a means of identification.
*
* env the Java environment
* obj the current Java object
* cellHandle a cell handle previously returned by
* a call to getCellHandle
* jserverName the name of the server for which to retrieve
* a vos handle
* returns a vos handle to the server
*/
JNIEXPORT jlong JNICALL
Java_org_openafs_jafs_Server_getVosServerHandle
(JNIEnv *env, jobject obj, jlong cellHandle, jstring jserverName)
{
afs_status_t ast;
void *serverHandle;
// convert java string
const char *serverName;
if( jserverName != NULL ) {
serverName = (*env)->GetStringUTFChars(env, jserverName, 0);
if( !serverName ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
serverName = NULL;
}
if( !vos_ServerOpen( (void *) cellHandle, serverName,
(void **) &serverHandle, &ast ) ) {
if( serverName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jserverName, serverName);
}
throwAFSException( env, ast );
return 0;
}
// release converted string
if( serverName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jserverName, serverName);
}
return (jlong) serverHandle;
}
/**
* Closes the given currently open vos server handle.
*
* env the Java environment
* obj the current Java object
* vosServerHandle the vos server handle to close
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Server_closeVosServerHandle
(JNIEnv *env, jobject obj, jlong vosServerHandle)
{
afs_status_t ast;
if( !vos_ServerClose( (void *) vosServerHandle, &ast ) ) {
throwAFSException( env, ast );
return;
}
}
/**
* Opens a server for administrative bos use, based on the cell handle
* provided. Returns a bos server handle to be used by other methods
* as a means of identification.
*
* env the Java environment
* obj the current Java object
* cellHandle a cell handle previously returned by a call
* to getCellHandle
* jserverName the name of the server for which to retrieve
* a bos handle
* returns a bos handle to the server
*/
JNIEXPORT jlong JNICALL
Java_org_openafs_jafs_Server_getBosServerHandle
(JNIEnv *env, jobject obj, jlong cellHandle, jstring jserverName)
{
afs_status_t ast;
void *serverHandle;
// convert java string
const char *serverName;
if( jserverName != NULL ) {
serverName = (*env)->GetStringUTFChars(env, jserverName, 0);
if( !serverName ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
serverName = NULL;
}
if( !bos_ServerOpen( (void *) cellHandle, serverName,
(void **) &serverHandle, &ast ) ) {
if( serverName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jserverName, serverName);
}
throwAFSException( env, ast );
return 0;
}
// release converted string
if( serverName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jserverName, serverName);
}
return (jlong) serverHandle;
}
/**
* Closes the given currently open bos server handle.
*
* env the Java environment
* obj the current Java object
* bosServerHandle the bos server handle to close
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Server_closeBosServerHandle
(JNIEnv *env, jobject obj, jlong bosServerHandle)
{
afs_status_t ast;
if( !bos_ServerClose( (void *) bosServerHandle, &ast ) ) {
throwAFSException( env, ast );
return;
}
}
/**
* Gets the expiration time for a given token.
*
* env the Java environment
* obj the current Java object
*
* tokenHandle a token handle previously returned by a call
* to getToken
* returns a long representing the UTC time for the token expiration
*/
JNIEXPORT jlong JNICALL
Java_org_openafs_jafs_Token_getExpiration
(JNIEnv *env, jobject obj, jlong tokenHandle)
{
afs_status_t ast;
unsigned long expTime;
char *prince = malloc( sizeof(char)*KAS_MAX_NAME_LEN );
char *inst = malloc( sizeof(char)*KAS_MAX_NAME_LEN );
char *cell = malloc( sizeof(char)*AFS_MAX_SERVER_NAME_LEN );
int hkt;
if( !prince || !inst || !cell ) {
if( prince ) {
free( prince );
}
if( inst ) {
free( inst );
}
if( cell ) {
free( cell );
}
throwAFSException( env, JAFSADMNOMEM );
return;
}
if( !afsclient_TokenQuery( (void *) tokenHandle, &expTime, prince, inst,
cell, &hkt, &ast ) ) {
free( prince );
free( inst );
free( cell );
throwAFSException( env, ast );
return 0;
}
free( prince );
free( inst );
free( cell );
return (jlong) expTime;
}
// reclaim global memory used by this portion
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Token_reclaimAuthMemory (JNIEnv *env, jclass cls)
{
}

File diff suppressed because it is too large Load Diff

View File

@ -1,41 +0,0 @@
20050524: (by Peter Somogyi somogyi@de.ibm.com)
- bugfix: ACL.c: syscall => pioctl (problem on ppc64)
- bugfix: ACL.c: memory leak
- some minor changes in ACL.c to be more accordance to src/venus/fs.c
- bugfix: inet_ntoa crashed; implemented an own function is Server.c instead
- modified src/libuafs/MakefileProto.LINUX: added -fPIC flag (doesn't tolerate mixing with non-fPIC on ppc)
20050525: (somogyi@de.ibm.com)
- removed non-error message from getACL; extended the error report (path string) instead of it
20050602: (somogyi@de.ibm.com)
- moved ACL.c from libjafs.so into libjafsadm.so
(solves pioctl call failure in [get|set]ACL)
In the future each one should be in libjafsadm.so - using _only_ AFS API (!!!).
20050603:
- moved GetNativeString from libjafs.so into libjafsadm.so
20050610:
- created an automatic testAFS comprehensive java test
- modified java library: made all getInfo-like methods public
20050614:
- bugfix: Cell.c: ..._getServersNextString: return "not_implemented" instead of making a crash
20050616:
- created a multithreaded test; pioctl in getACL fails on i386_linux26, but doesn't fail under ppc64_linux26
20050617:
- [#]ifdef-separated c sources and makefiles for ppc64_linux26
- bugfix: eliminating thread-safety crashes on pioctl/i386, but only pioctl works on ppc64 (idef-ed)
(pioctl didn't crash on ppc64)
20050720:
- added s390x support, needs some special patches to openafs src
- added 64-bit support, affects java part
- refined testAFS.java tester tool
20050727:
- tested on ppc64/32, fixed some bugs because of some s390x modifications
20050830:
- modified Makefile.in to support OpenAFS version 1.3.85 or higher (added util/rxkstats.o to libjafs.so)
20050906:
- added version info (overwritting an earlier implementation)
- added build info (using AFS_component_version_number.c) which is autogenerated

View File

@ -1,12 +0,0 @@
#ifndef _Jafsadm_Exceptions
#define _Jafsadm_Exceptions
static char *afsExceptionName = "org/openafs/jafs/AFSException";
static char *afsFileExceptionName = "org/openafs/jafs/AFSFileException";
static char *afsSecurityExceptionName = "org/openafs/jafs/AFSSecurityException";
#endif

View File

@ -1,615 +0,0 @@
/*
* Copyright (c) 2001-2002 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <afs/param.h>
#include <afs/com_err.h>
#include <errno.h>
#include "Internal.h"
#include "org_openafs_jafs_File.h"
#include <sys/stat.h>
#include <fcntl.h>
#include <jni.h>
#include <pthread.h>
/*#include <afs/afs_usrops.h>*/
#include <afs/prs_fs.h>
#include <sys/time.h>
#include <unistd.h>
/* Access Rights */
#define UAFS_READ 1
#define UAFS_WRITE 2
#define UAFS_INSERT 4
#define UAFS_LOOKUP 8
#define UAFS_DELETE 16
#define UAFS_LOCK 32
#define UAFS_ADMIN 64
#ifdef DMALLOC
#include "dmalloc.h"
#endif
void setFileNotExistsAttributes(JNIEnv *env, jobject *obj);
typedef struct {
char *fileName;
void *next;
} FileNameNode;
/*static char compile_date[] = COMPILE_DATE;*/
int sub_time(struct timeval *tv1, struct timeval *tv2)
{
if (tv2->tv_usec > tv1->tv_usec) {
tv1->tv_usec += 1000000;
tv1->tv_usec -= 1;
}
tv1->tv_usec -= tv2->tv_usec;
tv1->tv_sec -= tv2->tv_sec;
}
/**
* Sets dirName to the absolute path according to the path field
* within the Java File object (obj).
*
* env the Java environment
* obj the current Java object
*/
char* getAbsolutePath(JNIEnv *env, jobject *obj, char *dirName)
{
jclass thisClass;
jstring jDirName;
jmethodID getAbsolutePathID;
const char *auxDirName;
jfieldID fid;
thisClass = (*env)->GetObjectClass(env, *obj);
if(thisClass == NULL) {
fprintf(stderr, "File::getAbsolutePath(): GetObjectClass failed\n");
return NULL;
}
fid = (*env)->GetFieldID(env, thisClass, "path", "Ljava/lang/String;");
if (fid == 0) {
fprintf(stderr, "File::getAbsolutePath(): GetFieldID (path) failed\n");
return NULL;
}
jDirName = (*env)->GetObjectField(env, *obj, fid);
if(jDirName == NULL) {
fprintf(stderr, "File::getAbsolutePath(): failed to get file name\n");
return NULL;
}
auxDirName = (*env) -> GetStringUTFChars(env, jDirName, 0);
strcpy(dirName, auxDirName);
(*env) -> ReleaseStringUTFChars(env, jDirName, auxDirName);
}
/**
* Performs a file stat on the actual AFS file and populates
* the Java object's respective field members with the appropriate values.
* method will, if authorized, perform a stat on the
* actual AFS file and update its respective field members; defining
* this file object's attributes.
*
* env the Java environment
* obj the current Java object
*
* return true if and only if the current user is allowed to stat the file;
* false otherwise.
*
* throws AFSException
*/
JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_setAttributes
(JNIEnv *env, jobject obj)
{
char target[FILENAME_MAX+1];
char dirName[FILENAME_MAX];
jclass thisClass;
jfieldID fid;
struct stat st;
int rc, fd;
int mtpoint = 0;
jboolean islink = JNI_FALSE;
int i;
struct timeval tv0, tv1;
/*memset(target, 0, FILENAME_MAX);*/
*dirName = '\0';
getAbsolutePath(env, &obj, dirName);
/*fprintf(stderr, "dirName=%s\n", dirName);*/
if(*dirName == '\0') {
fprintf(stderr, "File::setAttributes(): failed to get dirName\n");
return JNI_FALSE;
}
thisClass = (*env) -> GetObjectClass(env, obj);
if(thisClass == NULL) {
fprintf(stderr, "File::setAttributes(): GetObjectClass failed\n");
return JNI_FALSE;
}
gettimeofday(&tv0, NULL);
if ((strcmp(dirName, "/afs") == 0) || (strcmp(dirName, "/afs/") == 0)) {
rc = 1; /* special case for /afs since statmountpoint fails on it */
} else {
rc = uafs_statmountpoint(dirName);
gettimeofday(&tv1, NULL);
sub_time(&tv1, &tv0);
/*printf("%s: statmountpoint %d.%06d\n", dirName, tv1.tv_sec, tv1.tv_usec);*/
}
if(rc < 0) {
setError(env, &obj, errno);
if(errno == ENOENT) {
setFileNotExistsAttributes(env, &obj);
return JNI_TRUE; /* not really an error */
} else {
fprintf(stderr, "File::setAttributes(): uafs_statmountpoint failed "
"for %s (%s)\n", dirName, afs_error_message(errno));
return JNI_FALSE;
}
}
if (rc == 1) {
/* this is an AFS mount point; we don't want to stat it */
/* fake up a stat entry instead */
mtpoint = 1;
st.st_mtime = 0;
st.st_size = 2048;
st.st_mode = 0; /* don't match anything */
} else {
mtpoint = 0;
fid = (*env)->GetFieldID(env, thisClass, "isLink", "Z");
if (fid == 0) {
fprintf(stderr, "File::setAttributes(): GetFieldID (isLink) failed\n");
setError(env, &obj, -1);
return JNI_FALSE;
}
islink = (*env)->GetBooleanField(env, obj, fid);
if (islink != JNI_TRUE) {
rc = uafs_lstat(dirName, &st);
} else {
/* Here we are being called on a link object for the second time,
so we want info on the object pointed to by the link. */
fprintf(stderr, "islink = TRUE on file %s\n", dirName);
rc = uafs_stat(dirName, &st);
}
if(rc < 0) {
setError(env, &obj, errno);
fprintf(stderr, "uafs_lstat failed for dir %s: error %d\n",
dirName, errno);
if(errno == ENOENT) {
setFileNotExistsAttributes(env, &obj);
return JNI_TRUE;
}
fprintf(stderr,
"File::setAttributes(): uafs_stat failed for %s (%s)\n",
dirName, afs_error_message(errno));
return JNI_FALSE;
}
}
fid = (*env)->GetFieldID(env, thisClass, "exists", "Z");
if (fid == 0) {
fprintf(stderr,
"File::setAttributes(): GetFieldID (exists) failed\n");
setError(env, &obj, -1);
return JNI_FALSE;
}
(*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
fid = (*env)->GetFieldID(env, thisClass, "isDirectory", "Z");
if (fid == 0) {
fprintf(stderr,
"File::setAttributes(): GetFieldID (isDirectory) failed\n");
setError(env, &obj, -1);
return JNI_FALSE;
}
if ((st.st_mode & S_IFMT) == S_IFDIR && !mtpoint) {
(*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
} else {
(*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
}
fid = (*env)->GetFieldID(env, thisClass, "isFile", "Z");
if (fid == 0) {
fprintf(stderr,
"File::setAttributes(): GetFieldID (isFile) failed\n");
setError(env, &obj, -1);
return JNI_FALSE;
}
if ((st.st_mode & S_IFMT) == S_IFREG) {
(*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
} else {
(*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
}
fid = (*env)->GetFieldID(env, thisClass, "isLink", "Z");
if (fid == 0) {
fprintf(stderr,
"File::setAttributes(): GetFieldID (isLink) failed\n");
setError(env, &obj, -1);
return JNI_FALSE;
}
if (islink != JNI_TRUE) { /* don't re-process link */
if ((st.st_mode & S_IFMT) == S_IFLNK) {
(*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
/* Find the target of the link */
rc = uafs_readlink(dirName, target, FILENAME_MAX);
if (rc < 0) {
fprintf(stderr, "File::setAttributes(): uafs_readlink failed\n");
setError(env, &obj, errno);
return JNI_FALSE;
} else {
target[rc] = 0; /* weird that we have to do this */
/*fprintf(stderr, "readlink %s succeeded, target=%s, rc=%d\n", dirName,
target, rc);*/
}
rc = setString(env, &obj, "target", target);
if (rc < 0) {
fprintf(stderr, "setString dirName=%s target=%s failed\n",
dirName, target);
}
} else {
(*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
}
}
fid = (*env)->GetFieldID(env, thisClass, "isMountPoint", "Z");
if (fid == 0) {
fprintf(stderr,
"File::setAttributes(): GetFieldID (isMountPoint) failed\n");
setError(env, &obj, -1);
return JNI_FALSE;
}
if (mtpoint) {
(*env)->SetBooleanField(env, obj, fid, JNI_TRUE);
} else {
(*env)->SetBooleanField(env, obj, fid, JNI_FALSE);
}
fid = (*env)->GetFieldID(env, thisClass, "lastModified", "J");
if (fid == 0) {
fprintf(stderr,
"File::setAttributes(): GetFieldID (lastModified) failed\n");
setError(env, &obj, -1);
return JNI_FALSE;
}
(*env)->SetLongField(env, obj, fid, ((jlong) st.st_mtime)*1000);
fid = (*env)->GetFieldID(env, thisClass, "length", "J");
if (fid == 0) {
fprintf(stderr,
"File::setAttributes(): GetFieldID (length) failed\n");
setError(env, &obj, -1);
return JNI_FALSE;
}
(*env)->SetLongField(env, obj, fid, st.st_size);
setError(env, &obj, 0);
return JNI_TRUE;
}
/**
* Returns the permission/ACL mask for the represented directory
*
* env the Java environment
* obj the current Java object
*
* return permission/ACL mask
*/
JNIEXPORT jint JNICALL Java_org_openafs_jafs_File_getRights
(JNIEnv *env, jobject obj)
{
char dirName[FILENAME_MAX];
jclass thisClass;
jfieldID fid;
int rc;
int afs_rights;
int rights;
*dirName = '\0';
getAbsolutePath(env, &obj, dirName);
if(*dirName == '\0') {
fprintf(stderr, "File::getRights(): failed to get dirName\n");
setError(env, &obj, -1);
return JNI_FALSE;
}
/*-Access Rights-
* UAFS_READ 1
* UAFS_WRITE 2
* UAFS_INSERT 4
* UAFS_LOOKUP 8
* UAFS_DELETE 16
* UAFS_LOCK 32
* UAFS_ADMIN 64
*/
rights = 0;
afs_rights = uafs_getRights(dirName);
if (afs_rights < 0) {
setError(env, &obj, errno);
return -1;
}
if (afs_rights & PRSFS_READ)
rights |= UAFS_READ;
if (afs_rights & PRSFS_WRITE)
rights |= UAFS_WRITE;
if (afs_rights & PRSFS_INSERT)
rights |= UAFS_INSERT;
if (afs_rights & PRSFS_LOOKUP)
rights |= UAFS_LOOKUP;
if (afs_rights & PRSFS_DELETE)
rights |= UAFS_DELETE;
if (afs_rights & PRSFS_LOCK)
rights |= UAFS_LOCK;
if (afs_rights & PRSFS_ADMINISTER)
rights |= UAFS_ADMIN;
return rights;
}
/**
* List the contents of the represented directory.
*
* env the Java environment
* obj the current Java object
*
* return the directory handle
*/
JNIEXPORT jlong JNICALL Java_org_openafs_jafs_File_listNative
(JNIEnv *env, jobject obj, jobject buffer)
{
return 0;
}
/**
* Close the currently open directory using a provided directory handle.
*
* env the Java environment
* obj the current Java object
*
* return true if the directory closes without error
*/
JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_closeDir
(JNIEnv *env, jobject obj, jlong dp)
{
return JNI_TRUE;
}
/**
* Removes/deletes the represented file.
*
* env the Java environment
* obj the current Java object
*
* return true if the file is removed without error
*/
JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_rmfile
(JNIEnv *env, jobject obj)
{
char dirName[FILENAME_MAX];
int rc;
*dirName='\0';
getAbsolutePath(env, &obj, dirName);
if(*dirName == '\0') {
setError(env, &obj, EINVAL);
fprintf(stderr, "File::rmfile(): failed to get dirName\n");
return JNI_FALSE;
}
rc = uafs_unlink(dirName);
if(rc < 0) {
setError(env, &obj, errno);
fprintf(stderr, "File::rmfile(): uafs_unlink failed\n");
return JNI_FALSE;
}
setError(env, &obj, 0);
return JNI_TRUE;
}
/**
* Removes/deletes the represented directory.
*
* env the Java environment
* obj the current Java object
*
* return true if the directory is removed without error
*/
JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_rmdir
(JNIEnv *env, jobject obj)
{
char dirName[FILENAME_MAX];
int rc;
*dirName='\0';
getAbsolutePath(env, &obj, dirName);
if(*dirName == '\0') {
setError(env, &obj, -1);
fprintf(stderr, "File::rmdir(): failed to get dirName\n");
return JNI_FALSE;
}
rc = uafs_rmdir(dirName);
if(rc < 0) {
setError(env, &obj, errno);
fprintf(stderr, "File::rmdir(): uafs_unlink failed\n");
return JNI_FALSE;
}
setError(env, &obj, 0);
return JNI_TRUE;
}
/**
* Creates the directory named by this abstract pathname.
*
* env the Java environment
* obj the current Java object
*
* return true if and only if the directory was
* created; false otherwise
*/
JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_mkdir
(JNIEnv *env, jobject obj)
{
char dirName[FILENAME_MAX];
int rc;
*dirName='\0';
getAbsolutePath(env, &obj, dirName);
if(*dirName == '\0') {
setError(env, &obj, EINVAL);
fprintf(stderr, "File::mkdir(): failed to get dirName\n");
return JNI_FALSE;
}
rc = uafs_mkdir(dirName, 0755);
if(rc < 0) {
setError(env, &obj, errno);
fprintf(stderr, "File::mkdir(): uafs_mkdir failed\n");
return JNI_FALSE;
}
setError(env, &obj, 0);
return JNI_TRUE;
}
/**
* Renames the file denoted by this abstract pathname.
*
* env the Java environment
* obj the current Java object
* dest the new abstract pathname for the named file
*
* return true if and only if the renaming succeeded;
* false otherwise
*
* throws NullPointerException
* If parameter dest is null
*/
JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_renameTo
(JNIEnv *env, jobject obj, jobject newFile)
{
char thisDirName[FILENAME_MAX], newDirName[FILENAME_MAX];
int rc;
*thisDirName='\0';
getAbsolutePath(env, &obj, thisDirName);
if(*thisDirName == '\0') {
setError(env, &obj, -1);
fprintf(stderr, "File::renameTo(): failed to get dirName for this \n");
return JNI_FALSE;
}
*newDirName='\0';
getAbsolutePath(env, &newFile, newDirName);
if(*newDirName == '\0') {
setError(env, &obj, -1);
fprintf(stderr, "File::renameTo(): failed to get dirName for new \n");
return JNI_FALSE;
}
rc = uafs_rename(thisDirName, newDirName);
if(rc < 0) {
setError(env, &obj, errno);
fprintf(stderr, "File::renameTo(): uafs_rename failed\n");
return JNI_FALSE;
}
return JNI_TRUE;
}
/**
* Set all the necessary fields within the Java File class to indicate the
* does not exist.
*
* env the Java environment
* obj the current Java object
*/
void setFileNotExistsAttributes
(JNIEnv *env, jobject *obj)
{
jclass thisClass;
jfieldID fid;
thisClass = (*env) -> GetObjectClass(env, *obj);
if(thisClass == NULL) {
fprintf(stderr,
"File::setFileNotExistsAttributes(): GetObjectClass failed\n");
return;
}
fid = (*env)->GetFieldID(env, thisClass, "exists", "Z");
if (fid == 0) {
fprintf(stderr,
"File::setFileNotExistsAttributes(): GetFieldID (exists) failed\n");
return;
}
(*env)->SetBooleanField(env, *obj, fid, JNI_FALSE);
fid = (*env)->GetFieldID(env, thisClass, "isDirectory", "Z");
if (fid == 0) {
fprintf(stderr,
"File::setFileNotExistsAttributes(): GetFieldID (isDirectory) failed\n");
return;
}
(*env)->SetBooleanField(env, *obj, fid, JNI_FALSE);
fid = (*env)->GetFieldID(env, thisClass, "isFile", "Z");
if (fid == 0) {
fprintf(stderr,
"File::setFileNotExistsAttributes(): GetFieldID (isDirectory) failed\n");
return;
}
(*env)->SetBooleanField(env, *obj, fid, JNI_FALSE);
fid = (*env)->GetFieldID(env, thisClass, "lastModified", "J");
if (fid == 0) {
fprintf(stderr,
"File::setFileNotExistsAttributes(): GetFieldID (lastModified) failed\n");
return;
}
(*env)->SetLongField(env, *obj, fid, 0);
fid = (*env)->GetFieldID(env, thisClass, "length", "J");
if (fid == 0) {
fprintf(stderr,
"File::setFileNotExistsAttributes(): GetFieldID (length) failed\n");
return;
}
(*env)->SetLongField(env, *obj, fid, 0);
return;
}

View File

@ -1,152 +0,0 @@
/*
* Copyright (c) 2001-2002 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "Internal.h"
#include "org_openafs_jafs_FileInputStream.h"
#include <errno.h>
#include <fcntl.h>
#ifdef DMALLOC
#include "dmalloc.h"
#endif
/**
* Be carefull with the memory management:
*
* - For every GetStringUTFChars call the corresponding ReleaseStringUTFChars.
* - For every Get<type>ArrayElements call the corresponding
* Release<type>ArrayElements
* - For every malloc call the corresponding free.
*/
/*-------------------------------------------------------------------------*/
/**
* Opens an AFS file, with the specified name, for appending.
*
* env the Java environment
* obj the current Java object
* fileNameUTF name of file to be opened
*
* @return file descriptor
* @exception AFSFileException if an I/O or other file related error occurs.
*/
JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileInputStream_openReadOnly
(JNIEnv *env, jobject obj, jstring fileNameUTF)
{
int err;
int fd = -1; //file descriptor
fd = openAFSFile(env, fileNameUTF, O_RDONLY, 0, &err);
if (fd < 0) {
fprintf(stderr, "FileInputStream::openReadOnly(): err=%d\n", err);
throwAFSFileException( env, err, NULL );
}
return fd;
}
/**
* Reads up to 'length' bytes of data from this input stream
* into an array of bytes. This method blocks until some input is
* available.
*
* env the Java environment
* obj the current Java object
* jbytes the data to be written
* offset the start offset in the data
* length the number of bytes that are written
*
* @return the total number of bytes read into the buffer, or
* <code>-1</code> if there is no more data because the end of
* the file has been reached.
* @exception AFSFileException if an I/O or other file related error occurs.
*/
JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileInputStream_read
(JNIEnv *env, jobject obj, jbyteArray jbytes, jint offset, jint length)
{
int fd, bytesLen, bytesRead;
jclass thisClass;
jmethodID getFileDescriptorID;
jbyte *bytes;
jfieldID fid;
/* If we have to read 0 bytes just return */
if(length == 0) return 0;
thisClass = (*env)->GetObjectClass(env, obj);
fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I");
fd = (*env)->GetIntField(env, obj, fid);
if(fd < 0) {
fprintf(stderr, "FileInputStream::read(): invalid file state\n");
throwAFSFileException(env, 0, "Invalid file state");
return -1;
}
bytes = (*env) -> GetByteArrayElements(env, jbytes, 0);
bytesLen = (*env) -> GetArrayLength(env, jbytes);
bytesRead = uafs_read(fd, bytes, bytesLen);
if (errno != 0) throwAFSFileException(env, errno, NULL);
(*env) -> ReleaseByteArrayElements(env, jbytes, bytes, 0);
return (bytesRead > 0) ? bytesRead : -1;
}
/**
* Closes this file input stream and releases any system resources
* associated with this stream. This file input stream may no longer
* be used for writing bytes.
*
* env the Java environment
* obj the current Java object
*
* @exception AFSFileException if an I/O or other file related error occurs.
*/
JNIEXPORT void JNICALL Java_org_openafs_jafs_FileInputStream_close
(JNIEnv *env, jobject obj)
{
int fd, rc;
jclass thisClass;
jmethodID getFileDescriptorID;
jfieldID fid;
char *bytes;
thisClass = (*env)->GetObjectClass(env, obj);
fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I");
fd = (*env)->GetIntField(env, obj, fid);
if(fd < 0) {
fprintf(stderr, "FileInputStream::close(): invalid file state\n");
throwAFSFileException(env, 0, "Invalid file state");
return;
}
rc = uafs_close(fd);
if (rc != 0) {
throwAFSFileException(env, errno, NULL);
}
}

View File

@ -1,179 +0,0 @@
/*
* Copyright (c) 2001-2002 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <afsconfig.h>
#include <afs/param.h>
#include <errno.h>
#include "Internal.h"
#include "org_openafs_jafs_FileOutputStream.h"
#include <stdio.h>
#include <fcntl.h>
/*#include <afs/afs_usrops.h>*/
#ifdef DMALLOC
#include "dmalloc.h"
#endif
/**
* Be carefull with the memory management:
*
* - For every GetStringUTFChars call the corresponding ReleaseStringUTFChars.
* - For every Get<type>ArrayElements call the corresponding
* Release<type>ArrayElements
* - For every malloc call the corresponding free.
*/
/*-------------------------------------------------------------------------*/
/**
* Opens an AFS file, with the specified name, for appending.
*
* env the Java environment
* obj the current Java object
* fileNameUTF name of file to be opened
*
* @returns file descriptor
* @exception AFSFileException if an I/O or other file related error occurs.
*/
JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileOutputStream_openWrite
(JNIEnv *env, jobject obj, jstring fileNameUTF)
{
int err;
jint fd = -1; //file descriptor
fd = openAFSFile(env, fileNameUTF, O_CREAT | O_TRUNC, 0644, &err);
if (fd < 0) {
fprintf(stderr, "FileOutputStream::openWrite(): err=%d\n", err);
throwAFSFileException(env, err, NULL);
}
return fd;
}
/**
* Opens an AFS file, with the specified name, for writing.
*
* env the Java environment
* obj the current Java object
* fileNameUTF name of file to be opened
*
* @return file descriptor
* @exception AFSFileException if an I/O or other file related error occurs.
*/
JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileOutputStream_openAppend
(JNIEnv *env, jobject obj, jstring fileNameUTF)
{
int err;
jint fd = -1; //file descriptor
fd = openAFSFile(env, fileNameUTF, O_CREAT | O_APPEND, 0644, &err);
if (fd < 0) {
fprintf(stderr, "FileOutputStream::openAppend(): err=%d\n", err);
throwAFSFileException(env, err, NULL);
}
return fd;
}
/**
* Writes 'lenght' bytes from the specified byte array starting at offset
* 'offset' to this file output stream.
*
* env the Java environment
* obj the current Java object
* jbytes the data to be written
* offset the start offset in the data
* length the number of bytes that are written
*
* @exception AFSFileException if an I/O or other file related error occurs.
*/
JNIEXPORT void JNICALL Java_org_openafs_jafs_FileOutputStream_write
(JNIEnv *env, jobject obj, jbyteArray jbytes, jint offset, jint length)
{
int fd, written, toWrite;
jint twritten;
jclass thisClass;
jmethodID getFileDescriptorID;
char *bytes;
jfieldID fid;
thisClass = (*env)->GetObjectClass(env, obj);
fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I");
fd = (*env)->GetIntField(env, obj, fid);
if(fd < 0) {
fprintf(stderr, "FileOutputStream::write(): failed to get file "
"descriptor\n");
throwAFSFileException(env, 0, "Failed to get file descriptor!");
}
bytes = malloc(length);
if(bytes == NULL) {
fprintf(stderr, "FileOutputStream::write(): malloc failed of %d bytes\n",
length);
throwAFSFileException(env, 0, "Failed to allocate memory!");
}
(*env) -> GetByteArrayRegion(env, jbytes, offset, length, bytes);
toWrite = length;
twritten = 0;
while(toWrite>0) {
written = uafs_write(fd, bytes, length);
twritten += written;
if(written<0) {
free(bytes);
throwAFSFileException(env, errno, NULL);
}
toWrite -= written;
}
free(bytes);
}
/**
* Closes this file output stream and releases any system resources
* associated with this stream. This file output stream may no longer
* be used for writing bytes.
*
* env the Java environment
* obj the current Java object
*
* @exception AFSFileException if an I/O or other file related error occurs.
*/
JNIEXPORT void JNICALL Java_org_openafs_jafs_FileOutputStream_close
(JNIEnv *env, jobject obj)
{
int fd, rc;
jclass thisClass;
jmethodID getFileDescriptorID;
char *bytes;
jfieldID fid;
thisClass = (*env)->GetObjectClass(env, obj);
fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I");
fd = (*env)->GetIntField(env, obj, fid);
if(fd < 0) {
fprintf(stderr, "FileOutputStream::close(): failed to get file descriptor\n");
throwAFSFileException(env, 0, "Failed to get file descriptor!");
}
rc = uafs_close(fd);
if (rc != 0) {
throwAFSFileException(env, rc, NULL);
}
}

View File

@ -1,49 +0,0 @@
#include <jni.h>
#include "GetNativeString.h"
char* GetNativeString(JNIEnv *env, jstring jstr){
jbyteArray bytes = 0;
jthrowable exc;
char *result = 0;
if ((*env)->EnsureLocalCapacity(env, 2) < 0) {
return 0; /* out of memory error */
}
jclass stringClass=(*env)->FindClass(env,"java/lang/String");
if(!stringClass){
return 0;
}
jmethodID MID_String_getBytes = (*env)->GetMethodID(env,stringClass,"getBytes","()[B");
if(!MID_String_getBytes){
return 0;
}
bytes = (*env)->CallObjectMethod(env, jstr,
MID_String_getBytes);
exc = (*env)->ExceptionOccurred(env);
if (!exc) {
jint len = (*env)->GetArrayLength(env, bytes);
result = malloc(len + 1);
if (result == 0) {
/*JNU_ThrowByName(env, "java/lang/OutOfMemoryError",
0);*/
(*env)->DeleteLocalRef(env, bytes);
return 0;
}
(*env)->GetByteArrayRegion(env, bytes, 0, len,
(jbyte *)result);
result[len] = 0; /* NULL-terminate */
} else {
(*env)->DeleteLocalRef(env, exc);
}
(*env)->DeleteLocalRef(env, bytes);
return result;
}
jstring GetJavaString(JNIEnv *env, char*);

View File

@ -1,6 +0,0 @@
#include <jni.h>
#include <stdlib.h>
char* GetNativeString(JNIEnv *env, jstring jstr);
jstring GetJavaString(JNIEnv *env, char*);

View File

@ -1,829 +0,0 @@
/*
* Copyright (c) 2001-2002 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "Internal.h"
#include "org_openafs_jafs_Group.h"
#include <afs_vosAdmin.h>
#include <stdio.h>
#include <afs_ptsAdmin.h>
#include <afs_AdminPtsErrors.h>
#include <afs_AdminClientErrors.h>
#include <afs_AdminCommonErrors.h>
#include <pterror.h>
///// definitions in Internal.c ///////////////
extern jclass userCls;
//extern jfieldID user_cellHandleField;
extern jfieldID user_nameField;
extern jfieldID user_cachedInfoField;
extern jclass groupCls;
extern jfieldID group_nameField;
extern jfieldID group_nameUidField;
extern jfieldID group_ownerUidField;
extern jfieldID group_creatorUidField;
extern jfieldID group_listStatusField;
extern jfieldID group_listGroupsOwnedField;
extern jfieldID group_listMembershipField;
extern jfieldID group_listAddField;
extern jfieldID group_listDeleteField;
extern jfieldID group_membershipCountField;
extern jfieldID group_ownerField;
extern jfieldID group_creatorField;
//////////////////////////////////////////////////////
/**
* Creates the PTS entry for a new group. Pass in 0 for the uid if PTS is to
* automatically assign the group id.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the group belongs
* jgroupName the name of the group to create
* jownerName the owner of this group
* gid the group id to assign to the group (0 to have one
* automatically assigned)
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Group_create
(JNIEnv *env, jclass cls, jlong cellHandle, jstring jgroupName,
jstring jownerName, jint gid )
{
afs_status_t ast;
// convert java strings
const char *groupName;
const char *ownerName;
if( jgroupName != NULL ) {
groupName = (*env)->GetStringUTFChars(env, jgroupName, 0);
if( !groupName ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
groupName = NULL;
}
if( jownerName != NULL ) {
ownerName = (*env)->GetStringUTFChars(env, jownerName, 0);
if( !ownerName ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
ownerName = NULL;
}
// make sure the name is within the allowed bounds
if( groupName != NULL && strlen( groupName ) > PTS_MAX_NAME_LEN ) {
// release converted java strings
if( groupName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
}
if( ownerName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jownerName, ownerName);
}
throwAFSException( env, ADMPTSGROUPNAMETOOLONG );
return;
}
if( !pts_GroupCreate( (void *) cellHandle, groupName, ownerName,
(int *) &gid, &ast ) ) {
// release converted java strings
if( groupName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
}
if( ownerName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jownerName, ownerName);
}
throwAFSException( env, ast );
return;
}
// release converted java strings
if( groupName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
}
if( ownerName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jownerName, ownerName);
}
}
/**
* Deletes the PTS entry for a group. Deletes this group from the
* membership list of the users that belonged to it, but does not delete
* the groups owned by this group.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the group belongs
* jgroupName the name of the group to delete
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Group_delete
(JNIEnv *env, jclass cls, jlong cellHandle, jstring jgroupName )
{
afs_status_t ast;
// convert java strings
const char *groupName;
if( jgroupName != NULL ) {
groupName = (*env)->GetStringUTFChars(env, jgroupName, 0);
if( !groupName ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
groupName = NULL;
}
if( !pts_GroupDelete( (void *) cellHandle, groupName, &ast ) ) {
if( groupName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
}
throwAFSException( env, ast );
return;
}
// release converted java strings
if( groupName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
}
}
/**
* Retrieve the information for the specified group and populate the
* given object
*
* env the Java environment
* cellHandle the handle of the cell to which the user belongs
* name the name of the group for which to get the info
* group the Group object to populate with the info
*/
void getGroupInfoChar
( JNIEnv *env, void *cellHandle, const char *name, jobject group )
{
jstring jowner;
jstring jcreator;
pts_GroupEntry_t entry;
afs_status_t ast;
// get the field ids if you haven't already
if( groupCls == 0 ) {
internal_getGroupClass( env, group );
}
if ( !pts_GroupGet( cellHandle, name, &entry, &ast ) ) {
throwAFSException( env, ast );
return;
}
// set the fields
(*env)->SetIntField(env, group, group_nameUidField, entry.nameUid);
(*env)->SetIntField(env, group, group_ownerUidField, entry.ownerUid);
(*env)->SetIntField(env, group, group_creatorUidField, entry.creatorUid);
(*env)->SetIntField(env, group, group_membershipCountField,
entry.membershipCount);
if( entry.listStatus == PTS_GROUP_OWNER_ACCESS ) {
(*env)->SetIntField(env, group, group_listStatusField,
org_openafs_jafs_Group_GROUP_OWNER_ACCESS);
} else if( entry.listStatus == PTS_GROUP_ACCESS ) {
(*env)->SetIntField(env, group, group_listStatusField,
org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
} else {
(*env)->SetIntField(env, group, group_listStatusField,
org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
}
if( entry.listGroupsOwned == PTS_GROUP_OWNER_ACCESS ) {
(*env)->SetIntField(env, group, group_listGroupsOwnedField,
org_openafs_jafs_Group_GROUP_OWNER_ACCESS);
} else if( entry.listGroupsOwned == PTS_GROUP_ACCESS ) {
(*env)->SetIntField(env, group, group_listGroupsOwnedField,
org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
} else {
(*env)->SetIntField(env, group, group_listGroupsOwnedField,
org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
}
if( entry.listMembership == PTS_GROUP_OWNER_ACCESS ) {
(*env)->SetIntField(env, group, group_listMembershipField,
org_openafs_jafs_Group_GROUP_OWNER_ACCESS);
} else if( entry.listMembership == PTS_GROUP_ACCESS ) {
(*env)->SetIntField(env, group, group_listMembershipField,
org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
} else {
(*env)->SetIntField(env, group, group_listMembershipField,
org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
}
if( entry.listAdd == PTS_GROUP_OWNER_ACCESS ) {
(*env)->SetIntField(env, group, group_listAddField,
org_openafs_jafs_Group_GROUP_OWNER_ACCESS);
} else if( entry.listAdd == PTS_GROUP_ACCESS ) {
(*env)->SetIntField(env, group, group_listAddField,
org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
} else {
(*env)->SetIntField(env, group, group_listAddField,
org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
}
if( entry.listDelete == PTS_GROUP_OWNER_ACCESS ) {
(*env)->SetIntField(env, group, group_listDeleteField,
org_openafs_jafs_Group_GROUP_OWNER_ACCESS);
} else if( entry.listDelete == PTS_GROUP_ACCESS ) {
(*env)->SetIntField(env, group, group_listDeleteField,
org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
} else {
(*env)->SetIntField(env, group, group_listDeleteField,
org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
}
jowner = (*env)->NewStringUTF(env, entry.owner);
jcreator = (*env)->NewStringUTF(env, entry.creator);
(*env)->SetObjectField(env, group, group_ownerField, jowner);
(*env)->SetObjectField(env, group, group_creatorField, jcreator);
}
/**
* Fills in the information fields of the provided Group.
* Fills in values based on the current PTS information of the group.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the group belongs
* name the name of the group for which to get the information
* group the Group object in which to fill in the
* information
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Group_getGroupInfo
(JNIEnv *env, jclass cls, jlong cellHandle, jstring jname, jobject group)
{
const char *name;
if( jname != NULL ) {
name = (*env)->GetStringUTFChars(env, jname, 0);
if( !name ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
name = NULL;
}
getGroupInfoChar( env, (void *)cellHandle, name, group );
// get class fields if need be
if( groupCls == 0 ) {
internal_getGroupClass( env, group );
}
// set name in case blank object
(*env)->SetObjectField(env, group, group_nameField, jname);
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
}
/**
* Sets the information values of this AFS group to be the parameter values.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the user belongs
* name the name of the user for which to set the information
* theGroup the group object containing the desired information
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Group_setGroupInfo
(JNIEnv *env, jclass cls, jlong cellHandle, jstring jname, jobject group)
{
const char *name;
pts_GroupUpdateEntry_t ptsEntry;
afs_status_t ast;
jint jlistStatus;
jint jlistGroupsOwned;
jint jlistMembership;
jint jlistAdd;
jint jlistDelete;
// get the field ids if you haven't already
if( groupCls == 0 ) {
internal_getGroupClass( env, group );
}
jlistStatus = (*env)->GetIntField(env, group, group_listStatusField);
jlistGroupsOwned = (*env)->GetIntField(env, group,
group_listGroupsOwnedField);
jlistMembership = (*env)->GetIntField(env, group, group_listMembershipField);
jlistAdd = (*env)->GetIntField(env, group, group_listAddField);
jlistDelete = (*env)->GetIntField(env, group, group_listDeleteField);
if( jname != NULL ) {
name = (*env)->GetStringUTFChars(env, jname, 0);
if( !name ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
name = NULL;
}
if( jlistStatus == org_openafs_jafs_Group_GROUP_OWNER_ACCESS ) {
ptsEntry.listStatus = PTS_GROUP_OWNER_ACCESS;
} else if( jlistStatus == org_openafs_jafs_Group_GROUP_GROUP_ACCESS ) {
ptsEntry.listStatus = PTS_GROUP_ACCESS;
} else {
ptsEntry.listStatus = PTS_GROUP_ANYUSER_ACCESS;
}
if( jlistGroupsOwned == org_openafs_jafs_Group_GROUP_OWNER_ACCESS ) {
ptsEntry.listGroupsOwned = PTS_GROUP_OWNER_ACCESS;
} else if( jlistGroupsOwned ==
org_openafs_jafs_Group_GROUP_GROUP_ACCESS ) {
ptsEntry.listGroupsOwned = PTS_GROUP_ACCESS;
} else {
ptsEntry.listGroupsOwned = PTS_GROUP_ANYUSER_ACCESS;
}
if( jlistMembership == org_openafs_jafs_Group_GROUP_OWNER_ACCESS ) {
ptsEntry.listMembership = PTS_GROUP_OWNER_ACCESS;
} else if( jlistMembership ==
org_openafs_jafs_Group_GROUP_GROUP_ACCESS ) {
ptsEntry.listMembership = PTS_GROUP_ACCESS;
} else {
ptsEntry.listMembership = PTS_GROUP_ANYUSER_ACCESS;
}
if( jlistAdd == org_openafs_jafs_Group_GROUP_OWNER_ACCESS ) {
ptsEntry.listAdd = PTS_GROUP_OWNER_ACCESS;
} else if( jlistAdd == org_openafs_jafs_Group_GROUP_GROUP_ACCESS ) {
ptsEntry.listAdd = PTS_GROUP_ACCESS;
} else {
ptsEntry.listAdd = PTS_GROUP_ANYUSER_ACCESS;
}
if( jlistDelete == org_openafs_jafs_Group_GROUP_OWNER_ACCESS ) {
ptsEntry.listDelete = PTS_GROUP_OWNER_ACCESS;
} else if( jlistDelete == org_openafs_jafs_Group_GROUP_GROUP_ACCESS ) {
ptsEntry.listDelete = PTS_GROUP_ACCESS;
} else {
ptsEntry.listDelete = PTS_GROUP_ANYUSER_ACCESS;
}
if( !pts_GroupModify( (void *) cellHandle, name, &ptsEntry, &ast ) ) {
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
throwAFSException( env, ast );
return;
}
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
}
/**
* Begin the process of getting the users that belong to the group. Returns
* an iteration ID to be used by subsequent calls to
* getGroupMembersNext and getGroupMembersDone.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the group belongs
* jname the name of the group for which to get the members
* returns an iteration ID
*/
JNIEXPORT jlong JNICALL
Java_org_openafs_jafs_Group_getGroupMembersBegin
(JNIEnv *env, jclass cls, jlong cellHandle, jstring jname)
{
const char *name;
afs_status_t ast;
void *iterationId;
if( jname != NULL ) {
name = (*env)->GetStringUTFChars(env, jname, 0);
if( !name ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
name = NULL;
}
if( !pts_GroupMemberListBegin( (void *) cellHandle, name, &iterationId,
&ast ) ) {
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
throwAFSException( env, ast );
return;
}
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
return (jlong) iterationId;
}
/**
* Returns the next members that belongs to the group. Returns
* null if there are no more members.
*
* env the Java environment
* cls the current Java class
* iterationId the iteration ID of this iteration
* returns the name of the next member
*/
JNIEXPORT jstring JNICALL
Java_org_openafs_jafs_Group_getGroupMembersNextString
(JNIEnv *env, jclass cls, jlong iterationId)
{
afs_status_t ast;
char *userName = malloc( sizeof(char)*PTS_MAX_NAME_LEN);
jstring juser;
if( !userName ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
if( !pts_GroupMemberListNext( (void *) iterationId, userName, &ast ) ) {
free( userName );
if( ast == ADMITERATORDONE ) {
return NULL;
} else {
throwAFSException( env, ast );
return;
}
}
juser = (*env)->NewStringUTF(env, userName);
free( userName );
return juser;
}
/**
* Fills the next user object belonging to that group. Returns 0 if there
* are no more users, != 0 otherwise.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the users belong
* iterationId the iteration ID of this iteration
* juserObject a User object to be populated with the values of the
* next user
* returns 0 if there are no more users, != 0 otherwise
*/
JNIEXPORT jint JNICALL
Java_org_openafs_jafs_Group_getGroupMembersNext
(JNIEnv *env, jclass cls, jlong cellHandle, jlong iterationId,
jobject juserObject)
{
afs_status_t ast;
char *userName;
jstring juser;
userName = malloc( sizeof(char)*PTS_MAX_NAME_LEN);
if( !userName ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
if( !pts_GroupMemberListNext( (void *) iterationId, userName, &ast ) ) {
free( userName );
if( ast == ADMITERATORDONE ) {
return 0;
} else {
throwAFSException( env, ast );
return 0;
}
}
juser = (*env)->NewStringUTF(env, userName);
if( userCls == 0 ) {
internal_getUserClass( env, juserObject );
}
(*env)->SetObjectField(env, juserObject, user_nameField, juser);
getUserInfoChar( env, (void *) cellHandle, userName, juserObject );
(*env)->SetBooleanField( env, juserObject, user_cachedInfoField, TRUE );
free( userName );
return 1;
}
/**
* Signals that the iteration is complete and will not be accessed anymore.
*
* env the Java environment
* cls the current Java class
* iterationId the iteration ID of this iteration
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Group_getGroupMembersDone
(JNIEnv *env, jclass cls, jlong iterationId)
{
afs_status_t ast;
if( !pts_GroupMemberListDone( (void *) iterationId, &ast ) ) {
throwAFSException( env, ast );
return;
}
}
/**
* Adds a user to the specified group.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the group belongs
* jgroupName the name of the group to which to add a member
* juserName the name of the user to add
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Group_addMember
(JNIEnv *env, jclass cls, jlong cellHandle, jstring jgroupName,
jstring juserName )
{
afs_status_t ast;
const char *groupName;
const char *userName;
if( jgroupName != NULL ) {
groupName = (*env)->GetStringUTFChars(env, jgroupName, 0);
if( !groupName ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
groupName = NULL;
}
if( juserName != NULL ) {
userName = (*env)->GetStringUTFChars(env, juserName, 0);
if( !userName ) {
if( groupName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
}
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
userName = NULL;
}
if( !pts_GroupMemberAdd( (void *) cellHandle, userName, groupName, &ast ) ) {
if( groupName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
}
if( userName != NULL ) {
(*env)->ReleaseStringUTFChars(env, juserName, userName);
}
throwAFSException( env, ast );
return;
}
if( groupName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
}
if( userName != NULL ) {
(*env)->ReleaseStringUTFChars(env, juserName, userName);
}
}
/**
* Removes a user from the specified group.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the group belongs
* jgroupName the name of the group from which to remove a
* member
* juserName the name of the user to remove
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Group_removeMember
(JNIEnv *env, jclass cls, jlong cellHandle, jstring jgroupName,
jstring juserName)
{
afs_status_t ast;
const char *groupName;
const char *userName;
if( jgroupName != NULL ) {
groupName = (*env)->GetStringUTFChars(env, jgroupName, 0);
if( !groupName ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
groupName = NULL;
}
if( juserName != NULL ) {
userName = (*env)->GetStringUTFChars(env, juserName, 0);
if( !userName ) {
if( groupName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
}
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
userName = NULL;
}
if( !pts_GroupMemberRemove( (void *)cellHandle, userName,
groupName, &ast ) ) {
if( groupName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
}
if( userName != NULL ) {
(*env)->ReleaseStringUTFChars(env, juserName, userName);
}
throwAFSException( env, ast );
return;
}
if( groupName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
}
if( userName != NULL ) {
(*env)->ReleaseStringUTFChars(env, juserName, userName);
}
}
/**
* Change the owner of the specified group.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the group belongs
* jgroupName the name of the group of which to change the
* owner
* jownerName the name of the new owner
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Group_changeOwner
(JNIEnv *env, jclass cls, jlong cellHandle, jstring jgroupName,
jstring jownerName )
{
afs_status_t ast;
const char *groupName;
const char *ownerName;
if( jgroupName != NULL ) {
groupName = (*env)->GetStringUTFChars(env, jgroupName, 0);
if( !groupName ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
groupName = NULL;
}
if( jownerName != NULL ) {
ownerName = (*env)->GetStringUTFChars(env, jownerName, 0);
if( !ownerName ) {
if( groupName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
}
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
ownerName = NULL;
}
if( !pts_GroupOwnerChange( (void *)cellHandle, groupName,
ownerName, &ast ) ) {
if( groupName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
}
if( ownerName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jownerName, ownerName);
}
throwAFSException( env, ast );
return;
}
if( groupName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
}
if( ownerName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jownerName, ownerName);
}
}
/**
* Change the name of the specified group.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the group belongs
* joldGroupName the old name of the group
* jnewGroupName the new name for the group
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Group_rename
(JNIEnv *env, jclass cls, jlong cellHandle, jstring jgroupOldName,
jstring jgroupNewName )
{
afs_status_t ast;
const char *groupOldName;
const char *groupNewName;
if( jgroupOldName != NULL ) {
groupOldName = (*env)->GetStringUTFChars(env, jgroupOldName, 0);
if( !groupOldName ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
groupOldName = NULL;
}
if( jgroupNewName != NULL ) {
groupNewName = (*env)->GetStringUTFChars(env, jgroupNewName, 0);
if( !groupNewName ) {
if( groupOldName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupOldName, groupOldName);
}
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
groupNewName = NULL;
}
if( !pts_GroupRename( (void *)cellHandle, groupOldName,
groupNewName, &ast ) ) {
if( groupOldName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupOldName, groupOldName);
}
if( groupNewName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupNewName, groupNewName);
}
throwAFSException( env, ast );
return;
}
if( groupOldName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupOldName, groupOldName);
}
if( groupNewName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jgroupNewName, groupNewName);
}
}
// reclaim global memory used by this portion
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Group_reclaimGroupMemory (JNIEnv *env, jclass cls)
{
if( groupCls ) {
(*env)->DeleteGlobalRef(env, groupCls);
groupCls = 0;
}
}

View File

@ -1,895 +0,0 @@
/*
* Copyright (c) 2001-2002 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "Internal.h"
#include <errno.h>
#ifdef DMALLOC
#include "dmalloc.h"
#endif
#ifndef LIBJUAFS
// user class and fields //
jclass userCls = 0;
jfieldID user_ptsField = 0;
jfieldID user_kasField = 0;
jfieldID user_nameField = 0;
//jfieldID user_cellHandleField = 0;
jfieldID user_cachedInfoField = 0;
//pts fields
jfieldID user_nameUidField = 0;
jfieldID user_ownerUidField = 0;
jfieldID user_creatorUidField = 0;
jfieldID user_listStatusField = 0;
jfieldID user_listGroupsOwnedField = 0;
jfieldID user_listMembershipField = 0;
jfieldID user_groupCreationQuotaField = 0;
jfieldID user_groupMembershipCountField = 0;
jfieldID user_ownerField = 0;
jfieldID user_creatorField = 0;
// kas fields
jfieldID user_adminSettingField = 0;
jfieldID user_tgsSettingField = 0;
jfieldID user_encSettingField = 0;
jfieldID user_cpwSettingField = 0;
jfieldID user_rpwSettingField = 0;
jfieldID user_userExpirationField = 0;
jfieldID user_lastModTimeField = 0;
jfieldID user_lastModNameField = 0;
jfieldID user_lastChangePasswordTimeField = 0;
jfieldID user_maxTicketLifetimeField = 0;
jfieldID user_keyVersionField = 0;
jfieldID user_encryptionKeyField = 0;
jfieldID user_keyCheckSumField = 0;
jfieldID user_daysToPasswordExpireField = 0;
jfieldID user_failLoginCountField = 0;
jfieldID user_lockTimeField = 0;
jfieldID user_lockedUntilField = 0;
// group class and fields //
jclass groupCls = 0;
jfieldID group_nameField = 0;
//jfieldID group_cellHandleField = 0;
jfieldID group_cachedInfoField = 0;
jfieldID group_nameUidField = 0;
jfieldID group_ownerUidField = 0;
jfieldID group_creatorUidField = 0;
jfieldID group_listStatusField = 0;
jfieldID group_listGroupsOwnedField = 0;
jfieldID group_listMembershipField = 0;
jfieldID group_listAddField = 0;
jfieldID group_listDeleteField = 0;
jfieldID group_membershipCountField = 0;
jfieldID group_ownerField = 0;
jfieldID group_creatorField = 0;
// server class and fields //
jclass serverCls = 0;
jfieldID server_nameField = 0;
//jfieldID server_cellHandleField = 0;
jfieldID server_cachedInfoField = 0;
jfieldID server_databaseField = 0;
jfieldID server_fileServerField = 0;
jfieldID server_badDatabaseField = 0;
jfieldID server_badFileServerField = 0;
jfieldID server_IPAddressField = 0;
// executable time class and fields //
jclass exectimeCls = 0;
jfieldID exectime_HourField = 0;
jfieldID exectime_MinField = 0;
jfieldID exectime_SecField = 0;
jfieldID exectime_DayField = 0;
jfieldID exectime_NowField = 0;
jfieldID exectime_NeverField = 0;
// partition class and fields //
jclass partitionCls = 0;
jfieldID partition_nameField = 0;
jfieldID partition_cachedInfoField = 0;
jfieldID partition_idField = 0;
jfieldID partition_deviceNameField = 0;
jfieldID partition_lockFileDescriptorField = 0;
jfieldID partition_totalSpaceField = 0;
jfieldID partition_totalFreeSpaceField = 0;
// volume class and fields //
jclass volumeCls = 0;
jfieldID volume_nameField = 0;
jfieldID volume_cachedInfoField = 0;
jfieldID volume_idField = 0;
jfieldID volume_readWriteIdField = 0;
jfieldID volume_readOnlyIdField = 0;
jfieldID volume_backupIdField = 0;
jfieldID volume_creationDateField = 0;
jfieldID volume_lastAccessDateField = 0;
jfieldID volume_lastUpdateDateField = 0;
jfieldID volume_lastBackupDateField = 0;
jfieldID volume_copyCreationDateField = 0;
jfieldID volume_accessesSinceMidnightField = 0;
jfieldID volume_fileCountField = 0;
jfieldID volume_maxQuotaField = 0;
jfieldID volume_currentSizeField = 0;
jfieldID volume_statusField = 0;
jfieldID volume_dispositionField = 0;
jfieldID volume_typeField = 0;
// key class and fields //
jclass keyCls = 0;
jfieldID key_cachedInfoField = 0;
jfieldID key_versionField = 0;
jfieldID key_encryptionKeyField = 0;
jfieldID key_lastModDateField = 0;
jfieldID key_lastModMsField = 0;
jfieldID key_checkSumField = 0;
// process class and fields //
jclass processCls = 0;
jfieldID process_cachedInfoField = 0;
jfieldID process_nameField = 0;
//jfieldID process_serverHandleField = 0;
jfieldID process_typeField = 0;
jfieldID process_stateField = 0;
jfieldID process_goalField = 0;
jfieldID process_startTimeField = 0;
jfieldID process_numberStartsField = 0;
jfieldID process_exitTimeField = 0;
jfieldID process_exitErrorTimeField = 0;
jfieldID process_errorCodeField = 0;
jfieldID process_errorSignalField = 0;
jfieldID process_stateOkField = 0;
jfieldID process_stateTooManyErrorsField = 0;
jfieldID process_stateBadFileAccessField = 0;
#endif /* !LIBJUAFS */
/**
* Throws an exception up to the Java layer, using ast as the error code
* for the exception. See Exceptions.h for the available
* exceptions.
*/
void throwException
(JNIEnv *env, jclass *excCls, char *excClsName, jmethodID *initID, int code)
{
jobject exc;
if( *excCls == 0 ) {
*excCls = (*env)->NewGlobalRef(env, (*env)->FindClass(env, excClsName ));
if( !*excCls ) {
fprintf(stderr, "ERROR: Internal::throwException()\n Cannot find class: %s\n", excClsName);
return;
}
*initID = (*env)->GetMethodID( env, *excCls, "<init>", "(I)V" );
if( !*initID ) {
fprintf(stderr, "ERROR: Internal::throwException()\n Cannot find construction method: %s\n",
excClsName);
return;
}
}
exc = (*env)->NewObject( env, *excCls, *initID, code );
if( !exc ) {
fprintf(stderr, "ERROR: Internal::throwException()\n Cannot construct new exception object: %s\n",
excClsName);
return;
}
(*env)->Throw(env, exc);
}
/**
* Throws an exception up to the Java layer, constructing it with msg.
* This function should only be used when a valid AFS error number/code
* is unavailable and it is necessary to interrupt the Java call with an
* exception. See Exceptions.h for the available exceptions.
*/
void throwMessageException( JNIEnv *env, char *msg )
{
jclass excCls = (*env)->FindClass(env, afsExceptionName);
if(excCls == 0) {
fprintf(stderr, "ERROR: Internal::throwMessageException()\n Cannot find class: %s\n", afsExceptionName);
return;
}
(*env)->ThrowNew(env, excCls, msg);
}
/**
* Throws an exception up to the Java layer, using ast as the error code
* for the exception. See Exceptions.h for the available
* exceptions.
*/
void throwAFSException( JNIEnv *env, int code )
{
jclass afsExceptionCls;
jmethodID afsExceptionInit;
jthrowable exc;
afsExceptionCls = (*env)->FindClass(env, afsExceptionName);
if( !afsExceptionCls ) {
fprintf(stderr, "ERROR: Internal::throwAFSException()\n Cannot find class: %s\n", afsExceptionName);
return;
}
afsExceptionInit = (*env)->GetMethodID( env, afsExceptionCls,
"<init>", "(I)V" );
if( !afsExceptionInit ) {
fprintf(stderr, "ERROR: Internal::throwAFSException()\n Cannot find construction method: %s\n",
afsExceptionName);
return;
}
exc = (*env)->NewObject( env, afsExceptionCls, afsExceptionInit, code );
if( !exc ) {
fprintf(stderr, "ERROR: Internal::throwAFSException()\n Cannot construct new exception object: %s\n",
afsExceptionName);
return;
}
(*env)->Throw(env, exc);
}
/**
* Throws an exception up to the Java layer, using ast as the error code
* for the exception. See Exceptions.h for the available
* exceptions.
*/
void throwAFSFileException( JNIEnv *env, int code, char *msg )
{
jclass afsFileExceptionCls;
jmethodID afsFileExceptionInit;
jthrowable exc;
afsFileExceptionCls = (*env)->FindClass(env, afsFileExceptionName);
if( !afsFileExceptionCls ) {
fprintf(stderr, "ERROR: Internal::throwAFSFileException()\n Cannot find class: %s\n", afsFileExceptionName);
return;
}
afsFileExceptionInit = (*env)->GetMethodID( env, afsFileExceptionCls,
"<init>", "(Ljava/lang/String;I)V" );
if( !afsFileExceptionInit ) {
fprintf(stderr, "ERROR: Internal::throwAFSFileException()\n Cannot find construction method: %s\n",
afsFileExceptionName);
return;
}
exc = (*env)->NewObject( env, afsFileExceptionCls,
afsFileExceptionInit, msg, code );
if( !exc ) {
fprintf(stderr, "ERROR: Internal::throwAFSFileException()\n Cannot construct new exception object: %s\n",
afsFileExceptionName);
return;
}
(*env)->Throw(env, exc);
}
/**
* Throws an exception up to the Java layer, using ast as the error code
* for the exception. See Exceptions.h for the available
* exceptions.
*/
void throwAFSSecurityException( JNIEnv *env, int code )
{
jclass afsSecurityExceptionCls;
jmethodID afsSecurityExceptionInit;
jthrowable exc;
afsSecurityExceptionCls = (*env)->FindClass(env, afsSecurityExceptionName);
if( !afsSecurityExceptionCls ) {
fprintf(stderr, "ERROR: Internal::throwAFSSecurityException()\n Cannot find class: %s\n", afsSecurityExceptionName);
return;
}
afsSecurityExceptionInit = (*env)->GetMethodID( env, afsSecurityExceptionCls,
"<init>", "(I)V" );
if( !afsSecurityExceptionInit ) {
fprintf(stderr, "ERROR: Internal::throwAFSSecurityException()\n Cannot find construction method: %s\n",
afsSecurityExceptionName);
return;
}
exc = (*env)->NewObject( env, afsSecurityExceptionCls,
afsSecurityExceptionInit, code );
if( !exc ) {
fprintf(stderr, "ERROR: Internal::throwAFSSecurityException()\n Cannot construct new exception object: %s\n",
afsSecurityExceptionName);
return;
}
(*env)->Throw(env, exc);
}
int setError(JNIEnv *env, jobject *obj, int code)
{
jfieldID fid;
jclass cls = (*env)->GetObjectClass(env, *obj);
if (cls != NULL) {
fid = (*env)->GetFieldID(env, cls, "errno", "I");
if (fid)
{
(*env)->SetIntField(env, *obj, fid, code);
return 0;
}
}
return -1;
}
#ifdef LIBJUAFS
/**
* Opens an AFS file, with the specified name, using the specified flags
* with in the specified mode (permission mode).
*
* env the Java environment
* fileNameUTF name of file to be opened
* flags open mode: O_CREAT, O_APPEND
* mode UNIX permission mode mask
* err error variable
*
* @returns file descriptor
*/
int openAFSFile
(JNIEnv *env, jstring fileNameUTF, int flags, int mode, int *err)
{
char *fileName;
int fd = -1;
*err = 0;
errno = 0;
fileName=(char*) (*env)->GetStringUTFChars(env, fileNameUTF, 0);
if(fileName == NULL) {
fprintf(stderr, "Internal::openAFSFile(): failed to get fileName\n");
*err = -1;
return fd;
}
fd = uafs_open(fileName, flags, mode);
*err = errno;
if (errno != 0) {
fprintf(stderr, "Internal::openAFSFile(): errno=%d\n", errno);
fprintf(stderr, "Internal::openAFSFile(): fd=%d\n", fd);
}
(*env)->ReleaseStringUTFChars(env, fileNameUTF, fileName);
if (fd < 0) {
fprintf(stderr, "Internal::openAFSFile(): failed to open fileName\n");
fprintf(stderr, "Internal::openAFSFile(): fd=%d\n", fd);
return -1;
}
return fd;
}
int readCacheParms(char *afsMountPoint, char *afsConfDir, char *afsCacheDir,
int *cacheBlocks, int *cacheFiles, int *cacheStatEntries,
int *dCacheSize, int *vCacheSize, int *chunkSize,
int *closeSynch, int *debug, int *nDaemons, int *cacheFlags,
char *logFile)
{
FILE *f;
char line[100];
char *p;
int len1, len2, n;
char cacheConfigFile[100];
p = (char *)getenv("LIBJAFS_CACHE_CONFIG");
if (p) {
strcpy(cacheConfigFile, p);
} else {
strcpy(cacheConfigFile, "/usr/afswsp/etc/CacheConfig");
}
f = fopen(cacheConfigFile, "r");
if (!f) {
fprintf(stderr, "Could not open cache config file: %s\n",
cacheConfigFile);
return -1;
}
while (1) {
fgets(line, 100, f);
if (feof(f)) break;
p = (char *)strchr(line, '\n');
if (p) *p = '\0';
if (strncmp(line, "#", 1) == 0) continue; /* comment */
p = (char *)strchr(line, ' ');
if (!p) continue;
len1 = p - line;
p++; len2 = strlen(p);
if (strncmp(line, "MountPoint", len1) == 0)
strcpy(afsMountPoint, p);
else if (strncmp(line, "ConfDir", len1) == 0)
strcpy(afsConfDir, p);
else if (strncmp(line, "CacheDir", len1) == 0)
strcpy(afsCacheDir, p);
else if (strncmp(line, "CacheBlocks", len1) == 0)
*cacheBlocks = atoi(p);
else if (strncmp(line, "CacheFiles", len1) == 0)
*cacheFiles = atoi(p);
else if (strncmp(line, "CacheStatEntries", len1) == 0)
*cacheStatEntries = atoi(p);
else if (strncmp(line, "DCacheSize", len1) == 0)
*dCacheSize = atoi(p);
else if (strncmp(line, "VCacheSize", len1) == 0)
*vCacheSize = atoi(p);
else if (strncmp(line, "ChunkSize", len1) == 0)
*chunkSize = atoi(p);
else if (strncmp(line, "CloseSynch", len1) == 0)
*closeSynch = atoi(p);
else if (strncmp(line, "Debug", len1) == 0)
*debug = atoi(p);
else if (strncmp(line, "NDaemons", len1) == 0)
*nDaemons = atoi(p);
else if (strncmp(line, "CacheFlags", len1) == 0)
*cacheFlags = atoi(p);
else if (strncmp(line, "LogFile", len1) == 0)
strcpy(logFile, p);
}
return 0;
}
int setString(JNIEnv *env, jobject *obj, char *field, char *string)
{
jclass cls;
jstring jstr;
jfieldID fid;
cls = (*env)->GetObjectClass(env, *obj);
/*fprintf(stderr, "setString: env=0x%x, obj=0x%x, cls=0x%x\n", env, obj, cls);*/
if (cls != NULL) {
fid = (*env)->GetFieldID(env, cls, field, "Ljava/lang/String;");
/*fprintf(stderr, "setString: field=%s, fid=0x%x\n", field, fid);*/
if (fid) {
jstr = (*env)->NewStringUTF(env, (string));
/*fprintf(stderr, "jstr = 0x%x\n", jstr);*/
(*env)->SetObjectField(env, *obj, fid, jstr);
return 0;
}
}
return -1;
}
#else
/**
* Makes a kas identity given the full name of a kas user. If the
* name contains a period, everything after the first period is
* considered to be the instance of that name, otherwise
* the instance is the empty string. The memory for who
* that's passed in should be fully allocated in advance.
*/
void internal_makeKasIdentity( const char *fullName,
kas_identity_p who ) {
char *period;
if( (period = (char *) strchr( fullName, '.' )) != NULL ) {
strncpy( who->principal, fullName, period - fullName );
who->principal[period - fullName] = '\0';
strncpy( who->instance, period + 1,
strlen(fullName) - (period - fullName) );
} else {
strcpy( who->principal, fullName);
strcpy( who->instance, "" );
}
}
/**
* Given a Java environment and an instance of a user, gets the object and
* field information for the user object from the Java environment.
*/
void internal_getUserClass( JNIEnv *env, jobject user ) {
if( userCls == 0 ) {
userCls = (*env)->NewGlobalRef( env, (*env)->GetObjectClass(env, user) );
if( !userCls ) {
throwAFSException( env, JAFSADMCLASSNOTFOUND );
return;
}
user_ptsField = (*env)->GetFieldID( env, userCls, "pts", "Z" );
user_kasField = (*env)->GetFieldID( env, userCls, "kas", "Z" );
user_nameField = (*env)->GetFieldID( env, userCls, "name",
"Ljava/lang/String;" );
user_cachedInfoField = (*env)->GetFieldID( env, userCls, "cachedInfo",
"Z" );
// pts fields
user_nameUidField = (*env)->GetFieldID( env, userCls, "nameUID", "I" );
user_ownerUidField = (*env)->GetFieldID( env, userCls, "ownerUID", "I" );
user_creatorUidField = (*env)->GetFieldID( env, userCls, "creatorUID",
"I" );
user_listStatusField = (*env)->GetFieldID( env, userCls, "listStatus",
"I" );
user_listGroupsOwnedField = (*env)->GetFieldID( env, userCls,
"listGroupsOwned", "I" );
user_listMembershipField = (*env)->GetFieldID( env, userCls,
"listMembership", "I" );
user_groupCreationQuotaField = (*env)->GetFieldID( env, userCls,
"groupCreationQuota",
"I" );
user_groupMembershipCountField = (*env)->GetFieldID( env, userCls,
"groupMembershipCount",
"I" );
user_ownerField = (*env)->GetFieldID( env, userCls, "owner",
"Ljava/lang/String;" );
user_creatorField = (*env)->GetFieldID( env, userCls, "creator",
"Ljava/lang/String;" );
// kas fields
user_adminSettingField = (*env)->GetFieldID( env, userCls, "adminSetting",
"I" );
user_tgsSettingField = (*env)->GetFieldID( env, userCls, "tgsSetting",
"I" );
user_encSettingField = (*env)->GetFieldID( env, userCls, "encSetting",
"I" );
user_cpwSettingField = (*env)->GetFieldID( env, userCls, "cpwSetting",
"I" );
user_rpwSettingField = (*env)->GetFieldID( env, userCls, "rpwSetting",
"I" );
user_userExpirationField = (*env)->GetFieldID( env, userCls,
"userExpiration", "I" );
user_lastModTimeField = (*env)->GetFieldID( env, userCls, "lastModTime",
"I" );
user_lastModNameField = (*env)->GetFieldID( env, userCls, "lastModName",
"Ljava/lang/String;" );
user_lastChangePasswordTimeField = (*env)->GetFieldID( env, userCls,
"lastChangePasswordTime",
"I" );
user_maxTicketLifetimeField = (*env)->GetFieldID( env, userCls,
"maxTicketLifetime",
"I" );
user_keyVersionField = (*env)->GetFieldID( env, userCls, "keyVersion",
"I" );
user_encryptionKeyField = (*env)->GetFieldID( env, userCls,
"encryptionKey",
"Ljava/lang/String;" );
user_keyCheckSumField = (*env)->GetFieldID( env, userCls, "keyCheckSum",
"J" );
user_daysToPasswordExpireField = (*env)->GetFieldID( env, userCls,
"daysToPasswordExpire",
"I" );
user_failLoginCountField = (*env)->GetFieldID( env, userCls,
"failLoginCount", "I" );
user_lockTimeField = (*env)->GetFieldID( env, userCls, "lockTime", "I" );
user_lockedUntilField = (*env)->GetFieldID( env, userCls, "lockedUntil",
"I" );
if( !user_ptsField || !user_kasField || !user_nameField ||
!user_cachedInfoField || !user_nameUidField || !user_ownerUidField ||
!user_creatorUidField || !user_listStatusField ||
!user_listGroupsOwnedField || !user_listMembershipField ||
!user_groupCreationQuotaField || !user_groupMembershipCountField ||
!user_ownerField || !user_creatorField || !user_adminSettingField ||
!user_tgsSettingField || !user_encSettingField ||
!user_cpwSettingField || !user_rpwSettingField ||
!user_userExpirationField || !user_lastModTimeField ||
!user_lastModNameField || !user_lastChangePasswordTimeField ||
!user_maxTicketLifetimeField || !user_keyVersionField ||
!user_encryptionKeyField || !user_keyCheckSumField ||
!user_daysToPasswordExpireField || !user_failLoginCountField ||
!user_lockTimeField || !user_lockedUntilField ) {
throwAFSException( env, JAFSADMFIELDNOTFOUND );
return;
}
}
}
/**
* Given a Java environment and an instance of a group, gets the object and
* field information for the group object from the Java environment.
*/
void internal_getGroupClass( JNIEnv *env, jobject group ) {
if( groupCls == 0 ) {
groupCls = (*env)->NewGlobalRef( env, (*env)->GetObjectClass(env, group) );
if( !groupCls ) {
throwAFSException( env, JAFSADMCLASSNOTFOUND );
return;
}
group_nameField = (*env)->GetFieldID( env, groupCls, "name",
"Ljava/lang/String;" );
group_cachedInfoField = (*env)->GetFieldID( env, groupCls, "cachedInfo",
"Z" );
group_nameUidField = (*env)->GetFieldID( env, groupCls, "nameUID", "I" );
group_ownerUidField = (*env)->GetFieldID( env, groupCls, "ownerUID", "I" );
group_creatorUidField = (*env)->GetFieldID( env, groupCls, "creatorUID",
"I" );
group_listStatusField = (*env)->GetFieldID( env, groupCls, "listStatus",
"I" );
group_listGroupsOwnedField = (*env)->GetFieldID( env, groupCls,
"listGroupsOwned", "I" );
group_listMembershipField = (*env)->GetFieldID( env, groupCls,
"listMembership", "I" );
group_listAddField = (*env)->GetFieldID( env, groupCls, "listAdd", "I" );
group_listDeleteField = (*env)->GetFieldID( env, groupCls, "listDelete",
"I" );
group_membershipCountField = (*env)->GetFieldID( env, groupCls,
"membershipCount", "I" );
group_ownerField = (*env)->GetFieldID( env, groupCls, "owner",
"Ljava/lang/String;" );
group_creatorField = (*env)->GetFieldID( env, groupCls, "creator",
"Ljava/lang/String;" );
if( !group_nameField || !group_cachedInfoField || !group_nameUidField ||
!group_ownerUidField || !group_creatorUidField ||
!group_listStatusField || !group_listGroupsOwnedField ||
!group_listMembershipField || !group_listAddField ||
!group_listDeleteField || !group_membershipCountField ||
!group_ownerField || !group_creatorField ) {
throwAFSException( env, JAFSADMFIELDNOTFOUND );
return;
}
}
}
/**
* Given a Java environment and an instance of a server, gets the object and
* field information for the server object from the Java environment.
*/
void internal_getServerClass( JNIEnv *env, jobject server ) {
if( serverCls == 0 ) {
serverCls = (*env)->NewGlobalRef( env,
(*env)->GetObjectClass(env, server) );
if( !serverCls ) {
throwAFSException( env, JAFSADMCLASSNOTFOUND );
return;
}
server_nameField = (*env)->GetFieldID( env, serverCls, "name",
"Ljava/lang/String;" );
server_cachedInfoField = (*env)->GetFieldID( env, serverCls, "cachedInfo",
"Z" );
server_databaseField = (*env)->GetFieldID( env, serverCls, "database",
"Z" );
server_fileServerField = (*env)->GetFieldID( env, serverCls, "fileServer",
"Z" );
server_badDatabaseField = (*env)->GetFieldID( env, serverCls,
"badDatabase", "Z" );
server_badFileServerField = (*env)->GetFieldID( env, serverCls,
"badFileServer", "Z" );
server_IPAddressField = (*env)->GetFieldID( env, serverCls, "ipAddresses",
"[Ljava/lang/String;" );
if( !server_nameField || !server_cachedInfoField || !server_databaseField
|| !server_fileServerField || !server_badDatabaseField ||
!server_badFileServerField || !server_IPAddressField ) {
throwAFSException( env, JAFSADMFIELDNOTFOUND );
return;
}
}
}
/**
* Given a Java environment and an instance of an executableTime, gets the
* object and field information for the executableTime object from the
* Java environment.
*/
void internal_getExecTimeClass( JNIEnv *env, jobject exectime ) {
if( exectimeCls == 0 ) {
exectimeCls = (*env)->NewGlobalRef( env,
(*env)->GetObjectClass(env, exectime) );
if( !exectimeCls ) {
throwAFSException( env, JAFSADMCLASSNOTFOUND );
return;
}
exectime_HourField = (*env)->GetFieldID( env, exectimeCls, "hour", "S" );
exectime_MinField = (*env)->GetFieldID( env, exectimeCls, "minute",
"S" );
exectime_SecField = (*env)->GetFieldID( env, exectimeCls, "second",
"S" );
exectime_DayField = (*env)->GetFieldID( env, exectimeCls, "day", "S" );
exectime_NowField = (*env)->GetFieldID( env, exectimeCls, "now", "Z" );
exectime_NeverField = (*env)->GetFieldID( env, exectimeCls, "never", "Z" );
if( !exectime_HourField || !exectime_MinField || !exectime_SecField ||
!exectime_DayField || !exectime_NowField || !exectime_NeverField ) {
throwAFSException( env, JAFSADMFIELDNOTFOUND );
return;
}
}
}
/**
* Given a Java environment and an instance of a partition, gets the object and
* field information for the partition object from the Java environment.
*/
void internal_getPartitionClass( JNIEnv *env, jobject partition ) {
if( partitionCls == 0 ) {
partitionCls = (*env)->NewGlobalRef( env,
(*env)->GetObjectClass(env, partition) );
if( !partitionCls ) {
throwAFSException( env, JAFSADMCLASSNOTFOUND );
return;
}
partition_nameField = (*env)->GetFieldID( env, partitionCls, "name",
"Ljava/lang/String;" );
partition_deviceNameField = (*env)->GetFieldID( env, partitionCls,
"deviceName",
"Ljava/lang/String;" );
partition_idField = (*env)->GetFieldID( env, partitionCls, "id", "I" );
partition_cachedInfoField = (*env)->GetFieldID( env, partitionCls,
"cachedInfo", "Z" );
partition_lockFileDescriptorField = (*env)->GetFieldID( env, partitionCls,
"lockFileDescriptor",
"I" );
partition_totalSpaceField = (*env)->GetFieldID( env, partitionCls,
"totalSpace", "I" );
partition_totalFreeSpaceField = (*env)->GetFieldID( env, partitionCls,
"totalFreeSpace", "I");
if( !partition_nameField || !partition_cachedInfoField ||
!partition_idField || !partition_deviceNameField ||
!partition_lockFileDescriptorField || !partition_totalSpaceField ||
!partition_totalFreeSpaceField ) {
throwAFSException( env, JAFSADMFIELDNOTFOUND );
return;
}
}
}
/**
* Given a Java environment and an instance of a volume, gets the object and
* field information for the volume object from the Java environment.
*/
void internal_getVolumeClass( JNIEnv *env, jobject volume ) {
if( volumeCls == 0 ) {
volumeCls = (*env)->NewGlobalRef( env,
(*env)->GetObjectClass(env, volume) );
if( !volumeCls ) {
throwAFSException( env, JAFSADMCLASSNOTFOUND );
return;
}
volume_nameField = (*env)->GetFieldID( env, volumeCls, "name",
"Ljava/lang/String;" );
volume_cachedInfoField = (*env)->GetFieldID( env, volumeCls, "cachedInfo",
"Z" );
volume_idField = (*env)->GetFieldID( env, volumeCls, "id", "I" );
volume_readWriteIdField = (*env)->GetFieldID( env, volumeCls,
"readWriteID", "I" );
volume_readOnlyIdField = (*env)->GetFieldID( env, volumeCls, "readOnlyID",
"I" );
volume_backupIdField = (*env)->GetFieldID( env, volumeCls, "backupID",
"I" );
volume_creationDateField = (*env)->GetFieldID( env, volumeCls,
"creationDate", "J" );
volume_lastAccessDateField = (*env)->GetFieldID( env, volumeCls,
"lastAccessDate", "J" );
volume_lastUpdateDateField = (*env)->GetFieldID( env, volumeCls,
"lastUpdateDate", "J" );
volume_lastBackupDateField = (*env)->GetFieldID( env, volumeCls,
"lastBackupDate", "J" );
volume_copyCreationDateField = (*env)->GetFieldID( env, volumeCls,
"copyCreationDate",
"J" );
volume_accessesSinceMidnightField = (*env)->GetFieldID( env, volumeCls,
"accessesSinceMidnight",
"I" );
volume_fileCountField = (*env)->GetFieldID( env, volumeCls, "fileCount",
"I" );
volume_maxQuotaField = (*env)->GetFieldID( env, volumeCls, "maxQuota",
"I" );
volume_currentSizeField = (*env)->GetFieldID( env, volumeCls,
"currentSize", "I" );
volume_statusField = (*env)->GetFieldID( env, volumeCls, "status", "I" );
volume_dispositionField = (*env)->GetFieldID( env, volumeCls,
"disposition", "I" );
volume_typeField = (*env)->GetFieldID( env, volumeCls, "type", "I" );
if( !volume_nameField || !volume_cachedInfoField || !volume_idField ||
!volume_readWriteIdField || !volume_readOnlyIdField ||
!volume_backupIdField || !volume_creationDateField ||
!volume_lastAccessDateField || !volume_lastUpdateDateField ||
!volume_lastBackupDateField || !volume_copyCreationDateField ||
!volume_accessesSinceMidnightField || !volume_fileCountField ||
!volume_maxQuotaField || !volume_currentSizeField ||
!volume_statusField || !volume_dispositionField ||
!volume_typeField ) {
throwAFSException( env, JAFSADMFIELDNOTFOUND );
return;
}
}
}
/**
* Given a Java environment and an instance of a key, gets the object and
* field information for the key object from the Java environment.
*/
void internal_getKeyClass( JNIEnv *env, jobject key ) {
if( keyCls == 0 ) {
keyCls = (*env)->NewGlobalRef( env, (*env)->GetObjectClass(env, key) );
if( !keyCls ) {
throwAFSException( env, JAFSADMCLASSNOTFOUND );
return;
}
key_encryptionKeyField = (*env)->GetFieldID( env, keyCls,
"encryptionKey",
"Ljava/lang/String;" );
key_cachedInfoField = (*env)->GetFieldID( env, keyCls, "cachedInfo", "Z" );
key_versionField = (*env)->GetFieldID( env, keyCls, "version", "I" );
key_lastModDateField = (*env)->GetFieldID( env, keyCls, "lastModDate",
"I" );
key_lastModMsField = (*env)->GetFieldID( env, keyCls, "lastModMs", "I" );
key_checkSumField = (*env)->GetFieldID( env, keyCls, "checkSum", "J" );
if( !key_cachedInfoField || !key_versionField || !key_encryptionKeyField
|| !key_lastModDateField || !key_lastModMsField ||
!key_checkSumField ) {
throwAFSException( env, JAFSADMFIELDNOTFOUND );
return;
}
}
}
/**
* Given a Java environment and an instance of a process, gets the object and
* field information for the process object from the Java environment.
*/
void internal_getProcessClass( JNIEnv *env, jobject process ) {
if( processCls == 0 ) {
processCls = (*env)->NewGlobalRef( env,
(*env)->GetObjectClass(env, process) );
if( !processCls ) {
throwAFSException( env, JAFSADMCLASSNOTFOUND );
return;
}
process_cachedInfoField = (*env)->GetFieldID( env, processCls,
"cachedInfo", "Z" );
process_nameField = (*env)->GetFieldID( env, processCls, "name",
"Ljava/lang/String;" );
process_typeField = (*env)->GetFieldID( env, processCls, "type", "I" );
process_stateField = (*env)->GetFieldID( env, processCls, "state", "I" );
process_goalField = (*env)->GetFieldID( env, processCls, "goal", "I" );
process_startTimeField = (*env)->GetFieldID( env, processCls, "startTime",
"J" );
process_numberStartsField = (*env)->GetFieldID( env, processCls,
"numberStarts", "J" );
process_exitTimeField = (*env)->GetFieldID( env, processCls, "exitTime",
"J" );
process_exitErrorTimeField = (*env)->GetFieldID( env, processCls,
"exitErrorTime", "J" );
process_errorCodeField = (*env)->GetFieldID( env, processCls, "errorCode",
"J" );
process_errorSignalField = (*env)->GetFieldID( env, processCls,
"errorSignal", "J" );
process_stateOkField = (*env)->GetFieldID( env, processCls, "stateOk",
"Z" );
process_stateTooManyErrorsField = (*env)->GetFieldID( env, processCls,
"stateTooManyErrors",
"Z" );
process_stateBadFileAccessField = (*env)->GetFieldID( env, processCls,
"stateBadFileAccess",
"Z" );
if( !process_cachedInfoField || !process_nameField || !process_typeField
|| !process_stateField || !process_goalField ||
!process_startTimeField || !process_numberStartsField ||
!process_exitTimeField || !process_exitErrorTimeField ||
!process_errorCodeField || !process_errorSignalField ||
!process_stateOkField || !process_stateTooManyErrorsField ||
!process_stateBadFileAccessField ) {
throwAFSException( env, JAFSADMFIELDNOTFOUND );
return;
}
}
}
#endif /* LIBJUAFS */

View File

@ -1,63 +0,0 @@
#ifndef _Jafsadm_Internal
#define _Jafsadm_Internal
#include <jni.h>
#include "Exceptions.h"
#ifndef LIBJUAFS
#include <afs_Admin.h>
#include <afs_kasAdmin.h>
// error codes
#define JAFSADMNOMEM 1050 // Memory problems
#define JAFSADMCLASSNOTFOUND 1051 // Trouble finding a Java class
#define JAFSADMMETHODNOTFOUND 1052 // Trouble finding a Java method
#define JAFSADMFIELDNOTFOUND 1053 // Trouble finding a Java field
// make an identity out of a full name (possibly including an instance )
void internal_makeKasIdentity( const char *fullName, kas_identity_p who );
void internal_getUserClass( JNIEnv *env, jobject user );
void internal_getGroupClass( JNIEnv *env, jobject group );
void internal_getServerClass( JNIEnv *env, jobject server );
void internal_getPartitionClass( JNIEnv *env, jobject partition );
void internal_getVolumeClass( JNIEnv *env, jobject volume );
void internal_getKeyClass( JNIEnv *env, jobject key );
void internal_getProcessClass( JNIEnv *env, jobject process );
#else
int openAFSFile(JNIEnv *env, jstring fileNameUTF, int flags, int mode, int *err);
int readCacheParms(char *afsMountPoint, char *afsConfDir, char *afsCacheDir,
int *cacheBlocks, int *cacheFiles, int *cacheStatEntries,
int *dCacheSize, int *vCacheSize, int *chunkSize,
int *closeSynch, int *debug, int *nDaemons, int *cacheFlags,
char *logFile);
#endif /* !LIBJUAFS */
// throw a non-AFS exception with a message
void throwMessageException( JNIEnv *env, char *msg );
// throw an AFS exception with a message
void throwAFSException( JNIEnv *env, int code );
// throw an AFS Admin exception with a message
void throwAFSException( JNIEnv *env, int code );
// throw an AFS File or I/O related exception with a message
void throwFileAdminException( JNIEnv *env, int code, char *msg );
// throw an AFS Security exception with a message
void throwAFSSecurityException( JNIEnv *env, int code );
// throw an exception with an error code
void throwException( JNIEnv *env, jclass *excCls, char *excClsName, jmethodID *initID, int code );
// reclaim global memory used by exceptions
void reclaimExceptionMemory( JNIEnv *env, jclass cls );
int setError(JNIEnv *env, jobject *obj, int code);
int setString(JNIEnv *env, jobject *obj, char *field, char *string);
#endif

View File

@ -1,105 +0,0 @@
Java API for OpenAFS (Jafs) README
Current as of 6/5/02
##########################################################################
# Copyright (c) 2001-2002 International Business Machines Corp. #
# All rights reserved. #
# #
# This software has been released under the terms of the IBM Public #
# License. For details, see the LICENSE file in the top-level source #
# directory or online at http://www.openafs.org/dl/license10.html #
# #
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS #
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR #
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR #
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, #
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, #
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR #
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF #
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING #
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS #
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #
##########################################################################
*** INTRODUCTION ***
Jafs is an open source API designed to allow Java programmers the ability
to create applications for the administration or use of OpenAFS file systems.
It works by accessing libadmin and libuafs (administrative and user-level
libraries that come with OpenAFS) through JNI. It consists of a Java package
called org.openafs.jafs, and a shared libraries libjafsadm.so and libjafs.so.
*** USE ***
There is a version of Jafs that has been compiled on Red Hat Linux 7.1,
and can be directly used without compilation. It was compiled using
OpenAFS 1.2.4 libraries (with a modified version of libjuafs.a). It
consists of a JAR file (jafs.jar) and two shared libraries
(libjafsadm.so and libjafs.so). It was compiled using the
--enable-transarc-paths on compilation (for use with the OpenAFS RPMs),
gcc 2.96, and Java Classic VM version 1.4.0.
When you write Java code to use this API, import the
org.openafs.jafs package. During compilation of your Java code,
ensure one of the following conditions are met:
- Use the "-classpath" option to javac to specify the jafs.jar file.
- Change your $CLASSPATH environment variable to include the
jafs.jar file (e.g. export CLASSPATH=$CLASSPATH:jafs.jar
When running an application that uses Jafs, the shared libraries
need to be found by Java's library loader. The easiest way to
accomplish this is to copy these files into the /usr/lib/ directory,
or create symbolic links from that directory to the files. Alternatively,
the directory containing the libraries can also be added to the
LD_LIBRARY_PATH environment variable, instead.
You also need to have an OpenAFS client set up on your machine
(preferably version 1.2.4, but it should work for some past versions as well).
You can obtain the OpenAFS client and view installation documentation at
http://www.openafs.org (the RPMs are easiest to use for Linux). Also any
cells you plan to access through the API must have entries in your
client's CellServDB file (located in the /usr/vice/etc/ directory in most
setups).
This API is most effective when used with a cell that uses the kaserver
for authentication. It does not currently support alternative methods of
authentication such as Kerberos V.
If you have successfully set up your Linux 7.1 environment as described
above, you will be able to develop and execute applications that use
the Jafs API.
*** BUILD ***
The first step in compiling your own versions of the library and jar file
is to download the OpenAFS source code.
From that same directory, run the configure script as you normally would
to compile OpenAFS, but run it with a java_home argument so the script can
find your java distribution. For example:
./configure [other options] --java_home=/usr/local/jdk
The configure script will ensure that this directory contains bin/ and lib/
subdirectories, and that there are /bin/javac and/bin/javah executables and
an include/jni.h file. If you don't supply a command line argument for the
java home, the script will look for it in environment variables: first in
$JAVA_HOME and then in $JDK_HOME. Also, note that if you have installed
(or are planning to install) OpenAFS by using the RPMs for Linux, you
should provide the --enable-transarc-paths configuration option. If you
get a "** Can't determine local cell name" error message, the most likely
reason is that you didn't supply this option.
Next, do a full build of OpenAFS by executing a make in the current
directory. After it finishes, you are ready to compile Jafs. Execute
'make jafs' from that same directory. Afterward, there will be
libjafsadm.so and libjafs.so in the lib/ directory, and a jafs.jar in the
jlib/ directory. These can be used according to the instructions in the
'USE' section of this document.
If you'd like to edit the source code, you'll find the native C code in
the src/libjafs directory, and the Java code in the
src/JAVA/org/openafs/jafs/ directory. Please reference the
src/TechNotes-JavaAPI document for more information.

View File

@ -1,10 +0,0 @@
#ifndef __JAFS_VERSION_H_1234__
#define __JAFS_VERSION_H_1234__
#include "Internal.h"
#define VERSION_LIB_JAVA_OPENAFS "20050928_01"
extern char cml_version_number[]; /* from AFS_component_number.c */
#endif /* __JAFS_VERSION_H_1234__ */

View File

@ -1,248 +0,0 @@
/*
* Copyright (c) 2001-2002 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "Internal.h"
#include "org_openafs_jafs_Key.h"
#include <afs_bosAdmin.h>
#include <afs_AdminCommonErrors.h>
#include <kautils.h>
//// definitions in Internal.c //////////////////
extern jclass keyCls;
extern jfieldID key_versionField;
extern jfieldID key_encryptionKeyField;
extern jfieldID key_lastModDateField;
extern jfieldID key_lastModMsField;
extern jfieldID key_checkSumField;
//////////////////////////////////////////////////////////////////
/**
* Extract the information from the given key entry and populate the
* given object
*
* env the Java environment
* key the Key object to populate with the info
* keyEntry the container of the key's information
*/
void fillKeyInfo( JNIEnv *env, jobject key, bos_KeyInfo_t keyEntry )
{
jstring jencryptionKey;
char *convertedKey;
int i;
// get the class fields if need be
if( keyCls == 0 ) {
internal_getKeyClass( env, key );
}
// set all the fields
(*env)->SetIntField( env, key, key_versionField, keyEntry.keyVersionNumber );
convertedKey = malloc( sizeof(char *) * (sizeof(keyEntry.key.key)*4+1) );
if( !convertedKey ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
for( i = 0; i < sizeof(keyEntry.key.key); i++ ) {
sprintf( &(convertedKey[i*4]), "\\%0.3o", keyEntry.key.key[i] );
}
jencryptionKey = (*env)->NewStringUTF(env, convertedKey);
(*env)->SetObjectField( env, key, key_encryptionKeyField, jencryptionKey );
(*env)->SetIntField( env, key, key_lastModDateField,
keyEntry.keyStatus.lastModificationDate );
(*env)->SetIntField( env, key, key_lastModMsField,
keyEntry.keyStatus.lastModificationMicroSeconds );
(*env)->SetLongField( env, key, key_checkSumField,
(unsigned int) keyEntry.keyStatus.checkSum );
free( convertedKey );
}
/**
* Fills in the information fields of the provided Key.
*
* env the Java environment
* cls the current Java class
* serverHandle the bos handle of the server to which the key
* belongs
* version the version of the key for which to get the information
* key the Key object in which to fill in the
* information
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Key_getKeyInfo
(JNIEnv *env, jclass cls, jlong serverHandle, jint version, jobject key)
{
afs_status_t ast;
bos_KeyInfo_t keyEntry;
void *iterationId;
int done;
if( !bos_KeyGetBegin( (void *) serverHandle, &iterationId, &ast ) ) {
throwAFSException( env, ast );
return;
}
done = FALSE;
// there's no KeyGet function, so we must iterate and find the
// one with the matching version
while( !done ) {
if( !bos_KeyGetNext( iterationId, &keyEntry, &ast ) ) {
// no matching key
if( ast == ADMITERATORDONE ) {
afs_status_t astnew;
if( !bos_KeyGetDone( iterationId, &astnew ) ) {
throwAFSException( env, astnew );
return;
}
throwAFSException( env, KAUNKNOWNKEY );
return;
// other
} else {
throwAFSException( env, ast );
return;
}
}
if( keyEntry.keyVersionNumber == version ) {
done = TRUE;
}
}
fillKeyInfo( env, key, keyEntry );
if( !bos_KeyGetDone( iterationId, &ast ) ) {
throwAFSException( env, ast );
return;
}
}
/**
* Create a server key.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the server belongs
* serverHandle the bos handle of the server to which the key will
* belong
* versionNumber the version number of the key to create (0 to 255)
* jkeyString the String version of the key that will
* be encrypted
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Key_create
(JNIEnv *env, jclass cls, jlong cellHandle, jlong serverHandle, jint version,
jstring jkeyString)
{
afs_status_t ast;
const char *keyString;
char *cellName;
kas_encryptionKey_p key =
(kas_encryptionKey_p) malloc( sizeof(kas_encryptionKey_t) );
if( !key ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
if( jkeyString != NULL ) {
keyString = (*env)->GetStringUTFChars(env, jkeyString, 0);
if( !keyString ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
keyString = NULL;
}
if( !afsclient_CellNameGet( (void *) cellHandle, &cellName, &ast ) ) {
free( key );
if( keyString != NULL ) {
(*env)->ReleaseStringUTFChars(env, jkeyString, keyString);
}
throwAFSException( env, ast );
return;
}
if( !kas_StringToKey( cellName, keyString, key, &ast ) ) {
free( key );
if( keyString != NULL ) {
(*env)->ReleaseStringUTFChars(env, jkeyString, keyString);
}
throwAFSException( env, ast );
return;
}
if( !bos_KeyCreate( (void *) serverHandle, version, key, &ast ) ) {
free( key );
if( keyString != NULL ) {
(*env)->ReleaseStringUTFChars(env, jkeyString, keyString);
}
throwAFSException( env, ast );
return;
}
free( key );
if( keyString != NULL ) {
(*env)->ReleaseStringUTFChars(env, jkeyString, keyString);
}
}
/**
* Delete a server key.
*
* env the Java environment
* cls the current Java class
* serverHandle the bos handle of the server to which the key belongs
* versionNumber the version number of the key to remove (0 to 255)
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Key_delete
(JNIEnv *env, jclass cls, jlong serverHandle, jint version )
{
afs_status_t ast;
if( !bos_KeyDelete( (void *) serverHandle, version, &ast ) ) {
throwAFSException( env, ast );
return;
}
}
// reclaim global memory being used by this portion
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Key_reclaimKeyMemory (JNIEnv *env, jclass cls)
{
if( keyCls ) {
(*env)->DeleteGlobalRef(env, keyCls);
keyCls = 0;
}
}

View File

@ -1,275 +0,0 @@
# Copyright 2000, International Business Machines Corporation and others.
# All Rights Reserved.
#
# This software has been released under the terms of the IBM Public
# License. For details, see the LICENSE file in the top-level source
# directory or online at http://www.openafs.org/dl/license10.html
include ../../config/Makefile.config
#${SYS_NAME}
DEST=@DEST@
TOP_SRCDIR=@TOP_SRCDIR@
TOP_INCDIR=@TOP_INCDIR@
TOP_LIBDIR=@TOP_LIBDIR@
TOP_JLIBDIR=@TOP_SRCDIR@/JAVA/libjafs
JNI_INC=-I ${JAVA_HOME}/include -I `dirname ${JAVA_HOME}/include/*/jni_md.h`
prefix=@prefix@
exec_prefix=@exec_prefix@
datarootdir=@datarootdir@
bindir=@bindir@
sbindir=@sbindir@
libexecdir=@libexecdir@
libdir=@libdir@
includedir=@includedir@
mandir=@mandir@
afssrvbindir=@afssrvbindir@
afssrvsbindir=@afssrvsbindir@
afssrvlibexecdir=@afssrvlibexecdir@
COMPILE_ET=${TOP_SRCDIR}/comerr/compile_et
RXGEN=${TOP_SRCDIR}/rxgen/rxgen
SYS_NAME=@AFS_SYSNAME@
CC = ${MT_CC}
SHARED_FLAGS = -shared -Xlinker -Bsymbolic
OBJECT_FLAGS = -fPIC -c
ifeq "$(BUILD_TYPE)" "admin"
INC := -I${TOP_SRCDIR}/config -I${TOP_INCDIR} -I${TOP_INCDIR}/afs/ ${JNI_INC}
CFLAGS := ${INC} ${DBG} ${OPTMZ} -I${TOP_SRCDIR}/config ${MT_CFLAGS}
else
INC := -I${TOP_SRCDIR}/config -I${TOP_SRCDIR}/libuafs -I${TOP_INCDIR} ${JNI_INC}
CFLAGS := ${INC} ${DBG} ${OPTMZ} ${FSINCLUDES} -D_REENTRANT -DLIBJUAFS ${MT_CFLAGS}
endif
LIBJAFSADMDIR = ./
ROOTPACKAGEDIR = ../classes
RELPACKAGEDIR = org/openafs/jafs/
PACKAGEDIR = ${ROOTPACKAGEDIR}/${RELPACKAGEDIR}
JAVADOCSDIR = javadocs/
JAVAH = ${JAVA_HOME}/bin/javah -classpath ${ROOTPACKAGEDIR} -jni -d ${LIBJAFSADMDIR}
JAVAC = ${JAVA_HOME}/bin/javac -source 1.4 -classpath ${ROOTPACKAGEDIR}
J_NATIVE_PREFIX = org.openafs.jafs.
C_NATIVE_PREFIX = org_openafs_jafs_
PACKAGE =\
${PACKAGEDIR}ACL.class \
${PACKAGEDIR}AFSException.class \
${PACKAGEDIR}AFSFileException.class \
${PACKAGEDIR}AFSSecurityException.class \
${PACKAGEDIR}Cell.class \
${PACKAGEDIR}File.class \
${PACKAGEDIR}FileInputStream.class \
${PACKAGEDIR}FileOutputStream.class \
${PACKAGEDIR}Group.class \
${PACKAGEDIR}Key.class \
${PACKAGEDIR}Partition.class \
${PACKAGEDIR}Process.class \
${PACKAGEDIR}Server.class \
${PACKAGEDIR}Token.class \
${PACKAGEDIR}User.class \
${PACKAGEDIR}Volume.class \
${PACKAGEDIR}VersionInfo.class
ifeq (${SYS_NAME}, ppc64_linux26)
LIBJAFS_OBJS =
else
ifeq (${SYS_NAME}, s390x_linux26)
LIBJAFS_OBJS =
else
LIBJAFS_OBJS =\
${LIBJAFSADMDIR}GetNativeString.o \
${LIBJAFSADMDIR}ACL.o
endif
endif
LIBJAFS_OBJS +=\
${LIBJAFSADMDIR}File.o \
${LIBJAFSADMDIR}FileInputStream.o \
${LIBJAFSADMDIR}FileOutputStream.o \
${LIBJAFSADMDIR}Internal.o \
${LIBJAFSADMDIR}UserToken.o \
${LIBJAFSADMDIR}VersionInfo.o \
${TOP_SRCDIR}/libuafs/UAFS/xdr_int32.o
ifeq (${SYS_NAME}, ppc64_linux26)
LIBJAFSADM_OBJS =\
${LIBJAFSADMDIR}GetNativeString.o \
${LIBJAFSADMDIR}ACL.o
else
ifeq (${SYS_NAME}, s390x_linux26)
LIBJAFSADM_OBJS =\
${LIBJAFSADMDIR}GetNativeString.o \
${LIBJAFSADMDIR}ACL.o
else
LIBJAFSADM_OBJS =
endif
endif
LIBJAFSADM_OBJS +=\
${LIBJAFSADMDIR}AdminToken.o \
${LIBJAFSADMDIR}Cell.o \
${LIBJAFSADMDIR}Group.o \
${LIBJAFSADMDIR}Internal.o \
${LIBJAFSADMDIR}Key.o \
${LIBJAFSADMDIR}Partition.o \
${LIBJAFSADMDIR}Process.o \
${LIBJAFSADMDIR}Server.o \
${LIBJAFSADMDIR}User.o \
${LIBJAFSADMDIR}Version2.o \
${LIBJAFSADMDIR}Volume.o
CORRELATING_SOURCE_FILES =\
${LIBJAFSADMDIR}ACL.c \
${LIBJAFSADMDIR}Cell.c \
${LIBJAFSADMDIR}File.c \
${LIBJAFSADMDIR}FileInputStream.c \
${LIBJAFSADMDIR}FileOutputStream.c \
${LIBJAFSADMDIR}Group.c \
${LIBJAFSADMDIR}Key.c \
${LIBJAFSADMDIR}Partition.c \
${LIBJAFSADMDIR}Process.c \
${LIBJAFSADMDIR}Server.c \
${LIBJAFSADMDIR}User.c \
${LIBJAFSADMDIR}Volume.c \
${LIBJAFSADMDIR}VersionInfo.c
JAVA_HEADERS = ${PACKAGE:${PACKAGEDIR}%.class=${C_NATIVE_PREFIX}%.h}
BOSADMINLIB = ${TOP_LIBDIR}/libbosadmin.a
VOSADMINLIB = ${TOP_LIBDIR}/libvosadmin.a
PTSADMINLIB = ${TOP_LIBDIR}/libptsadmin.a
KASADMINLIB = ${TOP_LIBDIR}/libkasadmin.a
CFGADMINLIB = ${TOP_LIBDIR}/libcfgadmin.a
UTILADMINLIB = ${TOP_LIBDIR}/libafsadminutil.a
CLIENTADMINLIB = ${TOP_LIBDIR}/libclientadmin.a
LIBJAFS_LIBS =\
${TOP_LIBDIR}/libuafs.a \
${TOP_LIBDIR}/libafsutil.a \
-lresolv \
-lpthread
LIBJAFSADM_LIBS =\
${CLIENTADMINLIB} \
${VOSADMINLIB} \
${BOSADMINLIB} \
${PTSADMINLIB} \
${KASADMINLIB} \
${CFGADMINLIB} \
${UTILADMINLIB} \
${TOP_LIBDIR}/libafsauthent.a \
${TOP_LIBDIR}/libafsrpc.a \
${TOP_LIBDIR}/libcmd.a \
${TOP_LIBDIR}/util.a \
-lresolv \
-lpthread
JARFILE = jafs.jar
all: ${TOP_JLIBDIR} libjafs libjafsadm ${PACKAGE} all_jar
install: all ${DESTDIR}${libdir}/libjafs.so ${DESTDIR}${libdir}/libjafsadm.so ${PACKAGE} install_jar
if [ ! -e /usr/afswsp ]; then \
mkdir -p /usr/afswsp/; \
fi; \
if [ ! -e /usr/afswsp/etc ]; then \
mkdir -p /usr/afswsp/etc/; \
cp ./etc/CacheConfig /usr/afswsp/etc/; \
fi; \
if [ ! -e /usr/afswsp/log ]; then \
mkdir -p /usr/afswsp/log/; \
fi; \
if [ ! -e /usr/afswsp/cache ]; then \
mkdir -p /usr/afswsp/cache/; \
fi; \
if [ ! -L /usr/vice/etc/CellServDB ]; then \
ln -s /usr/vice/etc/CellServDB /usr/afswsp/etc/; \
fi; \
if [ ! -L /usr/vice/etc/ThisCell ]; then \
ln -s /usr/vice/etc/ThisCell /usr/afswsp/etc/; \
fi
clean:
${RM} -f ${PACKAGEDIR}*.class ${LIBJAFSADMDIR}*.o ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}*.h
setup: FORCE
if [ ! -e ./h ]; then \
ln -s /usr/include/sys h; \
fi;
${TOP_JLIBDIR}:
mkdir -p $@
FORCE: ;
############# Shared library ###############################
libjafs: setup
${RM} -f ${LIBJAFSADMDIR}Internal.o; \
export BUILD_TYPE=user; \
${MAKE} ${TOP_LIBDIR}/libjafs.so
libjafsadm:
${RM} -f ${LIBJAFSADMDIR}Internal.o; \
export BUILD_TYPE=admin; \
${MAKE} ${TOP_LIBDIR}/libjafsadm.so
${TOP_LIBDIR}/libjafs.so: ${LIBJAFS_OBJS}
${CC} ${CFLAGS} ${SHARED_FLAGS} -o $@ $^ ${LIBJAFS_LIBS}
${DESTDIR}${libdir}/libjafs.so: ${LIBJAFS_OBJS}192.168.13.10
${CC} ${CFLAGS} ${SHARED_FLAGS} -o $@ $^ ${LIBJAFS_LIBS}
${TOP_LIBDIR}/libjafsadm.so: ${LIBJAFSADM_OBJS}
${CC} ${CFLAGS} ${SHARED_FLAGS} -o $@ $^ ${LIBJAFSADM_LIBS}
${DESTDIR}${libdir}/libjafsadm.so: ${LIBJAFSADM_OBJS}
${CC} ${CFLAGS} ${SHARED_FLAGS} -o $@ $^ ${LIBJAFSADM_LIBS}
############## Object files ################################
${LIBJAFSADM_OBJS}: %.o: %.c
${CC} ${CFLAGS} ${OBJECT_FLAGS} -o $@ $<
############## C files #####################################
${CORRELATING_SOURCE_FILES}: ${LIBJAFSADMDIR}%.c: ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}%.h ${LIBJAFSADMDIR}Internal.h
${LIBJAFSADMDIR}AdminToken.c: ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}Token.h ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}Cell.h
${LIBJAFSADMDIR}Internal.c: ${LIBJAFSADMDIR}Internal.h
${LIBJAFSADMDIR}Version2.c: ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}VersionInfo.h ${LIBJAFSADMDIR}JAFS_Version.h
${LIBJAFSADMDIR}UserToken.c: ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}Token.h
############## Package javac section #########################
${PACKAGEDIR}%.class: ${PACKAGEDIR}%.java
${JAVAC} $<
############## Javah section ###############################
${JAVA_HEADERS}: ${C_NATIVE_PREFIX}%.h: ${PACKAGEDIR}%.class
${JAVAH} ${J_NATIVE_PREFIX}$*
############# JAR file #####################################
all_jar: clean_jar
cd ${ROOTPACKAGEDIR}; ${JAVA_HOME}/bin/jar -cMf ${TOP_JLIBDIR}/${JARFILE} *.properties ${RELPACKAGEDIR}*.class
install_jar: clean_jar
cd ${ROOTPACKAGEDIR}; ${JAVA_HOME}/bin/jar -cMf ${JAVA_HOME}/lib/${JARFILE} *.properties ${RELPACKAGEDIR}*.class
clean_jar:
${RM} -f ${TOP_JLIBDIR}/${JARFILE}

View File

@ -1,482 +0,0 @@
/*
* Copyright (c) 2001-2002 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "Internal.h"
#include "org_openafs_jafs_Partition.h"
#include <afs_vosAdmin.h>
#include <afs_AdminCommonErrors.h>
//// definitions in Internal.c //////////////////
extern jclass partitionCls;
extern jfieldID partition_nameField;
extern jfieldID partition_idField;
extern jfieldID partition_deviceNameField;
extern jfieldID partition_lockFileDescriptorField;
extern jfieldID partition_totalSpaceField;
extern jfieldID partition_totalFreeSpaceField;
extern jclass volumeCls;
extern jfieldID volume_cachedInfoField;
//////////////////////////////////////////////////////////
///// definition in jafs_Volume.c /////////////////
extern void fillVolumeInfo
( JNIEnv *env, jobject volume, vos_volumeEntry_t volEntry );
///////////////////////////////////////////////////
/**
* Extract the information from the given partition entry and populate the
* given object
*
* env the Java environment
* partition the Partition object to populate with the info
* partEntry the container of the partition's information
*/
void fillPartitionInfo
(JNIEnv *env, jobject partition, vos_partitionEntry_t partEntry)
{
jstring jdeviceName;
jstring jpartition;
jint id;
afs_status_t ast;
// get the class fields if need be
if( partitionCls == 0 ) {
internal_getPartitionClass( env, partition );
}
// fill name and id in case it's a blank object
jpartition = (*env)->NewStringUTF(env, partEntry.name);
// get the id
if( !vos_PartitionNameToId( partEntry.name, (int *) &id, &ast ) ) {
throwAFSException( env, ast );
return;
}
(*env)->SetObjectField(env, partition, partition_nameField, jpartition);
(*env)->SetIntField(env, partition, partition_idField, id);
jdeviceName = (*env)->NewStringUTF(env, partEntry.deviceName);
(*env)->SetObjectField(env, partition, partition_deviceNameField,
jdeviceName);
(*env)->SetIntField(env, partition, partition_lockFileDescriptorField,
partEntry.lockFileDescriptor);
(*env)->SetIntField(env, partition, partition_totalSpaceField,
partEntry.totalSpace);
(*env)->SetIntField(env, partition, partition_totalFreeSpaceField,
partEntry.totalFreeSpace);
}
/**
* Fills in the information fields of the provided Partition.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the partition belongs
* serverHandle the vos handle of the server on which the
* partition resides
* partition the numeric id of the partition for which to get the
* info
* jpartitionObject the Partition object in which to
* fill in the information
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Partition_getPartitionInfo
(JNIEnv *env, jclass cls, jlong cellHandle, jlong serverHandle,
jint partition, jobject jpartitionObject)
{
afs_status_t ast;
vos_partitionEntry_t partEntry;
// get the partition entry
if ( !vos_PartitionGet( (void *) cellHandle, (void *) serverHandle, NULL,
(unsigned int) partition, &partEntry, &ast ) ) {
throwAFSException( env, ast );
return;
}
fillPartitionInfo( env, jpartitionObject, partEntry );
}
/**
* Translates a partition name into a partition id
*
* env the Java environment
* cls the current Java class
* jname the name of the partition in question
* returns the id of the partition in question
*/
JNIEXPORT jint JNICALL
Java_org_openafs_jafs_Partition_translateNameToID
(JNIEnv *env, jclass cls, jstring jname)
{
afs_status_t ast;
jint id;
const char *name;
if( jname != NULL ) {
name = (*env)->GetStringUTFChars(env, jname, 0);
if( !name ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
name = NULL;
}
// get the id
if( !vos_PartitionNameToId( name, (unsigned int *) &id, &ast ) ) {
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
throwAFSException( env, ast );
return -1;
}
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
return id;
}
/**
* Translates a partition id into a partition name
*
* env the Java environment
* cls the current Java class
* id the id of the partition in question
* returns the name of the partition in question
*/
JNIEXPORT jstring JNICALL
Java_org_openafs_jafs_Partition_translateIDToName
(JNIEnv *env, jclass cls, jint id)
{
afs_status_t ast;
char *name = malloc( sizeof(char)*VOS_MAX_PARTITION_NAME_LEN);
jstring jname;
if( !name ) {
throwAFSException( env, JAFSADMNOMEM );
return NULL;
}
// get the name
if( !vos_PartitionIdToName( (unsigned int) id, name, &ast ) ) {
free(name);
throwAFSException( env, ast );
return NULL;
}
jname = (*env)->NewStringUTF(env, name);
free(name);
return jname;
}
/**
* Returns the total number of volumes hosted by this partition.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the partition belongs
* serverHandle the vos handle of the server to which the partition
* belongs
* partition the numeric id of the partition on which the volumes
* reside
* returns total number of volumes hosted by this partition
*/
JNIEXPORT jint JNICALL
Java_org_openafs_jafs_Partition_getVolumeCount
(JNIEnv *env, jclass cls, jlong cellHandle, jlong serverHandle, jint partition)
{
afs_status_t ast;
void *iterationId;
vos_volumeEntry_t volEntry;
int i = 0;
if( !vos_VolumeGetBegin( (void *) cellHandle, (void *) serverHandle, NULL,
(unsigned int) partition, &iterationId, &ast ) ) {
throwAFSException( env, ast );
return -1;
}
while ( vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) i++;
if( ast != ADMITERATORDONE ) {
throwAFSException( env, ast );
return -1;
}
return i;
}
/**
* Begin the process of getting the volumes on a partition. Returns
* an iteration ID to be used by subsequent calls to
* getVolumesNext and getVolumesDone.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the partition belongs
* serverHandle the vos handle of the server to which the partition
* belongs
* partition the numeric id of the partition on which the volumes
* reside
* returns an iteration ID
*/
JNIEXPORT jlong JNICALL
Java_org_openafs_jafs_Partition_getVolumesBegin
(JNIEnv *env, jclass cls, jlong cellHandle, jlong serverHandle, jint partition)
{
afs_status_t ast;
void *iterationId;
if( !vos_VolumeGetBegin( (void *) cellHandle, (void *) serverHandle, NULL,
(unsigned int) partition, &iterationId, &ast ) ) {
throwAFSException( env, ast );
return;
}
return (jlong) iterationId;
}
/**
* Begin the process of getting the volumes on a partition. Returns
* an iteration ID to be used by subsequent calls to
* getVolumesNext and getVolumesDone.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the partition belongs
* serverHandle the vos handle of the server to which the partition
* belongs
* partition the numeric id of the partition on which the volumes
* reside
* returns an iteration ID
*/
JNIEXPORT jlong JNICALL
Java_org_openafs_jafs_Partition_getVolumesBeginAt
(JNIEnv *env, jclass cls, jlong cellHandle, jlong serverHandle,
jint partition, jint index)
{
afs_status_t ast;
void *iterationId;
vos_volumeEntry_t volEntry;
int i;
if( !vos_VolumeGetBegin( (void *) cellHandle, (void *) serverHandle, NULL,
(unsigned int) partition, &iterationId, &ast ) ) {
throwAFSException( env, ast );
return;
}
for ( i = 1; i < index; i++) {
if( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) {
if( ast == ADMITERATORDONE ) {
return 0;
} else {
throwAFSException( env, ast );
return 0;
}
}
}
return (jlong) iterationId;
}
/**
* Returns the next volume of the partition. Returns null
* if there are no more volumes.
*
* env the Java environment
* cls the current Java class
* iterationId the iteration ID of this iteration
* returns the name of the next volume of the server
*/
JNIEXPORT jstring JNICALL
Java_org_openafs_jafs_Partition_getVolumesNextString
(JNIEnv *env, jclass cls, jlong iterationId)
{
afs_status_t ast;
jstring jvolume;
vos_volumeEntry_t volEntry;
if( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) {
if( ast == ADMITERATORDONE ) {
return NULL;
} else {
throwAFSException( env, ast );
return;
}
}
jvolume = (*env)->NewStringUTF(env, volEntry.name);
return jvolume;
}
/**
* Fills the next volume object of the partition. Returns 0 if there
* are no more volumes, != 0 otherwise.
*
* env the Java environment
* cls the current Java class
* iterationId the iteration ID of this iteration
* jvolumeObject the Volume object in which to fill the values
* of the next volume
* returns 0 if there are no more volumes, != 0 otherwise
*/
JNIEXPORT jint JNICALL
Java_org_openafs_jafs_Partition_getVolumesNext
(JNIEnv *env, jclass cls, jlong iterationId, jobject jvolumeObject)
{
afs_status_t ast;
jstring jvolume;
vos_volumeEntry_t volEntry;
if( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) {
if( ast == ADMITERATORDONE ) {
return 0;
} else {
throwAFSException( env, ast );
return 0;
}
}
fillVolumeInfo( env, jvolumeObject, volEntry );
// get the class fields if need be
if( volumeCls == 0 ) {
internal_getVolumeClass( env, jvolumeObject );
}
(*env)->SetBooleanField( env, jvolumeObject, volume_cachedInfoField, TRUE );
return 1;
}
/**
* Fills the next volume object of the partition. Returns 0 if there
* are no more volumes, != 0 otherwise.
*
* env the Java environment
* cls the current Java class
* iterationId the iteration ID of this iteration
* jvolumeObject the Volume object in which to fill the values of the
* next volume
* advanceCount the number of volumes to advance past
* returns 0 if there are no more volumes, != 0 otherwise
*/
JNIEXPORT jint JNICALL
Java_org_openafs_jafs_Partition_getVolumesAdvanceTo
(JNIEnv *env, jclass cls, jlong iterationId, jobject jvolumeObject,
jint advanceCount)
{
afs_status_t ast;
jstring jvolume;
vos_volumeEntry_t volEntry;
int i;
for ( i = 0; i < advanceCount; i++) {
if( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) {
if( ast == ADMITERATORDONE ) {
return 0;
} else {
throwAFSException( env, ast );
return 0;
}
}
}
fillVolumeInfo( env, jvolumeObject, volEntry );
// get the class fields if need be
if( volumeCls == 0 ) {
internal_getVolumeClass( env, jvolumeObject );
}
(*env)->SetBooleanField( env, jvolumeObject, volume_cachedInfoField, TRUE );
return 1;
}
/**
* Signals that the iteration is complete and will not be accessed anymore.
*
* env the Java environment
* cls the current Java class
* iterationId the iteration ID of this iteration
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Partition_getVolumesDone
(JNIEnv *env, jclass cls, jlong iterationId)
{
afs_status_t ast;
if( !vos_VolumeGetDone( (void *) iterationId, &ast ) ) {
throwAFSException( env, ast );
return;
}
}
// reclaim global memory being used by this portion
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Partition_reclaimPartitionMemory
(JNIEnv *env, jclass cls)
{
if( partitionCls ) {
(*env)->DeleteGlobalRef(env, partitionCls);
partitionCls = 0;
}
}

View File

@ -1,567 +0,0 @@
/*
* Copyright (c) 2001-2002 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "Internal.h"
#include "org_openafs_jafs_Process.h"
#include <afs_bosAdmin.h>
///// definitions in Internal.c ////////////////////
extern jclass processCls;
extern jfieldID process_nameField;
extern jfieldID process_typeField;
extern jfieldID process_stateField;
extern jfieldID process_goalField;
extern jfieldID process_startTimeField;
extern jfieldID process_numberStartsField;
extern jfieldID process_exitTimeField;
extern jfieldID process_exitErrorTimeField;
extern jfieldID process_errorCodeField;
extern jfieldID process_errorSignalField;
extern jfieldID process_stateOkField;
extern jfieldID process_stateTooManyErrorsField;
extern jfieldID process_stateBadFileAccessField;
//////////////////////////////////////////////////////////////////
/**
* Retrieve the information for the specified process and populate the
* given object
*
* env the Java environment
* serverHandle the bos handle of the server on which the process resides
* processName the name of the process for which to get the info
* process the Process object to populate with the info
*/
void getProcessInfoChar( JNIEnv *env, void *serverHandle,
const char *processName, jobject process ) {
afs_status_t ast;
bos_ProcessType_t type;
bos_ProcessInfo_t infoEntry;
bos_ProcessExecutionState_t state;
char *auxStatus;
// get class fields if need be
if( processCls == 0 ) {
internal_getProcessClass( env, process );
}
if( !bos_ProcessInfoGet( serverHandle, processName, &type,
&infoEntry, &ast ) ) {
throwAFSException( env, ast );
return;
}
// set type variable
switch( type ) {
case BOS_PROCESS_SIMPLE :
(*env)->SetIntField(env, process, process_typeField,
org_openafs_jafs_Process_SIMPLE_PROCESS);
break;
case BOS_PROCESS_FS :
(*env)->SetIntField(env, process, process_typeField,
org_openafs_jafs_Process_FS_PROCESS);
break;
case BOS_PROCESS_CRON :
(*env)->SetIntField(env, process, process_typeField,
org_openafs_jafs_Process_CRON_PROCESS);
break;
default:
throwAFSException( env, type );
return;
}
// set goal variable
switch( infoEntry.processGoal ) {
case BOS_PROCESS_STOPPED :
(*env)->SetIntField(env, process, process_goalField,
org_openafs_jafs_Process_STOPPED);
break;
case BOS_PROCESS_RUNNING :
(*env)->SetIntField(env, process, process_goalField,
org_openafs_jafs_Process_RUNNING);
break;
case BOS_PROCESS_STOPPING :
(*env)->SetIntField(env, process, process_goalField,
org_openafs_jafs_Process_STOPPING);
break;
case BOS_PROCESS_STARTING :
(*env)->SetIntField(env, process, process_goalField,
org_openafs_jafs_Process_STARTING);
break;
default:
throwAFSException( env, infoEntry.processGoal );
return;
}
// set state variable
auxStatus = malloc( sizeof(char)*BOS_MAX_NAME_LEN );
if( !auxStatus ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
if( !bos_ProcessExecutionStateGet( (void *) serverHandle, processName,
&state, auxStatus, &ast ) ) {
free( auxStatus );
throwAFSException( env, ast );
return;
}
free( auxStatus );
switch( state ) {
case BOS_PROCESS_STOPPED :
(*env)->SetIntField(env, process, process_stateField,
org_openafs_jafs_Process_STOPPED);
break;
case BOS_PROCESS_RUNNING :
(*env)->SetIntField(env, process, process_stateField,
org_openafs_jafs_Process_RUNNING);
break;
case BOS_PROCESS_STOPPING :
(*env)->SetIntField(env, process, process_stateField,
org_openafs_jafs_Process_STOPPING);
break;
case BOS_PROCESS_STARTING :
(*env)->SetIntField(env, process, process_stateField,
org_openafs_jafs_Process_STARTING);
break;
default:
throwAFSException( env, state );
return;
}
// set longs
(*env)->SetLongField(env, process, process_startTimeField,
infoEntry.processStartTime );
(*env)->SetLongField(env, process, process_numberStartsField,
infoEntry.numberProcessStarts );
(*env)->SetLongField(env, process, process_exitTimeField,
infoEntry.processExitTime );
(*env)->SetLongField(env, process, process_exitErrorTimeField,
infoEntry.processExitErrorTime );
(*env)->SetLongField(env, process, process_errorCodeField,
infoEntry.processErrorCode );
(*env)->SetLongField(env, process, process_errorSignalField,
infoEntry.processErrorSignal );
// set stateOk to true if no core dump
if( infoEntry.state & BOS_PROCESS_CORE_DUMPED ) {
(*env)->SetBooleanField(env, process, process_stateOkField, FALSE );
} else {
(*env)->SetBooleanField(env, process, process_stateOkField, TRUE );
}
// set stateTooManyErrors
if( infoEntry.state & BOS_PROCESS_TOO_MANY_ERRORS ) {
(*env)->SetBooleanField(env, process,
process_stateTooManyErrorsField, TRUE );
} else {
(*env)->SetBooleanField(env, process,
process_stateTooManyErrorsField, FALSE );
}
// set stateBadFileAccess
if( infoEntry.state & BOS_PROCESS_BAD_FILE_ACCESS ) {
(*env)->SetBooleanField(env, process,
process_stateBadFileAccessField, TRUE );
} else {
(*env)->SetBooleanField(env, process,
process_stateBadFileAccessField, FALSE );
}
}
/**
* Fills in the information fields of the provided Process.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the process belongs
* jname the instance name of the process for which to get
* the information
* process the Process object in which to fill
* in the information
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Process_getProcessInfo (JNIEnv *env, jclass cls,
jlong serverHandle,
jstring jname,
jobject process) {
const char *name;
if( jname != NULL ) {
name = (*env)->GetStringUTFChars(env, jname, 0);
if( !name ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
name = NULL;
}
getProcessInfoChar( env, (void *) serverHandle, name, process );
// set name in case blank object
if( name != NULL ) {
if( processCls == 0 ) {
internal_getProcessClass( env, process );
}
(*env)->SetObjectField(env, process, process_nameField, jname);
(*env)->ReleaseStringUTFChars(env, jname, name);
}
}
/**
* Creates a process on a server.
*
* env the Java environment
* cls the current Java class
* serverHandle the bos handle of the server to which the key will
* belong
* jname the instance name to give the process. See AFS
* documentation for a standard list of instance names
* jtype the type of process this will be.
* Acceptable values are:
* org_openafs_jafs_Process_SIMPLE_PROCESS
* org_openafs_jafs_Process_FS_PROCESS
* org_openafs_jafs_Process_CRON_PROCESS
* jpath the execution path process to create
* jcronTime a String representing the time a cron process is to
* be run. Acceptable formats are:
* for daily restarts: "23:10" or "11:10 pm"
* for weekly restarts: "sunday 11:10pm" or
* "sun 11:10pm"
* Can be null for non-cron processes.
* jnotifier the execution path to a notifier program that should
* be called when the process terminates. Can be
* null
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Process_create (JNIEnv *env, jclass cls,
jlong serverHandle, jstring jname,
jint jtype, jstring jpath,
jstring jcronTime,
jstring jnotifier) {
afs_status_t ast;
bos_ProcessType_t type;
const char *name;
const char *path;
const char *cronTime;
const char *notifier;
if( jname != NULL ) {
name = (*env)->GetStringUTFChars(env, jname, 0);
if( !name ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
name = NULL;
}
if( jpath != NULL ) {
path = (*env)->GetStringUTFChars(env, jpath, 0);
if( !path ) {
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
path = NULL;
}
switch( jtype ) {
case org_openafs_jafs_Process_SIMPLE_PROCESS:
type = BOS_PROCESS_SIMPLE;
break;
case org_openafs_jafs_Process_FS_PROCESS:
type = BOS_PROCESS_FS;
break;
case org_openafs_jafs_Process_CRON_PROCESS:
type = BOS_PROCESS_CRON;
break;
default:
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
if( path != NULL ) {
(*env)->ReleaseStringUTFChars(env, jpath, path);
}
throwAFSException( env, jtype );
return;
}
if( jcronTime != NULL ) {
cronTime = (*env)->GetStringUTFChars(env, jcronTime, 0);
if( !cronTime ) {
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
if( path != NULL ) {
(*env)->ReleaseStringUTFChars(env, jpath, path);
}
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
cronTime = NULL;
}
if( jnotifier != NULL ) {
notifier = (*env)->GetStringUTFChars(env, jnotifier, 0);
if( !notifier ) {
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
if( path != NULL ) {
(*env)->ReleaseStringUTFChars(env, jpath, path);
}
if( cronTime != NULL ) {
(*env)->ReleaseStringUTFChars(env, jcronTime, cronTime);
}
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
notifier = NULL;
}
if( !bos_ProcessCreate( (void *) serverHandle, name, type, path,
cronTime, notifier, &ast ) ) {
// release strings
if( cronTime != NULL ) {
(*env)->ReleaseStringUTFChars(env, jcronTime, cronTime);
}
if( notifier != NULL ) {
(*env)->ReleaseStringUTFChars(env, jnotifier, notifier);
}
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
if( path != NULL ) {
(*env)->ReleaseStringUTFChars(env, jpath, path);
}
throwAFSException( env, ast );
return;
}
// release strings
if( cronTime != NULL ) {
(*env)->ReleaseStringUTFChars(env, jcronTime, cronTime);
}
if( notifier != NULL ) {
(*env)->ReleaseStringUTFChars(env, jnotifier, notifier);
}
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
if( path != NULL ) {
(*env)->ReleaseStringUTFChars(env, jpath, path);
}
}
/**
* Removes a process from a server.
*
* env the Java environment
* cls the current Java class
* serverHandle the bos handle of the server to which the process
* belongs
* jname the name of the process to remove
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Process_delete (JNIEnv *env, jclass cls,
jlong serverHandle, jstring jname) {
afs_status_t ast;
const char *name;
if( jname != NULL ) {
name = (*env)->GetStringUTFChars(env, jname, 0);
if( !name ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
name = NULL;
}
if( !bos_ProcessDelete( (void *) serverHandle, name, &ast ) ) {
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
throwAFSException( env, ast );
return;
}
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
}
/**
* Stop this process.
*
* env the Java environment
* cls the current Java class
* serverHandle the bos handle of the server to which the process
* belongs
* jname the name of the process to stop
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Process_stop (JNIEnv *env, jclass cls,
jlong serverHandle, jstring jname) {
afs_status_t ast;
const char *name;
if( jname != NULL ) {
name = (*env)->GetStringUTFChars(env, jname, 0);
if( !name ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
name = NULL;
}
if( !bos_ProcessExecutionStateSet( (void *) serverHandle, name,
BOS_PROCESS_STOPPED, &ast ) ) {
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
throwAFSException( env, ast );
return;
}
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
}
/**
* Start this process.
*
* env the Java environment
* cls the current Java class
* serverHandle the bos handle of the server to which the process
* belongs
* jname the name of the process to start
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Process_start (JNIEnv *env, jclass cls,
jlong serverHandle, jstring jname) {
afs_status_t ast;
const char *name;
if( jname != NULL ) {
name = (*env)->GetStringUTFChars(env, jname, 0);
if( !name ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
name = NULL;
}
if( !bos_ProcessExecutionStateSet( (void *) serverHandle, name,
BOS_PROCESS_RUNNING, &ast ) ) {
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
throwAFSException( env, ast );
return;
}
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
}
/**
* Retart this process.
*
* env the Java environment
* cls the current Java class
* serverHandle the bos handle of the server to which the process
* belongs
* jname the name of the process to restart
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Process_restart (JNIEnv *env, jclass cls,
jlong serverHandle, jstring jname) {
afs_status_t ast;
const char *name;
if( jname != NULL ) {
name = (*env)->GetStringUTFChars(env, jname, 0);
if( !name ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
name = NULL;
}
if( !bos_ProcessRestart( (void *) serverHandle, name, &ast ) ) {
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
throwAFSException( env, ast );
return;
}
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
}
// reclaim global memory being used by this portion
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Process_reclaimProcessMemory (JNIEnv *env,
jclass cls) {
if( processCls ) {
(*env)->DeleteGlobalRef(env, processCls);
processCls = 0;
}
}

View File

@ -1,259 +0,0 @@
Java API for OpenAFS (JAFS) README
Current as of June 4, 2003
##########################################################################
# Copyright (c) 2001-2002 International Business Machines Corp. #
# All rights reserved. #
# #
# This software has been released under the terms of the IBM Public #
# License. For details, see the LICENSE file in the top-level source #
# directory or online at http://www.openafs.org/dl/license10.html #
# #
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS #
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR #
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR #
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, #
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, #
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR #
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF #
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING #
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS #
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #
##########################################################################
---------------------------------------------------------------------------
*
* INTRODUCTION
*
---------------------------------------------------------------------------
JAFS is an open source API designed to allow Java programmers the ability
to create applications for the administration or use of OpenAFS file systems.
It works by accessing libadmin and libuafs (administrative and user-level
libraries that come with OpenAFS) through JNI. It consists of a Java package
called org.openafs.jafs, and two shared libraries libjafsadm.so and libjafs.so.
---------------------------------------------------------------------------
*
* USE
*
---------------------------------------------------------------------------
There is a version of JAFS that has been compiled on Red Hat Linux 7.3,
and can be directly used without compilation. It was compiled using
OpenAFS 1.2.10a libraries (with a modified version of libjuafs.a). It
consists of a JAR file (jafs-1.2.10a.jar) and two shared libraries
(libjafsadm.so and libjafs.so). It was compiled using the
--enable-transarc-paths on compilation (for use with the OpenAFS RPMs),
gcc 2.96, and Java Classic VM version 1.4.1_02.
When you write Java code to use this API, import the
org.openafs.jafs package. During compilation of your Java code,
ensure one of the following conditions are met:
- Use the "-classpath" option to javac to specify the jafs.jar file.
- Change your $CLASSPATH environment variable to include the
jafs.jar file (e.g. export CLASSPATH=$CLASSPATH:jafs.jar
When running an application that uses JAFS, the shared libraries
need to be found by Java's library loader. The easiest way to
accomplish this is to copy these files into the /usr/local/lib/ directory,
or create symbolic links from that directory to the files. Alternatively,
the directory containing the libraries can also be added to the
LD_LIBRARY_PATH environment variable.
You also need to have an OpenAFS client set up on your machine
(preferably version 1.2.10a, but it should work for some past versions as well).
You can obtain the OpenAFS client and view installation documentation at
http://www.openafs.org (the RPMs are easiest to use for Linux). Also any
cells you plan to access through the API must have entries in your
client's CellServDB file (located in the /usr/vice/etc/ directory in most
setups).
This API is most effective when used with a cell that uses the kaserver
for authentication. It does not currently support alternative methods of
authentication such as Kerberos V.
If you have successfully set up your Linux 7.3 environment as described
above, you will be able to develop and execute applications that use
the JAFS API.
---------------------------------------------------------------------------
*
* BUILD
*
---------------------------------------------------------------------------
** DOWNLOAD SOURCE
The first step in compiling your own versions of the library and jar file
is to download the OpenAFS source code. Please follow the directions for
for the source you download:
** APPLY THE APPROPRIATE PATCH
You can apply the appropriate JAFS patch with the following command,
executed from the root directory of the download code
(i.e. openafs-1.2.10a/):
patch -p1 < xxx.diff
(where xxx.diff is one of the following patch files)
Use the patch respective to the source you are using:
* OpenAFS 1.2.6 Source (openafs-1.2.6-src.tar.gz)
OpenAFS 1.2.7 Source (openafs-1.2.7-src.tar.gz)
OpenAFS 1.2.8 Source (openafs-1.2.8-src.tar.gz)
jafs-1.2.6-8.diff
* OpenAFS 1.2.9 Source (openafs-1.2.9-src.tar.gz)
jafs-1.2.9.diff
* OpenAFS 1.2.10a Source (openafs-1.2.10a-src.tar.gz)
jafs-1.2.10a.diff
* Daily Snapshot / CVS (example: openafs-snap-2003-05-21.tar.gz)
jafs.diff
** RUN CONFIGURE
From the same directory, run the configure script as you normally would
to compile OpenAFS, but run it with a java-home argument so the script can
find your java distribution. For example:
./configure [other options] --java-home=/usr/java/jdk
NOTE: If the configure script is not within the root source directory,
then you will need to first run ./regen.sh to generate the
configure script. In this case you will need to manually
modify the JAFS Makefile by setting the JAVA_HOME variable
to your local system's JAVA_HOME. (i.e. /usr/java/jdk)
The configure script will ensure that this directory contains bin/ and lib/
subdirectories, and that there are /bin/javac and/bin/javah executables and
an include/jni.h file. If you don't supply a command line argument for the
java home, the script will look for it in environment variables: first in
$JAVA_HOME and then in $JDK_HOME. Also, note that if you have installed
(or are planning to install) OpenAFS by using the RPMs for Linux, you
should provide the --enable-transarc-paths configuration option. If you
get a "** Can't determine local cell name" error message, the most likely
reason is that you didn't supply this option.
** RUN MAKE
Finally, do a full build of OpenAFS by executing 'make' in the current
directory. After it finishes, you are ready to compile JAFS. Execute
'make jafs' from that same directory. Afterward, there will be
libjafsadm.so and libjafs.so in the lib/ directory, and a jafs.jar in the
jlib/ directory. These can be used according to the instructions in the
'USE' section of this document.
For additional make options, please refer to the next section "MAKE OPTIONS"
---------------------------------------------------------------------------
*
* MAKE OPTIONS
*
---------------------------------------------------------------------------
Additional make options are available by running 'make' from the
src/JAVA/libjafs directory; they are as follows:
make - Perform a full make of all Java classes, jar archive, and JNI
libraries
make acltest - Builds the ACL test program. Program usage is available by
simply invoking './acltest'
make clean - Delete all Java classes, Java API docs, test programs, and C
object files
make cleanc - Only delete test programs and C object files.
make clean_jar - Delete the Java archive library (jlib/jafs.jar)
make clean_libs - Delete both JNI shared libraries (lib/libjafs.so and
lib/libjafsadm.so)
make install - Performs a full make of all components and then installs all
necessary components to your local system. This option
prepares the required '/usr/afswsp/' directory for use by
the native library.
make javadocs - Generate Java API documents (in javadoc format). Docs are
saved to src/JAVA/javadocs
make jar - Builds the Java archive library (containing all Java classes)
make libjafs - Builds the user-space library (used for ACL and file access)
make libjafsadm - Builds the administrative library (used for all admin related
functions)
---------------------------------------------------------------------------
*
* DIRECTORIES, FILES, AND TEST PROGRAMS
*
---------------------------------------------------------------------------
src/JAVA/libjafs:
Within the src/JAVA/libjafs directory you will find a few items in addition
to the C source code and Makefiles. In particular, you will find 'acltest.c',
'buildinfo.pl', and a subdirectory 'etc'.
acltest.c - A test program that allows testing of the native libraries
ACL calls without going through Java.
*Usage information for this program is available by simply
invoking './acltest' without any parameters.
buildinfo.pl - A perl script that automatically updates the build information
every time the native libraries are compiled. Additionally,
it automatically increments the build number associate with
the native libraries (found in VersionInfo.h). It may also
be used to programatically query for build information.
*Usage information for this program is available by simply
invoking 'perl buildinfo.pl' without any parameters.
etc/ - A directory containing user-space configuration files. These
files are used for user-space initialization and cache
configuration and are copied to '/usr/afswsp/etc' if a
'make install' is issued.
src/JAVA/classes:
Within the src/JAVA/classes directory you will find the root of the Java
package, the error message catalog file, and a test program:
*.java - Java classes that comprise the test program.
adminTest - A script that invokes the Java console-based test program.
This program can be used to exercise all major API calls
from Java, thus testing JNI libraries as well as Java code.
*Usage information for this program is available via its
help menu: './adminTest help'
adminTest.properties
- Configuration file for the Admin test program (only contains
default cell name for administrator)
ErrorMessages.properties
- Error message catalog file used by the ErrorTable class. Note
that an additional message file can be generated that represents
a language other than english (refer to the ErrorTable API docs
for more information)
org/ - Root of the Java class package (package: org.openafs.jafs)
src/JAVA/javadocs:
This directory is dynamically generated when you issue a 'make javadocs' from
the src/JAVA/libjafs directory. It contains all Java API documentation
generated from the Java classes.
---------------------------------------------------------------------------
*
* MISC
*
---------------------------------------------------------------------------
If you'd like to edit the source code, you'll find the native C code in
the src/JAVA/libjafs directory, and the Java code in the
src/JAVA/classes/org/openafs/jafs/ directory. Please reference the
src/TechNotes-JavaAPI document for more information.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,325 +0,0 @@
/*
* Copyright (c) 2001-2002 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <afsconfig.h>
#include <afs/param.h>
#include "Internal.h"
#include "org_openafs_jafs_Token.h"
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <afs/vice.h>
#include <netinet/in.h>
#include <afs/venus.h>
#include <afs/afs_args.h>
/*#include <afs/afs_osi.h>
#include <afs/afs_usrops.h>*/
#include <pthread.h>
#ifdef DMALLOC
#include "dmalloc.h"
#endif
pthread_mutex_t jafs_init_lock;
extern pthread_mutex_t jafs_login_lock;
extern int readCacheParms(char *afsMountPoint, char *afsConfDir,
char *afsCacheDir, int *cacheBlocks,
int *cacheFiles, int *cacheStatEntries,
int *dCacheSize, int *vCacheSize, int *chunkSize,
int *closeSynch, int *debug, int *nDaemons,
int *cacheFlags, char *logFile);
/**
* Be carefull with the memory management:
*
* - For every GetStringUTFChars call the corresponding ReleaseStringUTFChars.
* - For every Get<type>ArrayElements call the corresponding
* Release<type>ArrayElements
* - For every malloc call the corresponding free.
*/
int osi_audit(void)
{
return 0;
}
/*JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_callDebugger
(JNIEnv *env, jobject obj)
{
fprintf(stderr, "callDebugger called\n");
__asm__("int $0x3");
}*/
/**
* Initialize the user space library.
*
* The user space client must be initialized prior to any
* user space related methods, including: klog, unlog, relog,
* and shutdown.
*
* env the Java environment
* cls the current Java class
*
* throws AFSException
*/
JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_initUserSpace
(JNIEnv *env, jclass cls)
{
char afsMountPoint[100], afsConfDir[100], afsCacheDir[100], logFile[100];
jfieldID fid;
int pagval;
/* Initialize each init parameter with its associated default value */
int cacheBlocks = 100000;
int cacheFiles = 12500;
int cacheStatEntries = 8192;
int dCacheSize = 11398;
int vCacheSize = 128;
int chunkSize = 0;
int closeSynch = 0;
int debug = 0;
int nDaemons = 3;
int cacheFlags = -1;
/* Initialize each init parameter with its associated default value */
strcpy(afsMountPoint, "/afs");
strcpy(afsConfDir, "/usr/afswsp/etc");
strcpy(afsCacheDir, "/usr/afswsp/cache");
strcpy(logFile, "/usr/afswsp/log/libjafs.log");
pthread_mutex_init(&jafs_init_lock, NULL);
pthread_mutex_lock(&jafs_init_lock);
readCacheParms(afsMountPoint, afsConfDir, afsCacheDir,
&cacheBlocks, &cacheFiles, &cacheStatEntries,
&dCacheSize, &vCacheSize, &chunkSize,
&closeSynch, &debug, &nDaemons, &cacheFlags,
logFile);
/* See cache.tune for configuration details */
if (debug) {
fprintf(stderr, "uafs_Init(\"init_native\", \"%s\", \"%s\", \"%s\"",
"%d, %d, %d,"
"%d, %d, %d,"
"%d, %d, %d, %d, \"%s\");\n",
afsMountPoint, afsConfDir, afsCacheDir,
cacheBlocks, cacheFiles, cacheStatEntries,
dCacheSize, vCacheSize, chunkSize,
closeSynch, debug, nDaemons, cacheFlags, logFile);
}
uafs_Init("init_native", afsMountPoint, afsConfDir, afsCacheDir,
cacheBlocks, cacheFiles, cacheStatEntries,
dCacheSize, vCacheSize, chunkSize,
closeSynch, debug, nDaemons, cacheFlags, logFile);
/* make the initial pag the unauthenticated pag */
afs_setpag();
uafs_unlog();
pagval = afs_getpag_val();
fid = (*env)->GetStaticFieldID(env, cls, "ANYUSER_PAG_ID", "I");
if (fid == 0) {
fprintf(stderr,
"UserToken::init(): GetFieldID (ANYUSER_PAG_ID) failed\n");
return;
}
(*env)->SetStaticIntField(env, cls, fid, pagval);
pthread_mutex_unlock(&jafs_init_lock);
}
/**
* Authenticates a user in kas, and binds that authentication
* to the current process.
*
* env the Java environment
* obj the current Java class
* loginUTF the login to authenticate (expected as username@cellname)
* passwordUTF the password of the login
* id the existing pag (or 0)
*
* returns the assigned pag
*
* throws AFSException
*/
JNIEXPORT jint JNICALL
Java_org_openafs_jafs_Token_klog (JNIEnv *env, jobject obj,
jstring jusername, jstring jpassword, jstring jcell, jint id)
{
char *username;
char *password;
char *cell;
char *reason;
jint rc = -1;
int code;
if( jcell != NULL ) {
cell = (char*) (*env)->GetStringUTFChars(env, jcell, 0);
if( !cell ) {
char *error = "UserToken::klog(): failed to get cell name\n";
fprintf(stderr, error);
throwMessageException( env, error );
return -1;
}
} else {
cell = NULL;
}
if( jusername != NULL ) {
username = (char*) (*env)->GetStringUTFChars(env, jusername, 0);
if( !username ) {
char *error = "UserToken::klog(): failed to get username\n";
(*env)->ReleaseStringUTFChars(env, jcell, cell);
fprintf(stderr, error);
throwMessageException( env, error );
return -1;
}
} else {
username = NULL;
}
if( jpassword != NULL ) {
password = (char*) (*env)->GetStringUTFChars(env, jpassword, 0);
if( !password ) {
char *error = "UserToken::klog(): failed to get password\n";
(*env)->ReleaseStringUTFChars(env, jcell, cell);
(*env)->ReleaseStringUTFChars(env, jusername, username);
fprintf(stderr, error);
throwMessageException( env, error );
return -1;
}
} else {
password = NULL;
}
if (id == 0) {
code = uafs_klog(username, cell, password, &reason);
} else {
/* Use existing PAG for this thread */
code = afs_setpag_val(id);
if (code != 0) code = 180492L; /* KABADARGUMENT */
if (!code) code = uafs_klog_nopag(username, cell, password, &reason);
}
if (code != 0) {
if( cell != NULL ) {
(*env)->ReleaseStringUTFChars(env, jcell, cell);
}
if( username != NULL ) {
(*env)->ReleaseStringUTFChars(env, jusername, username);
}
if( password != NULL ) {
(*env)->ReleaseStringUTFChars(env, jpassword, password);
}
fprintf(stderr, "UserToken::klog(): uafs_klog failed to cell %s: %s\n",
cell, reason);
fprintf(stderr, "code = %d\n", code);
throwAFSException( env, code );
}
/* Get the PAG we were assigned as the return value */
rc = afs_getpag_val();
/* clean up */
if( cell != NULL ) {
(*env)->ReleaseStringUTFChars(env, jcell, cell);
}
if( username != NULL ) {
(*env)->ReleaseStringUTFChars(env, jusername, username);
}
if( password != NULL ) {
(*env)->ReleaseStringUTFChars(env, jpassword, password);
}
/* return PAG ID */
return rc;
}
/**
* Authenticates a user in KAS by a previously acquired PAG ID, and binds
* that authentication to the current thread or native process.
*
* <P> This method does not require the user's username and password to
* fully authenticate their request. Rather it utilizes the user's PAG ID
* to recapture the user's existing credentials.
*
* env the Java environment
* obj the current Java class
* id User's current PAG (process authentication group) ID
*
* throws AFSException
*/
JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_relog
(JNIEnv *env, jobject obj, jint id)
{
int rc;
rc = afs_setpag_val(id);
if (rc != 0) {
throwAFSException( env, rc );
}
}
/**
* Authenticates a user in KAS, and binds that authentication
* to the current process.
*
* env the Java environment
* obj the current Java class
*
* throws AFSException
*/
JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_unlog
(JNIEnv *env, jobject obj)
{
int rc;
rc = uafs_unlog();
if (rc != 0) {
throwAFSException( env, rc );
}
}
/**
* Inform the native library that the application is
* shutting down and will be unloading.
*
* <p> The library will make a call informing the file server that it will
* no longer be available for callbacks.
*
* env the Java environment
* obj the current Java class
*
* throws AFSException
*/
JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_shutdown
(JNIEnv *env, jobject obj)
{
uafs_Shutdown();
}

View File

@ -1,14 +0,0 @@
#include "JAFS_Version.h"
#include "org_openafs_jafs_VersionInfo.h"
JNIEXPORT jstring JNICALL Java_org_openafs_jafs_VersionInfo_getVersionOfLibjafsadm
(JNIEnv *env, jobject obj)
{
return (*env)->NewStringUTF(env, VERSION_LIB_JAVA_OPENAFS);
}
JNIEXPORT jstring JNICALL Java_org_openafs_jafs_VersionInfo_getBuildInfoOfLibjafsadm
(JNIEnv *env, jobject obj)
{
return (*env)->NewStringUTF(env, cml_version_number);
}

View File

@ -1,14 +0,0 @@
#include "JAFS_Version.h"
#include "org_openafs_jafs_VersionInfo.h"
JNIEXPORT jstring JNICALL Java_org_openafs_jafs_VersionInfo_getVersionOfLibjafs
(JNIEnv *env, jobject obj)
{
return (*env)->NewStringUTF(env, VERSION_LIB_JAVA_OPENAFS);
}
JNIEXPORT jstring JNICALL Java_org_openafs_jafs_VersionInfo_getBuildInfoOfLibjafs
(JNIEnv *env, jobject obj)
{
return (*env)->NewStringUTF(env, cml_version_number);
}

View File

@ -1,901 +0,0 @@
/*
* Copyright (c) 2001-2002 International Business Machines Corp.
* All rights reserved.
*
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "Internal.h"
#include "org_openafs_jafs_Volume.h"
#include <afs_vosAdmin.h>
#include <afs_AdminCommonErrors.h>
//// definitions in Internal.c //////////////////
extern jclass volumeCls;
extern jfieldID volume_nameField;
extern jfieldID volume_idField;
extern jfieldID volume_readWriteIdField;
extern jfieldID volume_readOnlyIdField;
extern jfieldID volume_backupIdField;
extern jfieldID volume_creationDateField;
extern jfieldID volume_lastAccessDateField;
extern jfieldID volume_lastUpdateDateField;
extern jfieldID volume_lastBackupDateField;
extern jfieldID volume_copyCreationDateField;
extern jfieldID volume_accessesSinceMidnightField;
extern jfieldID volume_fileCountField;
extern jfieldID volume_maxQuotaField;
extern jfieldID volume_currentSizeField;
extern jfieldID volume_statusField;
extern jfieldID volume_dispositionField;
extern jfieldID volume_typeField;
//////////////////////////////////////////////////////////
/**
* Extract the information from the given volume entry and populate the
* given object
*
* env the Java environment
* volume the Volume object to populate with the info
* volEntry the container of the volume's information
*/
extern void fillVolumeInfo( JNIEnv *env, jobject volume,
vos_volumeEntry_t volEntry ) {
jstring jvolume;
// get the class fields if need be
if( volumeCls == 0 ) {
internal_getVolumeClass( env, volume );
}
// set name, just in case it was a completely blank object
jvolume = (*env)->NewStringUTF(env, volEntry.name);
(*env)->SetObjectField(env, volume, volume_nameField, jvolume);
(*env)->SetIntField(env, volume, volume_idField, volEntry.id);
(*env)->SetIntField(env, volume, volume_readWriteIdField,
volEntry.readWriteId);
(*env)->SetIntField(env, volume, volume_readOnlyIdField,
volEntry.readOnlyId);
(*env)->SetIntField(env, volume, volume_backupIdField, volEntry.backupId);
(*env)->SetLongField(env, volume, volume_creationDateField,
volEntry.creationDate);
(*env)->SetLongField(env, volume, volume_lastAccessDateField,
volEntry.lastAccessDate);
(*env)->SetLongField(env, volume, volume_lastUpdateDateField,
volEntry.lastUpdateDate);
(*env)->SetLongField(env, volume, volume_lastBackupDateField,
volEntry.lastBackupDate);
(*env)->SetLongField(env, volume, volume_copyCreationDateField,
volEntry.copyCreationDate);
(*env)->SetIntField(env, volume, volume_accessesSinceMidnightField,
volEntry.accessesSinceMidnight);
(*env)->SetIntField(env, volume, volume_fileCountField, volEntry.fileCount);
(*env)->SetIntField(env, volume, volume_maxQuotaField, volEntry.maxQuota);
(*env)->SetIntField(env, volume, volume_currentSizeField,
volEntry.currentSize);
// set status variable
switch( volEntry.status ) {
case VOS_OK :
(*env)->SetIntField(env, volume, volume_statusField,
org_openafs_jafs_Volume_VOLUME_OK);
break;
case VOS_SALVAGE :
(*env)->SetIntField(env, volume, volume_statusField,
org_openafs_jafs_Volume_VOLUME_SALVAGE);
break;
case VOS_NO_VNODE:
(*env)->SetIntField(env, volume, volume_statusField,
org_openafs_jafs_Volume_VOLUME_NO_VNODE);
break;
case VOS_NO_VOL:
(*env)->SetIntField(env, volume, volume_statusField,
org_openafs_jafs_Volume_VOLUME_NO_VOL);
break;
case VOS_VOL_EXISTS:
(*env)->SetIntField(env, volume, volume_statusField,
org_openafs_jafs_Volume_VOLUME_VOL_EXISTS);
break;
case VOS_NO_SERVICE:
(*env)->SetIntField(env, volume, volume_statusField,
org_openafs_jafs_Volume_VOLUME_NO_SERVICE);
break;
case VOS_OFFLINE:
(*env)->SetIntField(env, volume, volume_statusField,
org_openafs_jafs_Volume_VOLUME_OFFLINE);
break;
case VOS_ONLINE:
(*env)->SetIntField(env, volume, volume_statusField,
org_openafs_jafs_Volume_VOLUME_ONLINE);
break;
case VOS_DISK_FULL:
(*env)->SetIntField(env, volume, volume_statusField,
org_openafs_jafs_Volume_VOLUME_DISK_FULL);
break;
case VOS_OVER_QUOTA:
(*env)->SetIntField(env, volume, volume_statusField,
org_openafs_jafs_Volume_VOLUME_OVER_QUOTA);
break;
case VOS_BUSY:
(*env)->SetIntField(env, volume, volume_statusField,
org_openafs_jafs_Volume_VOLUME_BUSY);
break;
case VOS_MOVED:
(*env)->SetIntField(env, volume, volume_statusField,
org_openafs_jafs_Volume_VOLUME_MOVED);
break;
default:
throwAFSException( env, volEntry.status );
}
// set disposition variable
switch( volEntry.volumeDisposition ) {
case VOS_OK :
(*env)->SetIntField(env, volume, volume_dispositionField,
org_openafs_jafs_Volume_VOLUME_OK);
break;
case VOS_SALVAGE :
(*env)->SetIntField(env, volume, volume_dispositionField,
org_openafs_jafs_Volume_VOLUME_SALVAGE);
break;
case VOS_NO_VNODE:
(*env)->SetIntField(env, volume, volume_dispositionField,
org_openafs_jafs_Volume_VOLUME_NO_VNODE);
break;
case VOS_NO_VOL:
(*env)->SetIntField(env, volume, volume_dispositionField,
org_openafs_jafs_Volume_VOLUME_NO_VOL);
break;
case VOS_VOL_EXISTS:
(*env)->SetIntField(env, volume, volume_dispositionField,
org_openafs_jafs_Volume_VOLUME_VOL_EXISTS);
break;
case VOS_NO_SERVICE:
(*env)->SetIntField(env, volume, volume_dispositionField,
org_openafs_jafs_Volume_VOLUME_NO_SERVICE);
break;
case VOS_OFFLINE:
(*env)->SetIntField(env, volume, volume_dispositionField,
org_openafs_jafs_Volume_VOLUME_OFFLINE);
break;
case VOS_ONLINE:
(*env)->SetIntField(env, volume, volume_dispositionField,
org_openafs_jafs_Volume_VOLUME_ONLINE);
break;
case VOS_DISK_FULL:
(*env)->SetIntField(env, volume, volume_dispositionField,
org_openafs_jafs_Volume_VOLUME_DISK_FULL);
break;
case VOS_OVER_QUOTA:
(*env)->SetIntField(env, volume, volume_dispositionField,
org_openafs_jafs_Volume_VOLUME_OVER_QUOTA);
break;
case VOS_BUSY:
(*env)->SetIntField(env, volume, volume_dispositionField,
org_openafs_jafs_Volume_VOLUME_BUSY);
break;
case VOS_MOVED:
(*env)->SetIntField(env, volume, volume_dispositionField,
org_openafs_jafs_Volume_VOLUME_MOVED);
break;
default:
throwAFSException( env, volEntry.volumeDisposition );
}
// set type variable
switch( volEntry.type ) {
case VOS_READ_WRITE_VOLUME:
(*env)->SetIntField(env, volume, volume_typeField,
org_openafs_jafs_Volume_VOLUME_TYPE_READ_WRITE);
break;
case VOS_READ_ONLY_VOLUME:
(*env)->SetIntField(env, volume, volume_typeField,
org_openafs_jafs_Volume_VOLUME_TYPE_READ_ONLY);
break;
case VOS_BACKUP_VOLUME:
(*env)->SetIntField(env, volume, volume_typeField,
org_openafs_jafs_Volume_VOLUME_TYPE_BACKUP);
break;
default:
throwAFSException( env, volEntry.type );
}
}
/**
* Fills in the information fields of the provided Volume.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the volume belongs
* serverHandle the vos handle of the server on which the volume
* resides
* partition the numeric id of the partition on which the volume
* resides
* volId the numeric id of the volume for which to get the info
* jvolumeObject the Volume object in which to fill in
* the information
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Volume_getVolumeInfo (JNIEnv *env, jclass cls,
jlong cellHandle,
jlong serverHandle,
jint partition, jint volID,
jobject jvolumeObject) {
afs_status_t ast;
vos_volumeEntry_t volEntry;
// get the volume entry
if ( !vos_VolumeGet( (void *) cellHandle, (void *) serverHandle, NULL,
(unsigned int) partition, (unsigned int) volID,
&volEntry, &ast ) ) {
throwAFSException( env, ast );
return;
}
fillVolumeInfo( env, jvolumeObject, volEntry );
}
/**
* Creates a volume on a particular partition.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell in which to create the volume
* serverHandle the vos handle of the server on which to create
* the volume
* partition the numeric id of the partition on which to create
* the volume
* jvolName the name of the volume to create
* quota the amount of space (in KB) to set as this volume's quota
* returns the numeric ID assigned to the volume
*/
JNIEXPORT jint JNICALL
Java_org_openafs_jafs_Volume_create (JNIEnv *env, jclass cls,
jlong cellHandle, jlong serverHandle,
jint partition, jstring jvolName,
jint quota) {
afs_status_t ast;
const char *volName;
int id;
if( jvolName != NULL ) {
volName = (*env)->GetStringUTFChars(env, jvolName, 0);
if( !volName ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
volName = NULL;
}
if( !vos_VolumeCreate( (void *) cellHandle, (void *) serverHandle, NULL,
(unsigned int) partition, volName,
(unsigned int) quota, &id, &ast ) ) {
if( volName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jvolName, volName);
}
throwAFSException( env, ast );
return;
}
if( volName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jvolName, volName);
}
return (jint) id;
}
/**
* Deletes a volume from a particular partition.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell in which to delete the volume
* serverHandle the vos handle of the server from which to delete
* the volume
* partition the numeric id of the partition from which to delete
* the volume
* volId the numeric id of the volume to delete
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Volume_delete (JNIEnv *env, jclass cls,
jlong cellHandle, jlong serverHandle,
jint partition, jint volID) {
afs_status_t ast;
if( !vos_VolumeDelete( (void *) cellHandle, (void *) serverHandle, NULL,
(unsigned int) partition,
(unsigned int) volID, &ast ) ) {
throwAFSException( env, ast );
return;
}
}
/**
* Creates a backup volume for the specified regular volume.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the volume belongs
* volId the numeric id of the volume for which to create a backup
* volume
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Volume_createBackupVolume (JNIEnv *env, jclass cls,
jlong cellHandle,
jint volID) {
afs_status_t ast;
if( !vos_BackupVolumeCreate( (void *) cellHandle, NULL,
(unsigned int) volID, &ast ) ) {
throwAFSException( env, ast );
return;
}
}
/**
* Creates a read-only volume for the specified regular volume.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the volume belongs
* serverHandle the vos handle of the server on which the read-only
* volume is to reside
* partition the numeric id of the partition on which the read-only
* volume is to reside
* volId the numeric id of the volume for which to
* create a read-only volume
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Volume_createReadOnlyVolume (JNIEnv *env, jclass cls,
jlong cellHandle,
jlong serverHandle,
jint partition,
jint volID) {
afs_status_t ast;
if( !vos_VLDBReadOnlySiteCreate( (void *) cellHandle, (void *) serverHandle,
NULL, (unsigned int) partition,
(unsigned int) volID, &ast ) ) {
throwAFSException( env, ast );
return;
}
}
/**
* Deletes a read-only volume for the specified regular volume.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the volume belongs
* serverHandle the vos handle of the server on which the read-only
* volume residea
* partition the numeric id of the partition on which the read-only
* volume resides
* volId the numeric read-write id of the volume for which to
* delete the read-only volume
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Volume_deleteReadOnlyVolume (JNIEnv *env, jclass cls,
jlong cellHandle,
jlong serverHandle,
jint partition,
jint volID) {
afs_status_t ast;
if( !vos_VLDBReadOnlySiteDelete( (void *) cellHandle, (void *) serverHandle,
NULL, (unsigned int) partition,
(unsigned int) volID, &ast ) ) {
throwAFSException( env, ast );
return;
}
}
/**
* Changes the quota of the specified volume.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the volume belongs
* serverHandle the vos handle of the server on which the volume
* resides
* partition the numeric id of the partition on which the volume
* resides
* volId the numeric id of the volume for which to change the quota
* newQuota the new quota (in KB) to assign the volume
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Volume_changeQuota (JNIEnv *env, jclass cls,
jlong cellHandle,
jlong serverHandle,
jint partition, jint volID,
jint newQuota) {
afs_status_t ast;
if( !vos_VolumeQuotaChange( (void *) cellHandle, (void *) serverHandle,
NULL, (unsigned int) partition,
(unsigned int) volID, (unsigned int) newQuota,
&ast ) ) {
throwAFSException( env, ast );
return;
}
}
/**
* Move the specified volume to a different site.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the volume belongs
* fromServerHandle the vos handle of the server on which the volume
* currently resides
* fromPartition the numeric id of the partition on which the volume
* currently resides
* toServerHandle the vos handle of the server to which the volume
* should be moved
* toPartition the numeric id of the partition to which the volume
* should be moved
* volId the numeric id of the volume to move
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Volume_move
(JNIEnv *env, jclass cls, jlong cellHandle, jlong fromServerHandle,
jint fromPartition, jlong toServerHandle, jint toPartition, jint volID)
{
afs_status_t ast;
if( !vos_VolumeMove( (void *) cellHandle, NULL, (unsigned int) volID,
(void *) fromServerHandle, (unsigned int) fromPartition,
(void *) toServerHandle, (unsigned int) toPartition,
&ast ) ) {
throwAFSException( env, ast );
return;
}
}
/**
* Releases the specified volume that has readonly volume sites.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the volume belongs
* volId the numeric id of the volume to release
* forceComplete whether or not to force a complete release
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Volume_release
(JNIEnv *env, jclass cls, jlong cellHandle, jint volID, jboolean forceComplete)
{
afs_status_t ast;
vos_force_t force;
if( forceComplete ) {
force = VOS_FORCE;
} else {
force = VOS_NORMAL;
}
if( !vos_VolumeRelease( (void *) cellHandle, NULL, (unsigned int) volID,
force, &ast )) {
throwAFSException( env, ast );
return;
}
}
/**
* Dumps the specified volume to a file.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the volume belongs
* serverHandle the vos handle of the server on which the volume
* resides
* partition the numeric id of the partition on which the
* volume resides
* volId the numeric id of the volume to dump
* startTime files with a modification time >= to this time will
* be dumped
* jdumpFile the full path of the file to which to dump
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Volume_dump (JNIEnv *env, jclass cls,
jlong cellHandle, jlong serverHandle,
jint partition, jint volID,
jint startTime, jstring jdumpFile) {
afs_status_t ast;
const char *dumpFile;
if( jdumpFile != NULL ) {
dumpFile = (*env)->GetStringUTFChars(env, jdumpFile, 0);
if( !dumpFile ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
dumpFile = NULL;
}
if( !vos_VolumeDump( (void *) cellHandle, (void *) serverHandle, NULL,
(unsigned int *) &partition, (unsigned int) volID,
(unsigned int) startTime, dumpFile, &ast ) ) {
if( dumpFile != NULL ) {
(*env)->ReleaseStringUTFChars(env, jdumpFile, dumpFile);
}
throwAFSException( env, ast );
return;
}
if( dumpFile != NULL ) {
(*env)->ReleaseStringUTFChars(env, jdumpFile, dumpFile);
}
}
/**
* Restores the specified volume from a dump file.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the volume belongs
* serverHandle the vos handle of the server on which the volume is
* to reside
* partition the numeric id of the partition on which the volume is
* to reside
* volId the numeric id to assign the restored volume (can be 0)
* jvolName the name of the volume to restore as
* jdumpFile the full path of the dump file from which to restore
* incremental if true, restores an incremental dump over an existing
* volume (server and partition values must correctly
* indicate the current position of the existing volume),
* otherwise restores a full dump
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Volume_restore (JNIEnv *env, jclass cls,
jlong cellHandle, jlong serverHandle,
jint partition, jint volID,
jstring jvolName, jstring jdumpFile,
jboolean incremental) {
afs_status_t ast;
const char *volName;
const char *dumpFile;
int *volumeIDp;
vos_volumeRestoreType_t vrt;
if( jvolName != NULL ) {
volName = (*env)->GetStringUTFChars(env, jvolName, 0);
if( !volName ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
volName = NULL;
}
if( jdumpFile != NULL ) {
dumpFile = (*env)->GetStringUTFChars(env, jdumpFile, 0);
if( !dumpFile ) {
if( volName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jvolName, volName);
}
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
dumpFile = NULL;
}
if( volID == 0 ) {
volumeIDp = NULL;
} else {
volumeIDp = (int *) &volID;
}
if( incremental ) {
vrt = VOS_RESTORE_INCREMENTAL;
} else {
vrt = VOS_RESTORE_FULL;
}
if( !vos_VolumeRestore( (void *) cellHandle, (void *) serverHandle, NULL,
(unsigned int) partition, (unsigned int *) volumeIDp,
volName, dumpFile, vrt, &ast ) ) {
if( volName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jvolName, volName);
}
if( dumpFile != NULL ) {
(*env)->ReleaseStringUTFChars(env, jdumpFile, dumpFile);
}
throwAFSException( env, ast );
return;
}
if( dumpFile != NULL ) {
(*env)->ReleaseStringUTFChars(env, jdumpFile, dumpFile);
}
if( volName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jvolName, volName);
}
}
/**
* Renames the specified read-write volume.
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the volume belongs
* volId the numeric id of the read-write volume to rename
* jnewName the new name for the volume
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Volume_rename (JNIEnv *env, jclass cls,
jlong cellHandle, jint volID,
jstring jnewName) {
afs_status_t ast;
const char *newName;
if( jnewName != NULL ) {
newName = (*env)->GetStringUTFChars(env, jnewName, 0);
if( !newName ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
newName = NULL;
}
if( !vos_VolumeRename( (void *) cellHandle, NULL, (unsigned int) volID,
newName, &ast ) ) {
if( newName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jnewName, newName);
}
throwAFSException( env, ast );
return;
}
if( newName != NULL ) {
(*env)->ReleaseStringUTFChars(env, jnewName, newName);
}
}
/**
* "Mounts" the specified volume, bringing it online.
*
* env the Java environment
* cls the current Java class
* serverHandle the vos handle of the server on which the volume
* resides
* partition the numeric id of the partition on which the volume
* resides
* volId the numeric id of the volume to bring online
* sleepTime ? (not sure what this is yet, possibly a time to wait
* before brining it online)
* offline ? (not sure what this is either, probably the current
* status of the volume -- busy or offline)
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Volume_mount (JNIEnv *env, jclass cls,
jlong serverHandle, jint partition,
jint volID, jint sleepTime,
jboolean offline) {
afs_status_t ast;
vos_volumeOnlineType_t volumeStatus;
if( offline ) {
volumeStatus = VOS_ONLINE_OFFLINE;
} else {
volumeStatus = VOS_ONLINE_BUSY;
}
if( !vos_VolumeOnline( (void *) serverHandle, NULL, (unsigned int) partition,
(unsigned int) volID, (unsigned int) sleepTime,
volumeStatus, &ast ) ) {
throwAFSException( env, ast );
return;
}
}
/**
* "Unmounts" the specified volume, bringing it offline.
*
* env the Java environment
* cls the current Java class
* serverHandle the vos handle of the server on which the volume
* resides
* partition the numeric id of the partition on which the volume
* resides
* volId the numeric id of the volume to bring offline
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Volume_unmount (JNIEnv *env, jclass cls,
jlong serverHandle, jint partition,
jint volID) {
afs_status_t ast;
if( !vos_VolumeOffline( (void *) serverHandle, NULL,
(unsigned int) partition, (unsigned int) volID,
&ast ) ) {
throwAFSException( env, ast );
return;
}
}
/**
* Locks the VLDB entry specified volume
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell on which the volume resides
* volId the numeric id of the volume to lock
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Volume_lock (JNIEnv *env, jclass cls,
jlong cellHandle, jint volID ) {
afs_status_t ast;
if( !vos_VLDBEntryLock( (void *) cellHandle, NULL, (unsigned int) volID,
&ast ) ) {
throwAFSException( env, ast );
return;
}
}
/**
* Unlocks the VLDB entry of the specified volume
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell on which the volume resides
* volId the numeric id of the volume to unlock
*/
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Volume_unlock (JNIEnv *env, jclass cls,
jlong cellHandle, jint volID) {
afs_status_t ast;
if( !vos_VLDBEntryUnlock( (void *) cellHandle, NULL, (unsigned int) volID,
&ast ) ) {
throwAFSException( env, ast );
return;
}
}
/**
* Translates a volume name into a volume id
*
* env the Java environment
* cls the current Java class
* cellHandle the handle of the cell to which the volume belongs
* jname the name of the volume in question, cannot end in backup or
* readonly
* type the type of volume: read-write, read-only, or backup.
* Acceptable values are:
* org_openafs_jafs_Volume_VOLUME_TYPE_READ_WRITE
* org_openafs_jafs_Volume_VOLUME_TYPE_READ_ONLY
* org_openafs_jafs_Volume_VOLUME_TYPE_BACKUP
* returns the id of the volume in question
*/
JNIEXPORT jint JNICALL
Java_org_openafs_jafs_Volume_translateNameToID (JNIEnv *env, jclass cls,
jlong cellHandle,
jstring jname, jint type) {
afs_status_t ast;
const char *name;
vos_vldbEntry_t vldbEntry;
if( jname != NULL ) {
name = (*env)->GetStringUTFChars(env, jname, 0);
if( !name ) {
throwAFSException( env, JAFSADMNOMEM );
return;
}
} else {
name = NULL;
}
// get the id
if( !vos_VLDBGet( (void *) cellHandle, NULL, NULL, name,
&vldbEntry, &ast ) ) {
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
throwAFSException( env, ast );
return -1;
}
if( name != NULL ) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
if( type == org_openafs_jafs_Volume_VOLUME_TYPE_READ_WRITE ) {
return vldbEntry.volumeId[VOS_READ_WRITE_VOLUME];
} else if( type == org_openafs_jafs_Volume_VOLUME_TYPE_READ_ONLY ) {
return vldbEntry.volumeId[VOS_READ_ONLY_VOLUME];
} else {
return vldbEntry.volumeId[VOS_BACKUP_VOLUME];
}
}
// reclaim global memory being used by this portion
JNIEXPORT void JNICALL
Java_org_openafs_jafs_Volume_reclaimVolumeMemory (JNIEnv *env, jclass cls) {
if( volumeCls ) {
(*env)->DeleteGlobalRef(env, volumeCls);
volumeCls = 0;
}
}

View File

@ -1,16 +0,0 @@
MountPoint /afs
ConfDir /usr/afswsp/etc
CacheDir /usr/afswsp/cache
LogFile /usr/afswsp/log/libjafs.log
CacheBlocks 40000
CacheFiles 3000
CacheStatEntries 3000
DCacheSize 100
VCacheSize 1000
ChunkSize 0
CloseSynch 0
Debug 0
NDaemons 3
CacheFlags -1

View File

@ -1,16 +0,0 @@
MountPoint /afs
ConfDir /usr/afswsp/etc
CacheDir /usr/afswsp/cache
LogFile /usr/afswsp/log/libjafs.log
CacheBlocks 100000
CacheFiles 6000
CacheStatEntries 6000
DCacheSize 250
VCacheSize 2000
ChunkSize 0
CloseSynch 0
Debug 0
NDaemons 3
CacheFlags -1

View File

@ -1,16 +0,0 @@
MountPoint /afs
ConfDir /usr/afswsp/etc
CacheDir /usr/afswsp/cache
LogFile /usr/afswsp/log/libjafs.log
CacheBlocks 40000
CacheFiles 3000
CacheStatEntries 3000
DCacheSize 100
VCacheSize 1000
ChunkSize 0
CloseSynch 0
Debug 0
NDaemons 3
CacheFlags -1

View File

@ -167,7 +167,6 @@ longer actively maintained.
| directory | description | | directory | description |
| --------- | ----------- | | --------- | ----------- |
| afsweb | Authenticated AFS access for older versions of Apache | | afsweb | Authenticated AFS access for older versions of Apache |
| JAVA | Java API library for OpenAFS development |
| kauth | Obsolete Kerberos-4 server (`kaserver`) and related programs | | kauth | Obsolete Kerberos-4 server (`kaserver`) and related programs |
| log | Obsolete programs to show and forget Kerberos-4 tokens | | log | Obsolete programs to show and forget Kerberos-4 tokens |
| lwp | Lightweight user-level non-preemptive cooperative threading library | | lwp | Lightweight user-level non-preemptive cooperative threading library |

View File

@ -1,88 +0,0 @@
Java API (Jafs): Technical Notes
-----------------------------------------
Overview
--------
The Java API (Jafs) is a Java package with a shared library
written in C. It is meant for use by programmers who wish to develop
tools in Java for OpenAFS administration and use. This document briefly
outlines the architecture of Jafs.
Shared library
--------------
The source code for the shared library resides in the src/JAVA/libjafs
directory. See the JAFS_README file in that directory for information
on how to compile this package. The code is broken up logically into
files by the type of AFS object they relate to (i.e. cell, user, volume,
etc.), which closely mirrors the different classes of the Java package.
This library is built on top of the libadmin and libuafs libraries, and
mainly serves as a translation layer between the Java package and the
OpenAFS code. It is closely tied to the Java package, in that it often
accesses the actual Java objects by calls up through JNI, in order to
retrieve or populate member fields of those objects. Also, if an error
occurs in this code or in another C library, a Java exception is
constructed with the appropriate error code, and is thrown back to the
Java layer to be dealt with.
Java package
------------
The code for the org.openafs.jafs package resides in the
src/JAVA/org/openafs/jafs/ directory. It is broken into classes
in the same way that the OpenAFS file system breaks down into logical
components: Cell, User, Group, Server, Partition, Volume, Process, Key,
Token, ACL, and File. There are also classes for file input and
output streams, and specialized exception classes.
Publicly, the developer only has access to these objects and their
instance functions, which provide a solid, object-oriented view of
OpenAFS administration and use. The first thing a programmer would do to
use this package in his or her code would be to construct a Token object by
giving it a cell name, a user name, and a password for that user. From
there, the programmer could easily construct a Cell object and then list,
for example, all the servers in a cell, create a new user, move a volume to
a different partition, etc.
When one of these objects is constructed, it does not actually create
the corresponding component in OpenAFS. The object is supposed to
represent the object. If the programmer wants to actually create a
new user in OpenAFS, for example, he or she would construct a new User
object with the name of the user to create, and then explicitly call
the object's create method.
When an object first accesses information about itself from OpenAFS
by calling down through JNI to the shared library, it saves the
information and will return it to the application on subsequent
requests. This minimizes the overhead of expensive JNI calls. This
saved information can be updated to reflect the most current state of
OpenAFS by calling the objects refresh method.
There are usually two ways to list something: getting an array of the
names of the elements in the list, or getting an array of the actual
objects themselves. For example, the Cell object can provide the
programmer with an array of the names of all users in the cell, or
an array of actual User objects, with relevant member fields already set
to the correct values.
Almost every method in the package declares AFSException in its
throws clause. This is thrown from the shared library whenever an
error occurs, and contains an OpenAFS error code as a member. The
programmer is expected to deal with these exceptions however they see fit.
The native methods that act as the interface between the Java layer and
the shared library are declared protected, so they can be used directly
by developers who wish to subclass these classes for their applications
and possibly implement their own versions of the Java API calls.
Known Issues
------------
Some issues not yet dealt with in this API include:
- Alternative methods of authentication, other than Kaserver (i.e.
Kerberos V). There has been some discussion about how to abstract
the User object to be more general, but so far it has not been
implemented.
- Access to VLDB functionality such as listing VLDB entries and
zapping volumes.