mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 15:00:12 +00:00
java-jafs-update-20030619
FIXES 1565 updates to java jafs, make it work with new cell code.
This commit is contained in:
parent
43011a3a00
commit
af1a0ea039
@ -11,6 +11,26 @@ E1002 = Session has expired, please login again
|
||||
E1003 = Operation aborted
|
||||
E1004 = Operation was forced to abort
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# Internal JAFS Error Codes
|
||||
#-----------------------------------------------------------
|
||||
E1050 = Could not allocate memory.
|
||||
E1051 = Could not find specified Java class.
|
||||
E1052 = Could not find specified Java method.
|
||||
E1053 = Could not find specified Java field.
|
||||
E1054 = Invalid argument value, argument is NULL.
|
||||
E1055 = Username provided is NULL.
|
||||
E1056 = Password provided is NULL.
|
||||
E1057 = Group name provided is NULL.
|
||||
E1058 = Group owner provided is NULL.
|
||||
E1059 = Volume name provided is NULL.
|
||||
E1060 = Partition name provided is NULL.
|
||||
E1061 = Process name provided is NULL.
|
||||
E1062 = Server name provided is NULL.
|
||||
E1063 = Cell name provided is NULL.
|
||||
E1064 = Invalid path name provided, path is NULL.
|
||||
E1065 = Invalid ACL provided, string is NULL.
|
||||
|
||||
#-----------------------------------------------------------
|
||||
# Standard UNIX Error Codes
|
||||
#-----------------------------------------------------------
|
||||
|
@ -33,6 +33,8 @@ import java.util.StringTokenizer;
|
||||
* This class is an extension of the standard Java File class with file-based
|
||||
* manipulation methods overridden by integrated AFS native methods.
|
||||
*
|
||||
* @version 2.2, 03/24/2003 - Added new Delta ACL functionality and changes
|
||||
* from Stonehenge.
|
||||
* @version 2.0, 04/18/2001 - Completely revised class for efficiency.
|
||||
*/
|
||||
|
||||
@ -41,9 +43,23 @@ public class ACL implements Serializable, Comparable
|
||||
private ACL.Entry[] positiveEntries;
|
||||
private ACL.Entry[] negativeEntries;
|
||||
|
||||
private String path;
|
||||
private ACL.Entry[] positiveExpungeEntries;
|
||||
private ACL.Entry[] negativeExpungeEntries;
|
||||
|
||||
/**
|
||||
* Path for this ACL, if null then this ACL instance is most likely a
|
||||
* Delta ACL.
|
||||
*/
|
||||
private String path = null;
|
||||
|
||||
public ACL(String path) throws AFSException
|
||||
private ACL()
|
||||
{
|
||||
}
|
||||
public ACL( String path ) throws AFSException
|
||||
{
|
||||
this( path, true );
|
||||
}
|
||||
public ACL( String path, boolean init ) throws AFSException
|
||||
{
|
||||
int numberPositiveEntries = 0;
|
||||
int numberNegativeEntries = 0;
|
||||
@ -52,85 +68,562 @@ public class ACL implements Serializable, Comparable
|
||||
|
||||
this.path = path;
|
||||
|
||||
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;
|
||||
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[0];
|
||||
negativeEntries = new ACL.Entry[0];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns the total number of ACL entries, this is the sum of positive
|
||||
* and negative entries.
|
||||
*
|
||||
* @return Total number of ACL entries
|
||||
*/
|
||||
public int getEntryCount()
|
||||
{
|
||||
return positiveEntries.length + positiveEntries.length;
|
||||
return getPositiveEntryCount() + getNegativeEntryCount();
|
||||
}
|
||||
/**
|
||||
* Returns the path this ACL instance is bound to.
|
||||
*
|
||||
* @return Path for this ACL
|
||||
*/
|
||||
public String getPath()
|
||||
{
|
||||
return 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 setNegativeEntries(ACL.Entry[] entries) throws AFSException
|
||||
{
|
||||
this.negativeEntries = entries;
|
||||
setACLString(path, getFormattedString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the ACL to AFS, making all changes immediately effective.
|
||||
* This method requires an active connection to AFS.
|
||||
*/
|
||||
public void flush() throws AFSException
|
||||
{
|
||||
setACLString(path, getFormattedString());
|
||||
}
|
||||
|
||||
private ACL.Entry[] getNonEmptyEntries(ACL.Entry[] entries)
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* Positive ACL Methods */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Returns the number of positive ACL entries for this ACL instance.
|
||||
*
|
||||
* @return Positive ACL entry count
|
||||
*/
|
||||
public int getPositiveEntryCount()
|
||||
{
|
||||
ArrayList response = new ArrayList(entries.length);
|
||||
return ( positiveEntries == null ) ? 0 : positiveEntries.length;
|
||||
}
|
||||
/**
|
||||
* Returns all positive ACL entries for this ACL instance.
|
||||
*
|
||||
* @return All positive ACL entries
|
||||
*/
|
||||
public ACL.Entry[] getPositiveEntries()
|
||||
{
|
||||
return ( positiveEntries == null ) ? new ACL.Entry[0] : positiveEntries;
|
||||
}
|
||||
/**
|
||||
* Returns the positive ACL entry associated with the specified
|
||||
* user/group name.
|
||||
*
|
||||
* @param name Name of user/group for desired ACL entry.
|
||||
* @return Positive ACL entry
|
||||
* @see ACL.Entry#getUser()
|
||||
*/
|
||||
public Entry getPositiveEntry(String name)
|
||||
{
|
||||
int n = getPositiveEntryCount();
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (positiveEntries[i].getUser().equalsIgnoreCase(name)) {
|
||||
return positiveEntries[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Returns all positive ACL entries to be expunged; used in Delta ACLs.
|
||||
*
|
||||
* @return All positive ACL entries
|
||||
*/
|
||||
public ACL.Entry[] getPositiveExpungeEntries()
|
||||
{
|
||||
return ( positiveExpungeEntries == null ) ? new ACL.Entry[0] : positiveExpungeEntries;
|
||||
}
|
||||
/**
|
||||
* Returns <code>true</code> if this ACL contains the specified ACL entry.
|
||||
*
|
||||
* @param entry Positive ACL entry
|
||||
* @return <code>true</code> if the specified ACL entry is present;
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean containsPositiveEntry(Entry entry)
|
||||
{
|
||||
int n = getPositiveEntryCount();
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (positiveEntries[i].equals(entry)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Adds a single positive ACL entry to this ACL instance.
|
||||
*
|
||||
* @param entry ACL.Entry object to add
|
||||
*/
|
||||
public void addPositiveEntry( ACL.Entry entry ) throws AFSException
|
||||
{
|
||||
int n = getPositiveEntryCount();
|
||||
ACL.Entry[] e = new ACL.Entry[n + 1];
|
||||
if ( n > 0 ) System.arraycopy(positiveEntries, 0, e, 0, n);
|
||||
e[n] = entry;
|
||||
positiveEntries = e;
|
||||
update();
|
||||
}
|
||||
/**
|
||||
* Adds the provided list of positive ACL entries to this ACL instance.
|
||||
*
|
||||
* @param entries Array of ACL.Entry objects to add
|
||||
*/
|
||||
public void addPositiveEntries( ACL.Entry[] entries ) throws AFSException
|
||||
{
|
||||
int n = getPositiveEntryCount();
|
||||
ACL.Entry[] e = new ACL.Entry[n + entries.length];
|
||||
System.arraycopy(positiveEntries, 0, e, 0, n);
|
||||
System.arraycopy(entries,0,e,n,entries.length);
|
||||
positiveEntries = e;
|
||||
update();
|
||||
}
|
||||
/**
|
||||
* Sets the complete array of positive ACL entries to the provided
|
||||
* ACL entry list (<code>entries</code>) for this ACL instance.
|
||||
*
|
||||
* @param entries Array of ACL.Entry objects that represent this
|
||||
* ACL's positive entry list.
|
||||
*/
|
||||
public void setPositiveEntries( ACL.Entry[] entries ) throws AFSException
|
||||
{
|
||||
this.positiveEntries = entries;
|
||||
update();
|
||||
}
|
||||
/**
|
||||
* Add a positive ACL entry to the list of positive ACL entries to be
|
||||
* expunged; used in Delta ACLs.
|
||||
*
|
||||
* @param entry Positive ACL entries to be expunged.
|
||||
*/
|
||||
public void addPositiveExpungeEntry( ACL.Entry entry ) throws AFSException
|
||||
{
|
||||
int n = ( positiveExpungeEntries == null ) ? 0 : positiveExpungeEntries.length;
|
||||
ACL.Entry[] e = new ACL.Entry[n + 1];
|
||||
if ( n > 0 ) System.arraycopy(positiveExpungeEntries, 0, e, 0, n);
|
||||
e[n] = entry;
|
||||
positiveExpungeEntries = e;
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a single positive ACL entry from this ACL instance.
|
||||
*
|
||||
* @param entry ACL.Entry object to removed
|
||||
*/
|
||||
public void removePositiveEntry(Entry entry) throws AFSException
|
||||
{
|
||||
int n = getPositiveEntryCount();
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (!positiveEntries[i].equals(entry)) {
|
||||
list.add(positiveEntries[i]);
|
||||
}
|
||||
}
|
||||
|
||||
positiveEntries = (ACL.Entry[]) list.toArray(new ACL.Entry[list.size()]);
|
||||
update();
|
||||
}
|
||||
/**
|
||||
* Removes all positive ACL entries from this ACL instance.
|
||||
*/
|
||||
public void removeAllPositiveEntries() throws AFSException
|
||||
{
|
||||
positiveEntries = new Entry[0];
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* Negative ACL Methods */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Returns the number of negative ACL entries for this ACL instance.
|
||||
*
|
||||
* @return Negative ACL entry count
|
||||
*/
|
||||
public int getNegativeEntryCount()
|
||||
{
|
||||
return ( negativeEntries == null ) ? 0 : negativeEntries.length;
|
||||
}
|
||||
/**
|
||||
* Returns all negative ACL entries for this ACL instance.
|
||||
*
|
||||
* @return All negative ACL entries
|
||||
*/
|
||||
public ACL.Entry[] getNegativeEntries()
|
||||
{
|
||||
return ( negativeEntries == null ) ? new ACL.Entry[0] : negativeEntries;
|
||||
}
|
||||
/**
|
||||
* Returns the negative ACL entry associated with the specified
|
||||
* user/group name.
|
||||
*
|
||||
* @param name Name of user/group for desired ACL entry.
|
||||
* @return Negative ACL entry
|
||||
* @see ACL.Entry#getUser()
|
||||
*/
|
||||
public Entry getNegativeEntry(String name)
|
||||
{
|
||||
int n = getNegativeEntryCount();
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (negativeEntries[i].getUser().equalsIgnoreCase(name)) {
|
||||
return negativeEntries[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Returns all negative ACL entries to be expunged; used in Delta ACLs.
|
||||
*
|
||||
* @return All negative ACL entries to be expunged.
|
||||
*/
|
||||
public ACL.Entry[] getNegativeExpungeEntries()
|
||||
{
|
||||
return ( negativeExpungeEntries == null ) ? new ACL.Entry[0] : negativeExpungeEntries;
|
||||
}
|
||||
/**
|
||||
* Returns <code>true</code> if this ACL contains the specified ACL entry.
|
||||
*
|
||||
* @param entry Negative ACL entry
|
||||
* @return <code>true</code> if the specified ACL entry is present;
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean containsNegative(Entry entry)
|
||||
{
|
||||
int n = getNegativeEntryCount();
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (negativeEntries[i].equals(entry)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Adds a single negative ACL entry to this ACL instance.
|
||||
*
|
||||
* @param entry ACL.Entry object to add
|
||||
*/
|
||||
public void addNegativeEntry( ACL.Entry entry ) throws AFSException
|
||||
{
|
||||
int n = getNegativeEntryCount();
|
||||
ACL.Entry[] e = new ACL.Entry[n + 1];
|
||||
if ( n > 0 ) System.arraycopy(negativeEntries, 0, e, 0, n);
|
||||
e[n] = entry;
|
||||
negativeEntries = e;
|
||||
update();
|
||||
}
|
||||
/**
|
||||
* Adds the provided list of negative ACL entries to this ACL instance.
|
||||
*
|
||||
* @param entries Array of ACL.Entry objects to add
|
||||
*/
|
||||
public void addNegativeEntries( ACL.Entry[] entries ) throws AFSException
|
||||
{
|
||||
int n = getNegativeEntryCount();
|
||||
ACL.Entry[] e = new ACL.Entry[n + entries.length];
|
||||
System.arraycopy(negativeEntries, 0, e, 0, n);
|
||||
System.arraycopy(entries,0,e,n,entries.length);
|
||||
negativeEntries = e;
|
||||
update();
|
||||
}
|
||||
/**
|
||||
* Add a negative ACL entry to the list of negative ACL entries to be
|
||||
* expunged; used in Delta ACLs.
|
||||
*
|
||||
* @param entry Negative ACL entries to be expunged.
|
||||
*/
|
||||
public void addNegativeExpungeEntry( ACL.Entry entry ) throws AFSException
|
||||
{
|
||||
int n = ( negativeExpungeEntries == null ) ? 0 : negativeExpungeEntries.length;
|
||||
ACL.Entry[] e = new ACL.Entry[n + 1];
|
||||
if ( n > 0 ) System.arraycopy(negativeExpungeEntries, 0, e, 0, n);
|
||||
e[n] = entry;
|
||||
negativeExpungeEntries = e;
|
||||
update();
|
||||
}
|
||||
/**
|
||||
* Sets the complete array of negative ACL entries to the provided
|
||||
* ACL entry list (<code>entries</code>) for this ACL instance.
|
||||
*
|
||||
* @param entries Array of ACL.Entry objects that represent this
|
||||
* ACL's negative entry list.
|
||||
*/
|
||||
public void setNegativeEntries( ACL.Entry[] entries ) throws AFSException
|
||||
{
|
||||
this.negativeEntries = entries;
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a single negative ACL entry from this ACL instance.
|
||||
*
|
||||
* @param entry ACL.Entry object to removed
|
||||
*/
|
||||
public void removeNegativeEntry(Entry entry) throws AFSException
|
||||
{
|
||||
int n = getNegativeEntryCount();
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (!negativeEntries[i].equals(entry)) {
|
||||
list.add(negativeEntries[i]);
|
||||
}
|
||||
}
|
||||
|
||||
negativeEntries = (ACL.Entry[]) list.toArray(new ACL.Entry[list.size()]);
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all negative ACL entries from this ACL instance.
|
||||
*/
|
||||
public void removeAllNegativeEntries() throws AFSException
|
||||
{
|
||||
negativeEntries = new Entry[0];
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* Delta ACL Methods */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Returns a "Delta ACL", which is an ACL that represents only the difference
|
||||
* (delta) of two ACLs, relative to the current ACL instance by the provided
|
||||
* ACL specified by <code>acl</code>.
|
||||
*
|
||||
* <P> This ACL instance represents the base or reference object while the
|
||||
* provided ACL (<code>acl</code>) represents the object in question.
|
||||
* Therefore, if the provided ACL has an entry that differs from the base ACL,
|
||||
* then the resulting Delta ACL will contain that entry found in the provided
|
||||
* ACL; base ACL entries are never entered into the Delta ACL, but rather are
|
||||
* used solely for comparison.
|
||||
*
|
||||
* @param acl the ACL to compare this ACL instance to
|
||||
* @return Delta ACL by comparing this ACL instance with <code>acl</code>
|
||||
*/
|
||||
public ACL getDeltaACL( ACL acl ) throws AFSException
|
||||
{
|
||||
ACL delta = new ACL();
|
||||
int n = getPositiveEntryCount();
|
||||
|
||||
ACL.Entry[] pEntries = acl.getPositiveEntries();
|
||||
for ( int i = 0; i < pEntries.length; i++ )
|
||||
{
|
||||
boolean match = false;
|
||||
for ( int j = 0; j < n; j++ )
|
||||
{
|
||||
if ( pEntries[i].equals( positiveEntries[j] ) ) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !match ) delta.addPositiveEntry( pEntries[i] );
|
||||
}
|
||||
|
||||
// Check for positive entries that need to be expunged.
|
||||
n = getPositiveEntryCount();
|
||||
if ( n > pEntries.length ) {
|
||||
for ( int i = 0; i < n; i++ )
|
||||
{
|
||||
String eu = positiveEntries[i].getUser();
|
||||
boolean match = false;
|
||||
for ( int j = 0; j < pEntries.length; j++ )
|
||||
{
|
||||
if ( eu != null && eu.equals( pEntries[j].getUser() ) ) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !match ) delta.addPositiveExpungeEntry( positiveEntries[i] );
|
||||
}
|
||||
}
|
||||
|
||||
n = getNegativeEntryCount();
|
||||
ACL.Entry[] nEntries = acl.getNegativeEntries();
|
||||
for ( int i = 0; i < nEntries.length; i++ )
|
||||
{
|
||||
boolean match = false;
|
||||
for ( int j = 0; j < n; j++ )
|
||||
{
|
||||
if ( nEntries[i].equals( negativeEntries[j] ) ) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !match ) delta.addNegativeEntry( nEntries[i] );
|
||||
}
|
||||
|
||||
// Check for negative entries that need to be expunged.
|
||||
n = getNegativeEntryCount();
|
||||
if ( n > nEntries.length ) {
|
||||
for ( int i = 0; i < n; i++ )
|
||||
{
|
||||
String eu = negativeEntries[i].getUser();
|
||||
boolean match = false;
|
||||
for ( int j = 0; j < nEntries.length; j++ )
|
||||
{
|
||||
if ( eu != null && eu.equals( nEntries[j].getUser() ) ) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !match ) delta.addNegativeExpungeEntry( negativeEntries[i] );
|
||||
}
|
||||
}
|
||||
|
||||
return delta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the current ACL instance by replacing, adding, or deleting
|
||||
* ACL entries designated by the specified Delta ACL (<code>delta</code>).
|
||||
*
|
||||
* <P> If the provided Delta ACL has an entry that differs from this ACL
|
||||
* instance, then the ACL entry of the Delta ACL will be set.
|
||||
*
|
||||
* @param delta the Delta ACL to be applied to this ACL instance
|
||||
*/
|
||||
public void update( ACL delta ) throws AFSException
|
||||
{
|
||||
ArrayList pos = new ArrayList( this.getPositiveEntryCount() );
|
||||
ArrayList neg = new ArrayList( this.getNegativeEntryCount() );
|
||||
|
||||
ACL.Entry[] pExpungeEntries = delta.getPositiveExpungeEntries();
|
||||
ACL.Entry[] nExpungeEntries = delta.getNegativeExpungeEntries();
|
||||
|
||||
ACL.Entry[] pEntries = delta.getPositiveEntries();
|
||||
ACL.Entry[] nEntries = delta.getNegativeEntries();
|
||||
|
||||
// Delete positive expunge entries first
|
||||
int n = getPositiveEntryCount();
|
||||
for ( int i = 0; i < n; i++ )
|
||||
{
|
||||
boolean match = false;
|
||||
for ( int j = 0; j < pExpungeEntries.length; j++ )
|
||||
{
|
||||
if ( pExpungeEntries[j].equals( positiveEntries[i] ) ) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !match ) pos.add( positiveEntries[i] );
|
||||
}
|
||||
|
||||
// Now check for entries that need replacing
|
||||
for ( int i = 0; i < pEntries.length; i++ )
|
||||
{
|
||||
boolean match = false;
|
||||
String user = pEntries[i].getUser();
|
||||
for ( int j = 0; j < pos.size(); j++ )
|
||||
{
|
||||
if ( user.equals( ((ACL.Entry)pos.get(j)).getUser() ) ) {
|
||||
pos.set( j, pEntries[i] );
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !match ) pos.add( pEntries[i] );
|
||||
}
|
||||
setPositiveEntries( (ACL.Entry[])pos.toArray(new ACL.Entry[pos.size()]) );
|
||||
|
||||
// Delete negative expunge entries next
|
||||
n = getNegativeEntryCount();
|
||||
for ( int i = 0; i < n; i++ )
|
||||
{
|
||||
boolean match = false;
|
||||
for ( int j = 0; j < nExpungeEntries.length; j++ )
|
||||
{
|
||||
if ( nExpungeEntries[j].equals( negativeEntries[i] ) ) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !match ) neg.add( negativeEntries[i] );
|
||||
}
|
||||
|
||||
// Now check for entries that need replacing (negative)
|
||||
for ( int i = 0; i < nEntries.length; i++ )
|
||||
{
|
||||
boolean match = false;
|
||||
String user = nEntries[i].getUser();
|
||||
for ( int j = 0; j < neg.size(); j++ )
|
||||
{
|
||||
if ( user.equals( ((ACL.Entry)neg.get(j)).getUser() ) ) {
|
||||
neg.set( j, nEntries[i] );
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !match ) neg.add( nEntries[i] );
|
||||
}
|
||||
setNegativeEntries( (ACL.Entry[])neg.toArray(new ACL.Entry[neg.size()]) );
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* Private Methods */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Returns a resized array containing only valid (non-empty) ACL entries.
|
||||
*
|
||||
* @param entries Original array of entries, possibly containing empty
|
||||
* entries.
|
||||
* @return All non-empty ACL entries
|
||||
*/
|
||||
private ACL.Entry[] getNonEmptyEntries( ACL.Entry[] entries )
|
||||
{
|
||||
if ( entries == null ) return new ACL.Entry[0];
|
||||
ArrayList list = new ArrayList( entries.length );
|
||||
for (int i = 0; i < entries.length; i++)
|
||||
{
|
||||
boolean isNonEmpty = entries[i].canRead() ||
|
||||
@ -140,23 +633,28 @@ public class ACL implements Serializable, Comparable
|
||||
entries[i].canDelete() ||
|
||||
entries[i].canLock() ||
|
||||
entries[i].canAdmin();
|
||||
if (isNonEmpty) response.add(entries[i]);
|
||||
if (isNonEmpty) list.add(entries[i]);
|
||||
}
|
||||
if (response.size() == entries.length) return entries;
|
||||
return (ACL.Entry[])response.toArray(new ACL.Entry[response.size()]);
|
||||
if (list.size() == entries.length) return entries;
|
||||
return (ACL.Entry[])list.toArray(new ACL.Entry[list.size()]);
|
||||
}
|
||||
|
||||
private void entriesToString(ACL.Entry[] entries, StringBuffer response)
|
||||
private void entriesToString( ACL.Entry[] entries, StringBuffer buffer )
|
||||
{
|
||||
for (int i = 0; i < entries.length; i++)
|
||||
{
|
||||
this.entryToString((ACL.Entry)entries[i], response);
|
||||
this.entryToString((ACL.Entry)entries[i], buffer);
|
||||
}
|
||||
}
|
||||
|
||||
private void entryToString(ACL.Entry entry, StringBuffer response)
|
||||
private void entryToString( ACL.Entry entry, StringBuffer buffer )
|
||||
{
|
||||
response.append(entry.getUser() + '\t' + entry.getPermissionsMask() + '\n');
|
||||
buffer.append(entry.getUser() + '\t' + entry.getPermissionsMask() + '\n');
|
||||
}
|
||||
|
||||
private void update() throws AFSException
|
||||
{
|
||||
if ( path != null ) setACLString(path, getFormattedString());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -179,7 +677,10 @@ public class ACL implements Serializable, Comparable
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
/////////////// custom override methods ////////////////////
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* Custom Override Methods */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Compares two ACL objects respective to their paths and does not
|
||||
@ -234,9 +735,14 @@ public class ACL implements Serializable, Comparable
|
||||
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");
|
||||
StringBuffer out = new StringBuffer();
|
||||
if ( path == null ) {
|
||||
out.append("Delta ACL\n");
|
||||
} else {
|
||||
out.append("ACL for ");
|
||||
out.append(path);
|
||||
out.append("\n");
|
||||
}
|
||||
out.append("Positive Entries:\n");
|
||||
for (int i = 0; i < nonEmptyPos.length; i++) {
|
||||
out.append(" ");
|
||||
@ -250,10 +756,33 @@ public class ACL implements Serializable, Comparable
|
||||
}
|
||||
}
|
||||
|
||||
// Check to see if this is a Delta ACL
|
||||
if ( path == null ) {
|
||||
nonEmptyPos = this.getNonEmptyEntries(this.getPositiveExpungeEntries());
|
||||
nonEmptyNeg = this.getNonEmptyEntries(this.getNegativeExpungeEntries());
|
||||
|
||||
if (nonEmptyPos.length > 0) {
|
||||
out.append("Positive Entries to Delete:\n");
|
||||
for (int i = 0; i < nonEmptyPos.length; i++) {
|
||||
out.append(" ");
|
||||
out.append(nonEmptyPos[i].toString());
|
||||
}
|
||||
}
|
||||
if (nonEmptyNeg.length > 0) {
|
||||
out.append("Negative Entries to Delete:\n");
|
||||
for (int i = 0; i < nonEmptyNeg.length; i++) {
|
||||
out.append(" ");
|
||||
out.append(nonEmptyNeg[i].toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
/////////////// native methods ////////////////////
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* Native Methods */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Returns a formatted String representing the ACL for the specified path.
|
||||
@ -278,7 +807,7 @@ public class ACL implements Serializable, Comparable
|
||||
private native void setACLString(String path, String aclString) throws AFSException;
|
||||
|
||||
/*====================================================================*/
|
||||
/* INNER CLASSES */
|
||||
/* INNER CLASSES */
|
||||
/*====================================================================*/
|
||||
|
||||
/**
|
||||
@ -456,13 +985,13 @@ public class ACL implements Serializable, Comparable
|
||||
username = user;
|
||||
}
|
||||
/**
|
||||
* <IMG SRC="file.gif" ALT="File Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits <code>read</code> access.
|
||||
* <IMG SRC="file.gif" ALT="File Permission" WIDTH="16" HEIGHT="16" 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>
|
||||
* <p><FONT COLOR="666699"><IMG SRC="file.gif" ALT="File Permission" WIDTH="16" HEIGHT="16" 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.
|
||||
*
|
||||
@ -487,7 +1016,7 @@ public class ACL implements Serializable, Comparable
|
||||
r = flag;
|
||||
}
|
||||
/**
|
||||
* <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits lookup access.
|
||||
* <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="16" HEIGHT="16" 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.
|
||||
@ -507,7 +1036,7 @@ public class ACL implements Serializable, Comparable
|
||||
* 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>
|
||||
* <p><FONT COLOR="666699"><IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="16" HEIGHT="16" 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
|
||||
@ -534,13 +1063,13 @@ public class ACL implements Serializable, Comparable
|
||||
l = flag;
|
||||
}
|
||||
/**
|
||||
* <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits <code>insert</code> access.
|
||||
* <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="16" HEIGHT="16" 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>
|
||||
* <p><FONT COLOR="666699"><IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="16" HEIGHT="16" 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
|
||||
@ -567,13 +1096,13 @@ public class ACL implements Serializable, Comparable
|
||||
i = flag;
|
||||
}
|
||||
/**
|
||||
* <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits <code>delete</code> access.
|
||||
* <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="16" HEIGHT="16" 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>
|
||||
* <p><FONT COLOR="666699"><IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="16" HEIGHT="16" 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
|
||||
@ -600,12 +1129,12 @@ public class ACL implements Serializable, Comparable
|
||||
d = flag;
|
||||
}
|
||||
/**
|
||||
* <IMG SRC="file.gif" ALT="File Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits <code>write</code> access.
|
||||
* <IMG SRC="file.gif" ALT="File Permission" WIDTH="16" HEIGHT="16" 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>
|
||||
* <p><FONT COLOR="666699"><IMG SRC="file.gif" ALT="File Permission" WIDTH="16" HEIGHT="16" 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.
|
||||
*
|
||||
@ -630,12 +1159,12 @@ public class ACL implements Serializable, Comparable
|
||||
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.
|
||||
* <IMG SRC="file.gif" ALT="File Permission" WIDTH="16" HEIGHT="16" 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>
|
||||
* <p><FONT COLOR="666699"><IMG SRC="file.gif" ALT="File Permission" WIDTH="16" HEIGHT="16" 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.
|
||||
*
|
||||
@ -660,7 +1189,7 @@ public class ACL implements Serializable, Comparable
|
||||
k = flag;
|
||||
}
|
||||
/**
|
||||
* <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="15" HEIGHT="15" BORDER="0"> Tests whether the ACL permits <code>administer</code> access.
|
||||
* <IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="16" HEIGHT="16" 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
|
||||
@ -668,7 +1197,7 @@ public class ACL implements Serializable, Comparable
|
||||
* 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>
|
||||
* <p><FONT COLOR="666699"><IMG SRC="folder.gif" ALT="Directory Permission" WIDTH="16" HEIGHT="16" 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
|
||||
@ -732,12 +1261,3 @@ public class ACL implements Serializable, Comparable
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -187,18 +187,3 @@ public class AFSException extends Exception
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -185,18 +185,3 @@ public class AFSSecurityException extends SecurityException
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -270,7 +270,7 @@ public class Cell implements java.io.Serializable
|
||||
|
||||
/**
|
||||
* Sets all the information fields of this <code>Cell</code> object,
|
||||
* such as max group and user ids, to trheir most current values.
|
||||
* such as max group and user ids, to their most current values.
|
||||
*
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
@ -310,8 +310,13 @@ public class Cell implements java.io.Serializable
|
||||
System.err.println("ERROR Cell::refreshUsers():kas (User: "
|
||||
+ currUser.getName() + ") -> " + e.getMessage());
|
||||
authorized = false;
|
||||
//if (org.openafs.jafs.ErrorCodes.isPermissionDenied(e.getErrorCode()))
|
||||
//r = 0;
|
||||
if (org.openafs.jafs.ErrorTable.isPermissionDenied(e.getErrorCode())) {
|
||||
// Check to see if the user has failed more than 25 times,
|
||||
// if so it is most likely because they are not appropriately
|
||||
// authorized to list or examine users. May want to check for
|
||||
// KAS admin attribute.
|
||||
if ( r++ > 25 ) r = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
getKasUsersDone( iterationId );
|
||||
@ -334,8 +339,13 @@ public class Cell implements java.io.Serializable
|
||||
System.err.println("ERROR Cell::refreshUsers():pts (User: "
|
||||
+ currUser.getName() + ") -> " + e.getMessage());
|
||||
authorized = false;
|
||||
//if (org.openafs.jafs.ErrorCodes.isPermissionDenied(e.getErrorCode()))
|
||||
// r = 0;
|
||||
if (org.openafs.jafs.ErrorTable.isPermissionDenied(e.getErrorCode())) {
|
||||
// Check to see if the user has failed more than 25 times,
|
||||
// if so it is most likely because they are not appropriately
|
||||
// authorized to list or examine users. May want to check for
|
||||
// KAS admin attribute.
|
||||
if ( r++ > 25 ) r = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
getPtsUsersDone( iterationId );
|
||||
@ -400,8 +410,10 @@ public class Cell implements java.io.Serializable
|
||||
System.err.println("ERROR Cell::refreshGroups() (Group: "
|
||||
+ currGroup.getName() + ") -> " + e.getMessage());
|
||||
authorized = false;
|
||||
//if (org.openafs.jafs.ErrorCodes.isPermissionDenied(e.getErrorCode()))
|
||||
// r = 0;
|
||||
if (org.openafs.jafs.ErrorTable.isPermissionDenied(e.getErrorCode())) {
|
||||
if ( r++ > 25 ) r = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Cell.getGroupsDone( iterationId );
|
||||
@ -456,8 +468,9 @@ System.out.println("[Java] Cell::refreshServers() -> r: " + r);
|
||||
System.err.println("ERROR Cell::refreshServers() (Server: "
|
||||
+ currServer.getName() + ") -> " + e.getMessage());
|
||||
authorized = false;
|
||||
//if (e.getErrorCode() == org.openafs.jafs.ErrorCodes.PERMISSION_DENIED)
|
||||
// r = 0;
|
||||
if (org.openafs.jafs.ErrorTable.isPermissionDenied(e.getErrorCode())) {
|
||||
if ( r++ > 25 ) r = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
getServersDone( iterationId );
|
||||
@ -1864,11 +1877,3 @@ System.out.println("[Java] Cell::refreshServers() -> r: " + r);
|
||||
protected static native void closeCell( int cellHandle )
|
||||
throws AFSException;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1174,7 +1174,7 @@ public class Group implements PTSEntry, Serializable, Comparable
|
||||
* <code>null</code> if there are no more members.
|
||||
*
|
||||
* @param iterationId the iteration ID of this iteration
|
||||
* @see getGroupMembersBegin
|
||||
* @see #getGroupMembersBegin
|
||||
* @return the name of the next member
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
@ -1188,7 +1188,7 @@ public class Group implements PTSEntry, Serializable, Comparable
|
||||
* @param cellHandle the handle of the cell to which the users belong
|
||||
* @see Cell#getCellHandle
|
||||
* @param iterationId the iteration ID of this iteration
|
||||
* @see getGroupMembersBegin
|
||||
* @see #getGroupMembersBegin
|
||||
* @param theUser a User object to be populated with the values of the
|
||||
* next user
|
||||
* @return 0 if there are no more users, != 0 otherwise
|
||||
@ -1203,7 +1203,7 @@ public class Group implements PTSEntry, Serializable, Comparable
|
||||
* Signals that the iteration is complete and will not be accessed anymore.
|
||||
*
|
||||
* @param iterationId the iteration ID of this iteration
|
||||
* @see getGroupMembersBegin
|
||||
* @see #getGroupMembersBegin
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native void getGroupMembersDone( int iterationId )
|
||||
|
@ -457,11 +457,3 @@ public class Key implements Serializable, Comparable
|
||||
protected static native void reclaimKeyMemory();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1041,12 +1041,3 @@ public class Partition implements Serializable, Comparable
|
||||
*/
|
||||
protected static native void reclaimPartitionMemory();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1443,12 +1443,12 @@ public class Server implements Serializable, Comparable
|
||||
* methods as a means of identification.
|
||||
*
|
||||
* @param cellHandle a cell handle previously returned by
|
||||
* a call to {@link #getCellHandle}
|
||||
* a call to {@link Cell#getCellHandle}
|
||||
* @param serverName the name of the server for which to retrieve
|
||||
* a vos handle
|
||||
* @return a vos handle to the server
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
* @see #getCellHandle
|
||||
* @see Cell#getCellHandle
|
||||
*/
|
||||
protected static native int getVosServerHandle( int cellHandle,
|
||||
String serverName )
|
||||
@ -1469,12 +1469,12 @@ public class Server implements Serializable, Comparable
|
||||
* as a means of identification.
|
||||
*
|
||||
* @param cellHandle a cell handle previously returned by a call
|
||||
* to {@link #getCellHandle}
|
||||
* to {@link Cell#getCellHandle}
|
||||
* @param serverName the name of the server for which to retrieve
|
||||
* a bos handle
|
||||
* @return a bos handle to the server
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
* @see #getCellHandle
|
||||
* @see Cell#getCellHandle
|
||||
*/
|
||||
protected static native int getBosServerHandle( int cellHandle,
|
||||
String serverName )
|
||||
@ -1735,7 +1735,7 @@ public class Server implements Serializable, Comparable
|
||||
* are no more admins, != 0 otherwise.
|
||||
*
|
||||
* @param cellHandle the handle of the cell to which these admins belong
|
||||
* @see #getCellHandle
|
||||
* @see Cell#getCellHandle
|
||||
* @param iterationId the iteration ID of this iteration
|
||||
* @see #getBosAdminsBegin
|
||||
* @param theUser the user object in which to fill the values of this admin
|
||||
@ -1787,7 +1787,7 @@ public class Server implements Serializable, Comparable
|
||||
* Salvages (restores consistency to) a volume, partition, or server
|
||||
*
|
||||
* @param cellHandle the handle of the cell to which the volume belongs
|
||||
* @see #getCellHandle
|
||||
* @see Cell#getCellHandle
|
||||
* @param serverHandle the bos handle of the server on which the
|
||||
* volume resides
|
||||
* @see #getBosServerHandle
|
||||
@ -1831,7 +1831,7 @@ public class Server implements Serializable, Comparable
|
||||
* Synchronizes a particular server with the volume location database.
|
||||
*
|
||||
* @param cellHandle the handle of the cell to which the server belongs
|
||||
* @see #getCellHandle
|
||||
* @see Cell#getCellHandle
|
||||
* @param serverHandle the vos handle of the server
|
||||
* @see #getVosServerHandle
|
||||
* @param partition the id of the partition to sync, can be -1 to ignore
|
||||
@ -1846,7 +1846,7 @@ public class Server implements Serializable, Comparable
|
||||
* Synchronizes the volume location database with a particular server.
|
||||
*
|
||||
* @param cellHandle the handle of the cell to which the server belongs
|
||||
* @see #getCellHandle
|
||||
* @see Cell#getCellHandle
|
||||
* @param serverHandle the vos handle of the server
|
||||
* @see #getVosServerHandle
|
||||
* @param partition the id of the partition to sync, can be -1 to ignore
|
||||
|
@ -250,7 +250,6 @@ System.out.println(username + ", " + cellName);
|
||||
public void login() throws AFSException
|
||||
{
|
||||
this.tokenHandle = this.getToken(cellName, username, password);
|
||||
System.out.println("Token handle -> " + tokenHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1288,7 +1288,7 @@ public class User implements PTSEntry, Serializable, Comparable
|
||||
if( (value != this.USER_OWNER_ACCESS) &&
|
||||
(value != this.USER_ANYUSER_ACCESS) ) {
|
||||
throw new IllegalArgumentException( "Cannot set listStatus to "
|
||||
+ value );
|
||||
+ value );
|
||||
} else {
|
||||
listStatus = value;
|
||||
}
|
||||
@ -1313,7 +1313,7 @@ public class User implements PTSEntry, Serializable, Comparable
|
||||
if( (value != this.USER_OWNER_ACCESS) &&
|
||||
(value != this.USER_ANYUSER_ACCESS) ) {
|
||||
throw new IllegalArgumentException( "Cannot set listGroupsOwned to "
|
||||
+ value );
|
||||
+ value );
|
||||
} else {
|
||||
listGroupsOwned = value;
|
||||
}
|
||||
@ -1339,7 +1339,7 @@ public class User implements PTSEntry, Serializable, Comparable
|
||||
if( (value != this.USER_OWNER_ACCESS) &&
|
||||
(value != this.USER_ANYUSER_ACCESS) ) {
|
||||
throw new IllegalArgumentException( "Cannot set listMembership to "
|
||||
+ value );
|
||||
+ value );
|
||||
} else {
|
||||
listMembership = value;
|
||||
}
|
||||
@ -1724,7 +1724,7 @@ public class User implements PTSEntry, Serializable, Comparable
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native void create( int cellHandle, String userName,
|
||||
String password, int uid )
|
||||
String password, int uid )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1764,7 +1764,7 @@ public class User implements PTSEntry, Serializable, Comparable
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native void getUserInfo( int cellHandle, String name,
|
||||
User user )
|
||||
User user )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1779,7 +1779,7 @@ public class User implements PTSEntry, Serializable, Comparable
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native void setUserInfo( int cellHandle, String name,
|
||||
User theUser )
|
||||
User theUser )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1793,7 +1793,7 @@ public class User implements PTSEntry, Serializable, Comparable
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native void rename( int cellHandle, String oldName,
|
||||
String newName )
|
||||
String newName )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1806,7 +1806,7 @@ public class User implements PTSEntry, Serializable, Comparable
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native void setPassword( int cellHandle, String userName,
|
||||
String newPassword )
|
||||
String newPassword )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1828,7 +1828,7 @@ public class User implements PTSEntry, Serializable, Comparable
|
||||
* <code>null</code> if there are no more groups.
|
||||
*
|
||||
* @param iterationId the iteration ID of this iteration
|
||||
* @see getUserGroupsBegin
|
||||
* @see #getUserGroupsBegin
|
||||
* @return the name of the next group
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
@ -1842,22 +1842,22 @@ public class User implements PTSEntry, Serializable, Comparable
|
||||
* @param cellHandle the handle of the cell to which the users belong
|
||||
* @see Cell#getCellHandle
|
||||
* @param iterationId the iteration ID of this iteration
|
||||
* @see getUserGroupsBegin
|
||||
* @see #getUserGroupsBegin
|
||||
* @param theGroup a Group object to be populated with the values of the
|
||||
* next group
|
||||
* @return 0 if there are no more users, != 0 otherwise
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native int getUserGroupsNext( int cellHandle,
|
||||
int iterationId,
|
||||
Group theGroup )
|
||||
int iterationId,
|
||||
Group theGroup )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
* Signals that the iteration is complete and will not be accessed anymore.
|
||||
*
|
||||
* @param iterationId the iteration ID of this iteration
|
||||
* @see getUserGroupsBegin
|
||||
* @see #getUserGroupsBegin
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native void getUserGroupsDone( int iterationId )
|
||||
@ -1887,7 +1887,7 @@ public class User implements PTSEntry, Serializable, Comparable
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native int getGroupsOwnedBegin( int cellHandle,
|
||||
String name )
|
||||
String name )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1895,7 +1895,7 @@ public class User implements PTSEntry, Serializable, Comparable
|
||||
* if there are no more groups.
|
||||
*
|
||||
* @param iterationId the iteration ID of this iteration
|
||||
* @see getGroupsOwnedBegin
|
||||
* @see #getGroupsOwnedBegin
|
||||
* @return the name of the next group
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
@ -1909,22 +1909,22 @@ public class User implements PTSEntry, Serializable, Comparable
|
||||
* @param cellHandle the handle of the cell to which the users belong
|
||||
* @see Cell#getCellHandle
|
||||
* @param iterationId the iteration ID of this iteration
|
||||
* @see getGroupsOwnedBegin
|
||||
* @see #getGroupsOwnedBegin
|
||||
* @param theGroup a Group object to be populated with the values of the
|
||||
* next group
|
||||
* @return 0 if there are no more users, != 0 otherwise
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native int getGroupsOwnedNext( int cellHandle,
|
||||
int iterationId,
|
||||
Group theGroup )
|
||||
int iterationId,
|
||||
Group theGroup )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
* Signals that the iteration is complete and will not be accessed anymore.
|
||||
*
|
||||
* @param iterationId the iteration ID of this iteration
|
||||
* @see getGroupsOwnedBegin
|
||||
* @see #getGroupsOwnedBegin
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native void getGroupsOwnedDone( int iterationId )
|
||||
@ -1937,12 +1937,3 @@ public class User implements PTSEntry, Serializable, Comparable
|
||||
*/
|
||||
protected static native void reclaimUserMemory();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -315,7 +315,7 @@ public class Volume implements Serializable, Comparable
|
||||
protected void refreshInfo() throws AFSException
|
||||
{
|
||||
getVolumeInfo( cell.getCellHandle(), server.getVosHandle(),
|
||||
partition.getID(), getID(), this );
|
||||
partition.getID(), getID(), this );
|
||||
cachedInfo = true;
|
||||
creationDateCal = null;
|
||||
lastUpdateDateCal = null;
|
||||
@ -333,7 +333,7 @@ public class Volume implements Serializable, Comparable
|
||||
public void create( int quota ) throws AFSException
|
||||
{
|
||||
id = create( cell.getCellHandle(), server.getVosHandle(),
|
||||
partition.getID(), name, quota );
|
||||
partition.getID(), name, quota );
|
||||
maxQuota = quota;
|
||||
}
|
||||
|
||||
@ -366,7 +366,7 @@ public class Volume implements Serializable, Comparable
|
||||
{
|
||||
Server siteServer = sitePartition.getServer();
|
||||
createReadOnlyVolume( cell.getCellHandle(), siteServer.getVosHandle(),
|
||||
sitePartition.getID(), getID() );
|
||||
sitePartition.getID(), getID() );
|
||||
release( false );
|
||||
return new Volume( name + ".readonly", sitePartition );
|
||||
}
|
||||
@ -379,7 +379,7 @@ public class Volume implements Serializable, Comparable
|
||||
public void delete() throws AFSException
|
||||
{
|
||||
delete( cell.getCellHandle(), server.getVosHandle(), partition.getID(),
|
||||
getID() );
|
||||
getID() );
|
||||
name = null;
|
||||
creationDateCal = null;
|
||||
lastUpdateDateCal = null;
|
||||
@ -434,7 +434,7 @@ public class Volume implements Serializable, Comparable
|
||||
startTime = (int) ((dumpSince.getTime().getTime())/((long) 1000));
|
||||
}
|
||||
dump( cell.getCellHandle(), server.getVosHandle(), partition.getID(),
|
||||
getID(), startTime, fileName );
|
||||
getID(), startTime, fileName );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -485,7 +485,7 @@ public class Volume implements Serializable, Comparable
|
||||
throws AFSException
|
||||
{
|
||||
restore( cell.getCellHandle(), server.getVosHandle(), partition.getID(),
|
||||
id, name, fileName, incremental );
|
||||
id, name, fileName, incremental );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -541,7 +541,7 @@ public class Volume implements Serializable, Comparable
|
||||
{
|
||||
Server newServer = newPartition.getServer();
|
||||
move( cell.getCellHandle(), server.getVosHandle(), partition.getID(),
|
||||
newServer.getVosHandle(), newPartition.getID(), getID() );
|
||||
newServer.getVosHandle(), newPartition.getID(), getID() );
|
||||
|
||||
server = newServer;
|
||||
partition = newPartition;
|
||||
@ -568,8 +568,8 @@ public class Volume implements Serializable, Comparable
|
||||
public void salvage() throws AFSException
|
||||
{
|
||||
Server.salvage( cell.getCellHandle(), server.getBosHandle(),
|
||||
partition.getName(), name, 4, null, null, false, false,
|
||||
false, false, false, false );
|
||||
partition.getName(), name, 4, null, null, false, false,
|
||||
false, false, false, false );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -598,7 +598,7 @@ public class Volume implements Serializable, Comparable
|
||||
throws AFSException
|
||||
{
|
||||
Cell.createMountPoint( cell.getCellHandle(), directory, getName(),
|
||||
readWrite, false );
|
||||
readWrite, false );
|
||||
}
|
||||
|
||||
//////////////// accessors: ////////////////////////
|
||||
@ -847,7 +847,7 @@ public class Volume implements Serializable, Comparable
|
||||
if ( !cachedInfo ) refreshInfo();
|
||||
if (maxQuota == 0) {
|
||||
throw new AFSException("Volume with id " + id +
|
||||
" has an unlimited quota configured.", 0);
|
||||
" has an unlimited quota configured.", 0);
|
||||
}
|
||||
return maxQuota;
|
||||
}
|
||||
@ -954,7 +954,7 @@ public class Volume implements Serializable, Comparable
|
||||
public void setQuota( int quota ) throws AFSException
|
||||
{
|
||||
this.changeQuota( cell.getCellHandle(), server.getVosHandle(),
|
||||
partition.getID(), getID(), quota );
|
||||
partition.getID(), getID(), quota );
|
||||
maxQuota = quota;
|
||||
}
|
||||
|
||||
@ -1097,8 +1097,8 @@ public class Volume implements Serializable, Comparable
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native void getVolumeInfo( int cellHandle, int serverHandle,
|
||||
int partition, int volId,
|
||||
Volume theVolume )
|
||||
int partition, int volId,
|
||||
Volume theVolume )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1117,8 +1117,8 @@ public class Volume implements Serializable, Comparable
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native int create( int cellHandle, int serverHandle,
|
||||
int partition, String volumeName,
|
||||
int quota )
|
||||
int partition, String volumeName,
|
||||
int quota )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1135,7 +1135,7 @@ public class Volume implements Serializable, Comparable
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native void delete( int cellHandle, int serverHandle,
|
||||
int partition, int volId )
|
||||
int partition, int volId )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1162,8 +1162,8 @@ public class Volume implements Serializable, Comparable
|
||||
* @see Cell#getCellHandle
|
||||
*/
|
||||
protected static native void createReadOnlyVolume( int cellHandle,
|
||||
int serverHandle,
|
||||
int partition, int volId )
|
||||
int serverHandle,
|
||||
int partition, int volId )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1180,8 +1180,8 @@ public class Volume implements Serializable, Comparable
|
||||
* @see Cell#getCellHandle
|
||||
*/
|
||||
protected static native void deleteReadOnlyVolume( int cellHandle,
|
||||
int serverHandle,
|
||||
int partition, int volId )
|
||||
int serverHandle,
|
||||
int partition, int volId )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1199,8 +1199,8 @@ public class Volume implements Serializable, Comparable
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native void changeQuota( int cellHandle, int serverHandle,
|
||||
int partition, int volId,
|
||||
int newQuota )
|
||||
int partition, int volId,
|
||||
int newQuota )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1221,8 +1221,8 @@ public class Volume implements Serializable, Comparable
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native void move( int cellHandle, int fromServerHandle,
|
||||
int fromPartition, int toServerHandle,
|
||||
int toPartition, int volId )
|
||||
int fromPartition, int toServerHandle,
|
||||
int toPartition, int volId )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1234,7 +1234,7 @@ public class Volume implements Serializable, Comparable
|
||||
* @see Cell#getCellHandle
|
||||
*/
|
||||
protected static native void release( int cellHandle, int volId,
|
||||
boolean forceComplete )
|
||||
boolean forceComplete )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1254,8 +1254,8 @@ public class Volume implements Serializable, Comparable
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native void dump( int cellHandle, int serverHandle,
|
||||
int partition, int volId, int startTime,
|
||||
String dumpFile )
|
||||
int partition, int volId, int startTime,
|
||||
String dumpFile )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1278,9 +1278,9 @@ public class Volume implements Serializable, Comparable
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native void restore( int cellHandle, int serverHandle,
|
||||
int partition, int volId,
|
||||
String volumeName, String dumpFile,
|
||||
boolean incremental )
|
||||
int partition, int volId,
|
||||
String volumeName, String dumpFile,
|
||||
boolean incremental )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1293,7 +1293,7 @@ public class Volume implements Serializable, Comparable
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native void rename( int cellHandle, int volId,
|
||||
String newVolumeName )
|
||||
String newVolumeName )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1312,8 +1312,8 @@ public class Volume implements Serializable, Comparable
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native void mount( int serverHandle, int partition,
|
||||
int volId, int sleepTime,
|
||||
boolean offline )
|
||||
int volId, int sleepTime,
|
||||
boolean offline )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1328,7 +1328,7 @@ public class Volume implements Serializable, Comparable
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native void unmount( int serverHandle, int partition,
|
||||
int volId )
|
||||
int volId )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1369,7 +1369,7 @@ public class Volume implements Serializable, Comparable
|
||||
* @exception AFSException If an error occurs in the native code
|
||||
*/
|
||||
protected static native int translateNameToID( int cellHandle, String name,
|
||||
int volumeType )
|
||||
int volumeType )
|
||||
throws AFSException;
|
||||
|
||||
/**
|
||||
@ -1379,16 +1379,3 @@ public class Volume implements Serializable, Comparable
|
||||
*/
|
||||
protected static native void reclaimVolumeMemory();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -19,16 +19,31 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <afs/param.h>
|
||||
#include <afs/stds.h>
|
||||
|
||||
#include "Internal.h"
|
||||
#include "org_openafs_jafs_ACL.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <afs/vice.h>
|
||||
#include <afs/venus.h>
|
||||
#include <afs/afs_args.h>
|
||||
#include <afs/afs_osi.h>
|
||||
|
||||
/*
|
||||
#include <afs/afs_osi.h>
|
||||
*/
|
||||
|
||||
/* just for debugging */
|
||||
#define MAXHOSTS 13
|
||||
#define OMAXHOSTS 8
|
||||
#define MAXNAME 100
|
||||
#define MAXSIZE 2048
|
||||
#define MAXINSIZE 1300 /* pioctl complains if data is larger than this */
|
||||
#define VMSGSIZE 128 /* size of msg buf in volume hdr */
|
||||
|
||||
static char space[MAXSIZE];
|
||||
|
||||
#ifdef DMALLOC
|
||||
#include "dmalloc.h"
|
||||
@ -49,8 +64,11 @@ char* getACL(char *path)
|
||||
struct ViceIoctl params;
|
||||
char *buffer;
|
||||
|
||||
params.in = NULL;
|
||||
params.in_size = 0;
|
||||
params.in = NULL;
|
||||
params.out = NULL;
|
||||
params.in_size = 0;
|
||||
params.out_size = 0;
|
||||
|
||||
buffer = (char*) malloc(ACL_LEN);
|
||||
|
||||
if (!buffer) {
|
||||
@ -61,9 +79,9 @@ char* getACL(char *path)
|
||||
params.out = buffer;
|
||||
params.out_size = ACL_LEN;
|
||||
|
||||
if(call_syscall(AFSCALL_PIOCTL, path, VIOCGETAL, ¶ms, 1)) {
|
||||
if ( call_syscall(AFSCALL_PIOCTL, path, VIOCGETAL, ¶ms, 1, 0) ) {
|
||||
fprintf(stderr, "ERROR: ACL::getACL -> VIOCGETAL failed: %d\n", errno);
|
||||
free(buffer);
|
||||
free( buffer );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -88,7 +106,7 @@ jboolean setACL(char *path, char *aclString)
|
||||
params.out = NULL;
|
||||
params.out_size = 0;
|
||||
|
||||
if(call_syscall(AFSCALL_PIOCTL, path, VIOCSETAL, ¶ms, 1)) {
|
||||
if ( call_syscall(AFSCALL_PIOCTL, path, VIOCGETAL, ¶ms, 1) ) {
|
||||
fprintf(stderr, "ERROR: ACL::setACL -> VIOCSETAL failed: %d\n", errno);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
@ -112,21 +130,20 @@ JNIEXPORT jstring JNICALL Java_org_openafs_jafs_ACL_getACLString
|
||||
char *path, *acl;
|
||||
jstring answer = NULL;
|
||||
|
||||
path = (char*) (*env)->GetStringUTFChars(env, pathUTF, 0);
|
||||
|
||||
if(path == NULL) {
|
||||
path = getNativeString(env, pathUTF);
|
||||
if ( path == NULL ) {
|
||||
fprintf(stderr, "ERROR: ACL::getACLString ->");
|
||||
fprintf(stderr, "GetStringUTFChars() returned path = NULL\n");
|
||||
throwMessageException( env, "Path is NULL" );
|
||||
fprintf(stderr, "path = NULL\n");
|
||||
throwAFSException( env, JAFSNULLPATH );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
acl = getACL(path);
|
||||
(*env)->ReleaseStringUTFChars(env, pathUTF, path);
|
||||
acl = getACL( path );
|
||||
free( path );
|
||||
|
||||
if(acl) {
|
||||
answer = (*env) -> NewStringUTF(env, acl);
|
||||
free(acl);
|
||||
if ( acl ) {
|
||||
answer = (*env)->NewStringUTF( env, acl );
|
||||
free( acl );
|
||||
} else {
|
||||
throwAFSException( env, errno );
|
||||
}
|
||||
@ -151,42 +168,45 @@ JNIEXPORT void JNICALL Java_org_openafs_jafs_ACL_setACLString
|
||||
{
|
||||
char *path, *aclString;
|
||||
|
||||
if(!pathUTF) {
|
||||
if ( pathUTF == NULL ) {
|
||||
fprintf(stderr, "ERROR: ACL::setACLString -> pathUTF == NULL\n");
|
||||
throwMessageException( env, "pathUTF == NULL" );
|
||||
throwAFSException( env, JAFSNULLPATH );
|
||||
return;
|
||||
}
|
||||
|
||||
path = (char*) (*env)->GetStringUTFChars(env, pathUTF, 0);
|
||||
|
||||
if(path == NULL) {
|
||||
fprintf(stderr, "ERROR: ACL::setACLString -> failed to get path\n");
|
||||
throwMessageException( env, "Failed to get path" );
|
||||
return;
|
||||
}
|
||||
|
||||
if(!aclStringUTF) {
|
||||
if ( aclStringUTF == NULL ) {
|
||||
fprintf(stderr, "ERROR: ACL::setACLString -> aclStringUTF == NULL\n");
|
||||
throwMessageException( env, "aclStringUTF == NULL" );
|
||||
throwAFSException( env, JAFSNULLACL );
|
||||
return;
|
||||
}
|
||||
|
||||
aclString = (char*) (*env)->GetStringUTFChars(env, aclStringUTF, 0);
|
||||
/* 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(aclString == NULL) {
|
||||
/* aclString = (char*) (*env)->GetStringUTFChars(env, aclStringUTF, 0); */
|
||||
aclString = getNativeString( env, aclStringUTF );
|
||||
if ( aclString == NULL ) {
|
||||
free( path );
|
||||
fprintf(stderr, "ERROR: ACL::setACLString -> failed to get aclString\n");
|
||||
(*env)->ReleaseStringUTFChars(env, pathUTF, path);
|
||||
throwMessageException( env, "aclString == NULL" );
|
||||
throwMessageException( env, "Failed to get ACL string." );
|
||||
return;
|
||||
}
|
||||
|
||||
if (!setACL(path, aclString)) {
|
||||
if ( !setACL(path, aclString) ) {
|
||||
throwAFSException( env, errno );
|
||||
}
|
||||
|
||||
/* Clean up */
|
||||
free( path );
|
||||
free( aclString );
|
||||
|
||||
/*
|
||||
(*env)->ReleaseStringUTFChars(env, pathUTF, path);
|
||||
(*env)->ReleaseStringUTFChars(env, aclStringUTF, aclString);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -42,7 +42,7 @@ JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Token_initializeAdminClient(JNIEnv *env, jclass cls)
|
||||
{
|
||||
afs_status_t ast;
|
||||
if( !afsclient_Init( &ast ) ) {
|
||||
if ( !afsclient_Init( &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
@ -66,67 +66,59 @@ Java_org_openafs_jafs_Token_getToken
|
||||
jstring jpassword)
|
||||
{
|
||||
afs_status_t ast;
|
||||
const char *cellName;
|
||||
const char *userName;
|
||||
const char *password;
|
||||
char *cellName;
|
||||
char *userName;
|
||||
char *password;
|
||||
void *tokenHandle;
|
||||
int rc;
|
||||
|
||||
// convert java strings
|
||||
if( jcellName != NULL ) {
|
||||
cellName = (*env)->GetStringUTFChars(env, jcellName, 0);
|
||||
if( !cellName ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return 0;
|
||||
}
|
||||
if ( jcellName != NULL ) {
|
||||
cellName = getNativeString(env, jcellName);
|
||||
if ( !cellName ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
cellName = NULL;
|
||||
cellName = NULL;
|
||||
}
|
||||
if( juserName != NULL ) {
|
||||
userName = (*env)->GetStringUTFChars(env, juserName, 0);
|
||||
if( !userName ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( juserName != NULL ) {
|
||||
userName = getNativeString(env, juserName);
|
||||
if ( !userName ) {
|
||||
if ( cellName != NULL ) free( cellName );
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
userName = NULL;
|
||||
if ( cellName != NULL ) free( cellName );
|
||||
throwAFSException( env, JAFSNULLUSER );
|
||||
return 0;
|
||||
}
|
||||
if( jpassword != NULL ) {
|
||||
password = (*env)->GetStringUTFChars(env, jpassword, 0);
|
||||
if( !password ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( jpassword != NULL ) {
|
||||
password = getNativeString(env, jpassword);
|
||||
if ( !password ) {
|
||||
if ( cellName != NULL ) free( cellName );
|
||||
free( userName );
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
password = NULL;
|
||||
if ( cellName != NULL ) free( cellName );
|
||||
free( userName );
|
||||
throwAFSException( env, JAFSNULLPASS );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( !(afsclient_TokenGetNew( cellName, userName, password, &tokenHandle,
|
||||
&ast) ) ) {
|
||||
// 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;
|
||||
&ast) ) ) {
|
||||
throwAFSException( env, ast );
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
if ( cellName != NULL ) free( cellName );
|
||||
free( userName );
|
||||
free( password );
|
||||
|
||||
return (jint) tokenHandle;
|
||||
}
|
||||
@ -142,12 +134,12 @@ JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Token_close
|
||||
(JNIEnv *env, jobject obj, jint tokenHandle)
|
||||
{
|
||||
afs_status_t ast;
|
||||
afs_status_t ast;
|
||||
|
||||
if( !afsclient_TokenClose( (void *) tokenHandle, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
if ( !afsclient_TokenClose( (void *) tokenHandle, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -166,31 +158,27 @@ Java_org_openafs_jafs_Cell_getCellHandle
|
||||
(JNIEnv *env, jobject obj, jstring jcellName, jint tokenHandle)
|
||||
{
|
||||
afs_status_t ast;
|
||||
const char *cellName;
|
||||
char *cellName;
|
||||
void *cellHandle;
|
||||
|
||||
if( jcellName != NULL ) {
|
||||
cellName = (*env)->GetStringUTFChars(env, jcellName, 0);
|
||||
if( !cellName ) {
|
||||
if ( jcellName != NULL ) {
|
||||
cellName = getNativeString(env, jcellName);
|
||||
if ( !cellName ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
cellName = NULL;
|
||||
throwAFSException( env, JAFSNULLCELL );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( !afsclient_CellOpen( cellName, (void *) tokenHandle,
|
||||
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);
|
||||
}
|
||||
free( cellName );
|
||||
|
||||
return (jint) cellHandle;
|
||||
}
|
||||
|
||||
@ -202,17 +190,15 @@ Java_org_openafs_jafs_Cell_getCellHandle
|
||||
* cellHandle the cell handle to close
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Cell_closeCell (JNIEnv *env, jobject obj,
|
||||
jint cellHandle)
|
||||
Java_org_openafs_jafs_Cell_closeCell
|
||||
(JNIEnv *env, jobject obj, jint cellHandle)
|
||||
{
|
||||
afs_status_t ast;
|
||||
|
||||
afs_status_t ast;
|
||||
|
||||
if( !afsclient_CellClose( (void *) cellHandle, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !afsclient_CellClose( (void *) cellHandle, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -234,32 +220,26 @@ Java_org_openafs_jafs_Server_getVosServerHandle
|
||||
{
|
||||
afs_status_t ast;
|
||||
void *serverHandle;
|
||||
// convert java string
|
||||
const char *serverName;
|
||||
char *serverName;
|
||||
|
||||
if( jserverName != NULL ) {
|
||||
serverName = (*env)->GetStringUTFChars(env, jserverName, 0);
|
||||
if( !serverName ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
if ( jserverName != NULL ) {
|
||||
serverName = getNativeString(env, jserverName);
|
||||
if ( !serverName ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
serverName = NULL;
|
||||
throwAFSException( env, JAFSNULLSERVER );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( !vos_ServerOpen( (void *) cellHandle, serverName,
|
||||
(void **) &serverHandle, &ast ) ) {
|
||||
if( serverName != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jserverName, serverName);
|
||||
}
|
||||
throwAFSException( env, ast );
|
||||
return 0;
|
||||
if ( !vos_ServerOpen( (void *) cellHandle, serverName,
|
||||
(void **) &serverHandle, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
}
|
||||
|
||||
// release converted string
|
||||
if( serverName != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jserverName, serverName);
|
||||
}
|
||||
free( serverName );
|
||||
|
||||
return (jint) serverHandle;
|
||||
}
|
||||
@ -275,12 +255,12 @@ JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Server_closeVosServerHandle
|
||||
(JNIEnv *env, jobject obj, jint vosServerHandle)
|
||||
{
|
||||
afs_status_t ast;
|
||||
afs_status_t ast;
|
||||
|
||||
if( !vos_ServerClose( (void *) vosServerHandle, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
if ( !vos_ServerClose( (void *) vosServerHandle, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -302,32 +282,26 @@ Java_org_openafs_jafs_Server_getBosServerHandle
|
||||
{
|
||||
afs_status_t ast;
|
||||
void *serverHandle;
|
||||
// convert java string
|
||||
const char *serverName;
|
||||
char *serverName;
|
||||
|
||||
if( jserverName != NULL ) {
|
||||
serverName = (*env)->GetStringUTFChars(env, jserverName, 0);
|
||||
if( !serverName ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
if ( jserverName != NULL ) {
|
||||
serverName = getNativeString(env, jserverName);
|
||||
if ( !serverName ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
serverName = NULL;
|
||||
throwAFSException( env, JAFSNULLSERVER );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !bos_ServerOpen( (void *) cellHandle, serverName,
|
||||
(void **) &serverHandle, &ast ) ) {
|
||||
if( serverName != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jserverName, serverName);
|
||||
}
|
||||
throwAFSException( env, ast );
|
||||
return 0;
|
||||
if ( !bos_ServerOpen( (void *) cellHandle, serverName,
|
||||
(void **) &serverHandle, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
}
|
||||
|
||||
// release converted string
|
||||
if( serverName != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jserverName, serverName);
|
||||
}
|
||||
free( serverName );
|
||||
|
||||
return (jint) serverHandle;
|
||||
}
|
||||
@ -343,12 +317,12 @@ JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Server_closeBosServerHandle
|
||||
(JNIEnv *env, jobject obj, jint bosServerHandle)
|
||||
{
|
||||
afs_status_t ast;
|
||||
afs_status_t ast;
|
||||
|
||||
if( !bos_ServerClose( (void *) bosServerHandle, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
if ( !bos_ServerClose( (void *) bosServerHandle, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -365,41 +339,37 @@ JNIEXPORT jlong JNICALL
|
||||
Java_org_openafs_jafs_Token_getExpiration
|
||||
(JNIEnv *env, jobject obj, jint 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;
|
||||
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 ( !prince || !inst || !cell ) {
|
||||
if ( prince ) {
|
||||
free( prince );
|
||||
}
|
||||
|
||||
if( !afsclient_TokenQuery( (void *) tokenHandle, &expTime, prince, inst,
|
||||
cell, &hkt, &ast ) ) {
|
||||
free( prince );
|
||||
free( inst );
|
||||
free( cell );
|
||||
throwAFSException( env, ast );
|
||||
return 0;
|
||||
if ( inst ) {
|
||||
free( inst );
|
||||
}
|
||||
if ( cell ) {
|
||||
free( cell );
|
||||
}
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
|
||||
free( prince );
|
||||
free( inst );
|
||||
free( cell );
|
||||
if ( !afsclient_TokenQuery( (void *) tokenHandle, &expTime, prince, inst,
|
||||
cell, &hkt, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
}
|
||||
|
||||
return (jlong) expTime;
|
||||
free( prince );
|
||||
free( inst );
|
||||
free( cell );
|
||||
|
||||
return (jlong) expTime;
|
||||
}
|
||||
|
||||
// reclaim global memory used by this portion
|
||||
@ -407,9 +377,3 @@ JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Token_reclaimAuthMemory (JNIEnv *env, jclass cls)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,6 +19,11 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#include <afs/param.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#include "Internal.h"
|
||||
#include "org_openafs_jafs_File.h"
|
||||
|
||||
@ -76,28 +81,34 @@ char* getAbsolutePath(JNIEnv *env, jobject *obj, char *dirName)
|
||||
jclass thisClass;
|
||||
jstring jDirName;
|
||||
jmethodID getAbsolutePathID;
|
||||
const char *auxDirName;
|
||||
char *auxDirName;
|
||||
jfieldID fid;
|
||||
|
||||
thisClass = (*env)->GetObjectClass(env, *obj);
|
||||
if(thisClass == NULL) {
|
||||
if( thisClass == NULL ) {
|
||||
fprintf(stderr, "File::getAbsolutePath(): GetObjectClass failed\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fid = (*env)->GetFieldID(env, thisClass, "path", "Ljava/lang/String;");
|
||||
if (fid == 0) {
|
||||
if ( fid == NULL ) {
|
||||
fprintf(stderr, "File::getAbsolutePath(): GetFieldID (path) failed\n");
|
||||
return NULL;
|
||||
}
|
||||
jDirName = (*env)->GetObjectField(env, *obj, fid);
|
||||
|
||||
if(jDirName == 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);
|
||||
|
||||
auxDirName = getNativeString(env, jDirName);
|
||||
if ( auxDirName == NULL ) {
|
||||
fprintf(stderr, "File::getAbsolutePath(): failed to get translated file name\n");
|
||||
return NULL;
|
||||
}
|
||||
strcpy(dirName, auxDirName);
|
||||
(*env) -> ReleaseStringUTFChars(env, jDirName, auxDirName);
|
||||
free( auxDirName );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -464,8 +475,9 @@ JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_closeDir
|
||||
if (rc < 0) {
|
||||
setError(env, &obj, errno);
|
||||
return JNI_FALSE;
|
||||
} else {
|
||||
return JNI_TRUE;
|
||||
}
|
||||
else return JNI_TRUE;
|
||||
}
|
||||
|
||||
|
||||
@ -636,8 +648,7 @@ void setFileNotExistsAttributes
|
||||
fid = (*env)->GetFieldID(env, thisClass, "isDirectory", "Z");
|
||||
if (fid == 0) {
|
||||
fprintf(stderr,
|
||||
"File::setFileNotExistsAttributes(): GetFieldID (isDirectory)
|
||||
failed\n");
|
||||
"File::setFileNotExistsAttributes(): GetFieldID (isDirectory) failed\n");
|
||||
return;
|
||||
}
|
||||
(*env)->SetBooleanField(env, *obj, fid, JNI_FALSE);
|
||||
@ -645,8 +656,7 @@ void setFileNotExistsAttributes
|
||||
fid = (*env)->GetFieldID(env, thisClass, "isFile", "Z");
|
||||
if (fid == 0) {
|
||||
fprintf(stderr,
|
||||
"File::setFileNotExistsAttributes(): GetFieldID (isDirectory)
|
||||
failed\n");
|
||||
"File::setFileNotExistsAttributes(): GetFieldID (isDirectory) failed\n");
|
||||
return;
|
||||
}
|
||||
(*env)->SetBooleanField(env, *obj, fid, JNI_FALSE);
|
||||
@ -670,5 +680,3 @@ void setFileNotExistsAttributes
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,7 +33,7 @@ extern int errno;
|
||||
/**
|
||||
* Be carefull with the memory management:
|
||||
*
|
||||
* - For every GetStringUTFChars call the corresponding ReleaseStringUTFChars.
|
||||
* - For every getNativeString call the corresponding free().
|
||||
* - For every Get<type>ArrayElements call the corresponding
|
||||
* Release<type>ArrayElements
|
||||
* - For every malloc call the corresponding free.
|
||||
@ -91,13 +91,13 @@ JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileInputStream_read
|
||||
jfieldID fid;
|
||||
|
||||
/* If we have to read 0 bytes just return */
|
||||
if(length == 0) return 0;
|
||||
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) {
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "FileInputStream::read(): invalid file state\n");
|
||||
throwAFSFileException(env, 0, "Invalid file state");
|
||||
return -1;
|
||||
@ -136,7 +136,7 @@ JNIEXPORT void JNICALL Java_org_openafs_jafs_FileInputStream_close
|
||||
fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I");
|
||||
fd = (*env)->GetIntField(env, obj, fid);
|
||||
|
||||
if(fd < 0) {
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "FileInputStream::close(): invalid file state\n");
|
||||
throwAFSFileException(env, 0, "Invalid file state");
|
||||
return;
|
||||
@ -148,6 +148,3 @@ JNIEXPORT void JNICALL Java_org_openafs_jafs_FileInputStream_close
|
||||
throwAFSFileException(env, errno, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -19,12 +19,15 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#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>
|
||||
/*#include <afs/afs_usrops.h>*/
|
||||
|
||||
#ifdef DMALLOC
|
||||
#include "dmalloc.h"
|
||||
@ -33,7 +36,7 @@
|
||||
/**
|
||||
* Be carefull with the memory management:
|
||||
*
|
||||
* - For every GetStringUTFChars call the corresponding ReleaseStringUTFChars.
|
||||
* - For every getNativeString call the corresponding free().
|
||||
* - For every Get<type>ArrayElements call the corresponding
|
||||
* Release<type>ArrayElements
|
||||
* - For every malloc call the corresponding free.
|
||||
@ -104,40 +107,43 @@ JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileOutputStream_openAppend
|
||||
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;
|
||||
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
|
||||
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!");
|
||||
throwAFSFileException(env, 0, "Failed to get file descriptor!");
|
||||
}
|
||||
|
||||
bytes = (char*) 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);
|
||||
}
|
||||
bytes = (char*) 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);
|
||||
toWrite -= written;
|
||||
}
|
||||
free(bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -153,23 +159,21 @@ JNIEXPORT void JNICALL Java_org_openafs_jafs_FileOutputStream_write
|
||||
JNIEXPORT void JNICALL Java_org_openafs_jafs_FileOutputStream_close
|
||||
(JNIEnv *env, jobject obj)
|
||||
{
|
||||
int fd, rc;
|
||||
jclass thisClass;
|
||||
jmethodID getFileDescriptorID;
|
||||
char *bytes;
|
||||
jfieldID fid;
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,63 +72,54 @@ Java_org_openafs_jafs_Group_create
|
||||
{
|
||||
afs_status_t ast;
|
||||
// convert java strings
|
||||
const char *groupName;
|
||||
const char *ownerName;
|
||||
char *groupName;
|
||||
char *ownerName;
|
||||
|
||||
if( jgroupName != NULL ) {
|
||||
groupName = (*env)->GetStringUTFChars(env, jgroupName, 0);
|
||||
if( !groupName ) {
|
||||
if ( jgroupName != NULL ) {
|
||||
groupName = getNativeString(env, jgroupName);
|
||||
if ( groupName == NULL ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
groupName = NULL;
|
||||
throwAFSException( env, JAFSNULLGROUP );
|
||||
return;
|
||||
}
|
||||
|
||||
if( jownerName != NULL ) {
|
||||
ownerName = (*env)->GetStringUTFChars(env, jownerName, 0);
|
||||
if( !ownerName ) {
|
||||
if ( jownerName != NULL ) {
|
||||
ownerName = getNativeString(env, jownerName);
|
||||
if ( ownerName == NULL ) {
|
||||
free( groupName );
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
ownerName = NULL;
|
||||
free( groupName );
|
||||
throwAFSException( env, JAFSNULLOWNER );
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure the name is within the allowed bounds
|
||||
if( groupName != NULL && strlen( groupName ) > PTS_MAX_NAME_LEN ) {
|
||||
if ( 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);
|
||||
}
|
||||
free( groupName );
|
||||
free( ownerName );
|
||||
throwAFSException( env, ADMPTSGROUPNAMETOOLONG );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !pts_GroupCreate( (void *) cellHandle, groupName, ownerName,
|
||||
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);
|
||||
}
|
||||
free( groupName );
|
||||
free( 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);
|
||||
}
|
||||
|
||||
free( groupName );
|
||||
free( ownerName );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,31 +138,25 @@ Java_org_openafs_jafs_Group_delete
|
||||
{
|
||||
afs_status_t ast;
|
||||
// convert java strings
|
||||
const char *groupName;
|
||||
char *groupName;
|
||||
|
||||
if( jgroupName != NULL ) {
|
||||
groupName = (*env)->GetStringUTFChars(env, jgroupName, 0);
|
||||
if( !groupName ) {
|
||||
if ( jgroupName != NULL ) {
|
||||
groupName = getNativeString(env, jgroupName);
|
||||
if ( !groupName ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
groupName = NULL;
|
||||
throwAFSException( env, JAFSNULLGROUP );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !pts_GroupDelete( (void *) cellHandle, groupName, &ast ) ) {
|
||||
if( groupName != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
|
||||
}
|
||||
if ( !pts_GroupDelete( (void *) cellHandle, groupName, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
|
||||
// release converted java strings
|
||||
if( groupName != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
|
||||
}
|
||||
|
||||
free( groupName );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -192,7 +177,7 @@ void getGroupInfoChar
|
||||
pts_GroupEntry_t entry;
|
||||
afs_status_t ast;
|
||||
// get the field ids if you haven't already
|
||||
if( groupCls == 0 ) {
|
||||
if ( groupCls == 0 ) {
|
||||
internal_getGroupClass( env, group );
|
||||
}
|
||||
|
||||
@ -208,10 +193,10 @@ void getGroupInfoChar
|
||||
(*env)->SetIntField(env, group, group_membershipCountField,
|
||||
entry.membershipCount);
|
||||
|
||||
if( entry.listStatus == PTS_GROUP_OWNER_ACCESS ) {
|
||||
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 ) {
|
||||
} else if ( entry.listStatus == PTS_GROUP_ACCESS ) {
|
||||
(*env)->SetIntField(env, group, group_listStatusField,
|
||||
org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
|
||||
} else {
|
||||
@ -219,10 +204,10 @@ void getGroupInfoChar
|
||||
org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
|
||||
}
|
||||
|
||||
if( entry.listGroupsOwned == PTS_GROUP_OWNER_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 ) {
|
||||
} else if ( entry.listGroupsOwned == PTS_GROUP_ACCESS ) {
|
||||
(*env)->SetIntField(env, group, group_listGroupsOwnedField,
|
||||
org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
|
||||
} else {
|
||||
@ -230,10 +215,10 @@ void getGroupInfoChar
|
||||
org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
|
||||
}
|
||||
|
||||
if( entry.listMembership == PTS_GROUP_OWNER_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 ) {
|
||||
} else if ( entry.listMembership == PTS_GROUP_ACCESS ) {
|
||||
(*env)->SetIntField(env, group, group_listMembershipField,
|
||||
org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
|
||||
} else {
|
||||
@ -241,10 +226,10 @@ void getGroupInfoChar
|
||||
org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
|
||||
}
|
||||
|
||||
if( entry.listAdd == PTS_GROUP_OWNER_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 ) {
|
||||
} else if ( entry.listAdd == PTS_GROUP_ACCESS ) {
|
||||
(*env)->SetIntField(env, group, group_listAddField,
|
||||
org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
|
||||
} else {
|
||||
@ -252,10 +237,10 @@ void getGroupInfoChar
|
||||
org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
|
||||
}
|
||||
|
||||
if( entry.listDelete == PTS_GROUP_OWNER_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 ) {
|
||||
} else if ( entry.listDelete == PTS_GROUP_ACCESS ) {
|
||||
(*env)->SetIntField(env, group, group_listDeleteField,
|
||||
org_openafs_jafs_Group_GROUP_GROUP_ACCESS);
|
||||
} else {
|
||||
@ -263,12 +248,11 @@ void getGroupInfoChar
|
||||
org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS);
|
||||
}
|
||||
|
||||
jowner = (*env)->NewStringUTF(env, entry.owner);
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -286,32 +270,29 @@ JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Group_getGroupInfo
|
||||
(JNIEnv *env, jclass cls, jint cellHandle, jstring jname, jobject group)
|
||||
{
|
||||
char *name;
|
||||
|
||||
const char *name;
|
||||
|
||||
if( jname != NULL ) {
|
||||
name = (*env)->GetStringUTFChars(env, jname, 0);
|
||||
if( !name ) {
|
||||
if ( jname != NULL ) {
|
||||
name = getNativeString(env, jname);
|
||||
if ( !name ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
name = NULL;
|
||||
throwAFSException( env, JAFSNULLGROUP );
|
||||
return;
|
||||
}
|
||||
getGroupInfoChar( env, cellHandle, name, group );
|
||||
|
||||
// get class fields if need be
|
||||
if( groupCls == 0 ) {
|
||||
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);
|
||||
}
|
||||
|
||||
free( name );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -327,7 +308,7 @@ JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Group_setGroupInfo
|
||||
(JNIEnv *env, jclass cls, jint cellHandle, jstring jname, jobject group)
|
||||
{
|
||||
const char *name;
|
||||
char *name;
|
||||
pts_GroupUpdateEntry_t ptsEntry;
|
||||
afs_status_t ast;
|
||||
|
||||
@ -338,7 +319,7 @@ Java_org_openafs_jafs_Group_setGroupInfo
|
||||
jint jlistDelete;
|
||||
|
||||
// get the field ids if you haven't already
|
||||
if( groupCls == 0 ) {
|
||||
if ( groupCls == 0 ) {
|
||||
internal_getGroupClass( env, group );
|
||||
}
|
||||
|
||||
@ -349,65 +330,60 @@ Java_org_openafs_jafs_Group_setGroupInfo
|
||||
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 ) {
|
||||
if ( jname != NULL ) {
|
||||
name = getNativeString(env, jname);
|
||||
if ( name == NULL ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
name = NULL;
|
||||
throwAFSException( env, JAFSNULLGROUP );
|
||||
return;
|
||||
}
|
||||
|
||||
if( jlistStatus == org_openafs_jafs_Group_GROUP_OWNER_ACCESS ) {
|
||||
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 ) {
|
||||
} 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 ) {
|
||||
if ( jlistGroupsOwned == org_openafs_jafs_Group_GROUP_OWNER_ACCESS ) {
|
||||
ptsEntry.listGroupsOwned = PTS_GROUP_OWNER_ACCESS;
|
||||
} else if( jlistGroupsOwned ==
|
||||
} 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 ) {
|
||||
if ( jlistMembership == org_openafs_jafs_Group_GROUP_OWNER_ACCESS ) {
|
||||
ptsEntry.listMembership = PTS_GROUP_OWNER_ACCESS;
|
||||
} else if( jlistMembership ==
|
||||
} 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 ) {
|
||||
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 ) {
|
||||
} 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 ) {
|
||||
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 ) {
|
||||
} 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);
|
||||
}
|
||||
|
||||
if ( !pts_GroupModify( (void *) cellHandle, name, &ptsEntry, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
|
||||
if( name != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jname, name);
|
||||
}
|
||||
|
||||
free( name );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -425,35 +401,29 @@ JNIEXPORT jint JNICALL
|
||||
Java_org_openafs_jafs_Group_getGroupMembersBegin
|
||||
(JNIEnv *env, jclass cls, jint cellHandle, jstring jname)
|
||||
{
|
||||
const char *name;
|
||||
char *name;
|
||||
afs_status_t ast;
|
||||
void *iterationId;
|
||||
|
||||
if( jname != NULL ) {
|
||||
name = (*env)->GetStringUTFChars(env, jname, 0);
|
||||
if( !name ) {
|
||||
if ( jname != NULL ) {
|
||||
name = getNativeString(env, jname);
|
||||
if ( name == NULL ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
name = NULL;
|
||||
throwAFSException( env, JAFSNULLGROUP );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( !pts_GroupMemberListBegin( (void *) cellHandle, name, &iterationId,
|
||||
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);
|
||||
}
|
||||
free( name );
|
||||
|
||||
return (jint) iterationId;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -473,14 +443,14 @@ Java_org_openafs_jafs_Group_getGroupMembersNextString
|
||||
char *userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
|
||||
jstring juser;
|
||||
|
||||
if( !userName ) {
|
||||
if ( !userName ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !pts_GroupMemberListNext( (void *) iterationId, userName, &ast ) ) {
|
||||
if ( !pts_GroupMemberListNext( (void *) iterationId, userName, &ast ) ) {
|
||||
free( userName );
|
||||
if( ast == ADMITERATORDONE ) {
|
||||
if ( ast == ADMITERATORDONE ) {
|
||||
return NULL;
|
||||
} else {
|
||||
throwAFSException( env, ast );
|
||||
@ -516,14 +486,14 @@ Java_org_openafs_jafs_Group_getGroupMembersNext
|
||||
|
||||
userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN);
|
||||
|
||||
if( !userName ) {
|
||||
if ( !userName ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !pts_GroupMemberListNext( (void *) iterationId, userName, &ast ) ) {
|
||||
if ( !pts_GroupMemberListNext( (void *) iterationId, userName, &ast ) ) {
|
||||
free( userName );
|
||||
if( ast == ADMITERATORDONE ) {
|
||||
if ( ast == ADMITERATORDONE ) {
|
||||
return 0;
|
||||
} else {
|
||||
throwAFSException( env, ast );
|
||||
@ -533,7 +503,7 @@ Java_org_openafs_jafs_Group_getGroupMembersNext
|
||||
|
||||
juser = (*env)->NewStringUTF(env, userName);
|
||||
|
||||
if( userCls == 0 ) {
|
||||
if ( userCls == 0 ) {
|
||||
internal_getUserClass( env, juserObject );
|
||||
}
|
||||
|
||||
@ -560,11 +530,10 @@ Java_org_openafs_jafs_Group_getGroupMembersDone
|
||||
{
|
||||
afs_status_t ast;
|
||||
|
||||
if( !pts_GroupMemberListDone( (void *) iterationId, &ast ) ) {
|
||||
if ( !pts_GroupMemberListDone( (void *) iterationId, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -582,49 +551,39 @@ Java_org_openafs_jafs_Group_addMember
|
||||
jstring juserName )
|
||||
{
|
||||
afs_status_t ast;
|
||||
const char *groupName;
|
||||
const char *userName;
|
||||
char *groupName;
|
||||
char *userName;
|
||||
|
||||
if( jgroupName != NULL ) {
|
||||
groupName = (*env)->GetStringUTFChars(env, jgroupName, 0);
|
||||
if( !groupName ) {
|
||||
if ( jgroupName != NULL ) {
|
||||
groupName = getNativeString(env, jgroupName);
|
||||
if ( groupName == NULL ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
groupName = NULL;
|
||||
throwAFSException( env, JAFSNULLGROUP );
|
||||
return;
|
||||
}
|
||||
|
||||
if( juserName != NULL ) {
|
||||
userName = (*env)->GetStringUTFChars(env, juserName, 0);
|
||||
if( !userName ) {
|
||||
if( groupName != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
|
||||
}
|
||||
if ( juserName != NULL ) {
|
||||
userName = getNativeString(env, juserName);
|
||||
if ( userName == NULL ) {
|
||||
free( 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 );
|
||||
free( groupName );
|
||||
throwAFSException( env, JAFSNULLUSER );
|
||||
return;
|
||||
}
|
||||
|
||||
if( groupName != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
|
||||
}
|
||||
if( userName != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, juserName, userName);
|
||||
if ( !pts_GroupMemberAdd( (void *) cellHandle, userName, groupName, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
}
|
||||
|
||||
free( userName );
|
||||
free( groupName );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -643,50 +602,40 @@ Java_org_openafs_jafs_Group_removeMember
|
||||
jstring juserName)
|
||||
{
|
||||
afs_status_t ast;
|
||||
const char *groupName;
|
||||
const char *userName;
|
||||
char *groupName;
|
||||
char *userName;
|
||||
|
||||
if( jgroupName != NULL ) {
|
||||
groupName = (*env)->GetStringUTFChars(env, jgroupName, 0);
|
||||
if( !groupName ) {
|
||||
if ( jgroupName != NULL ) {
|
||||
groupName = getNativeString(env, jgroupName);
|
||||
if ( groupName == NULL ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
groupName = NULL;
|
||||
throwAFSException( env, JAFSNULLGROUP );
|
||||
return;
|
||||
}
|
||||
|
||||
if( juserName != NULL ) {
|
||||
userName = (*env)->GetStringUTFChars(env, juserName, 0);
|
||||
if( !userName ) {
|
||||
if( groupName != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
|
||||
}
|
||||
if ( juserName != NULL ) {
|
||||
userName = getNativeString(env, juserName);
|
||||
if ( userName == NULL ) {
|
||||
free( 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 );
|
||||
free( groupName );
|
||||
throwAFSException( env, JAFSNULLUSER );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !pts_GroupMemberRemove( (void *)cellHandle, userName,
|
||||
groupName, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
}
|
||||
|
||||
if( groupName != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
|
||||
}
|
||||
if( userName != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, juserName, userName);
|
||||
}
|
||||
free( groupName );
|
||||
free( userName );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -705,51 +654,40 @@ Java_org_openafs_jafs_Group_changeOwner
|
||||
jstring jownerName )
|
||||
{
|
||||
afs_status_t ast;
|
||||
const char *groupName;
|
||||
const char *ownerName;
|
||||
char *groupName;
|
||||
char *ownerName;
|
||||
|
||||
if( jgroupName != NULL ) {
|
||||
groupName = (*env)->GetStringUTFChars(env, jgroupName, 0);
|
||||
if( !groupName ) {
|
||||
if ( jgroupName != NULL ) {
|
||||
groupName = getNativeString(env, jgroupName);
|
||||
if ( groupName == NULL ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
groupName = NULL;
|
||||
throwAFSException( env, JAFSNULLGROUP );
|
||||
return;
|
||||
}
|
||||
|
||||
if( jownerName != NULL ) {
|
||||
ownerName = (*env)->GetStringUTFChars(env, jownerName, 0);
|
||||
if( !ownerName ) {
|
||||
if( groupName != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jgroupName, groupName);
|
||||
}
|
||||
if ( jownerName != NULL ) {
|
||||
ownerName = getNativeString(env, jownerName);
|
||||
if ( ownerName == NULL ) {
|
||||
free( groupName );
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
ownerName = NULL;
|
||||
free( groupName );
|
||||
throwAFSException( env, JAFSNULLOWNER );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !pts_GroupOwnerChange( (void *)cellHandle, groupName,
|
||||
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);
|
||||
}
|
||||
|
||||
free( groupName );
|
||||
free( ownerName );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -767,61 +705,48 @@ Java_org_openafs_jafs_Group_rename
|
||||
jstring jgroupNewName )
|
||||
{
|
||||
afs_status_t ast;
|
||||
const char *groupOldName;
|
||||
const char *groupNewName;
|
||||
char *groupOldName;
|
||||
char *groupNewName;
|
||||
|
||||
if( jgroupOldName != NULL ) {
|
||||
groupOldName = (*env)->GetStringUTFChars(env, jgroupOldName, 0);
|
||||
if( !groupOldName ) {
|
||||
if ( jgroupOldName != NULL ) {
|
||||
groupOldName = getNativeString(env, jgroupOldName);
|
||||
if ( groupOldName == NULL ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
groupOldName = NULL;
|
||||
throwAFSException( env, JAFSNULLGROUP );
|
||||
return;
|
||||
}
|
||||
|
||||
if( jgroupNewName != NULL ) {
|
||||
groupNewName = (*env)->GetStringUTFChars(env, jgroupNewName, 0);
|
||||
if( !groupNewName ) {
|
||||
if( groupOldName != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jgroupOldName, groupOldName);
|
||||
}
|
||||
if ( jgroupNewName != NULL ) {
|
||||
groupNewName = getNativeString(env, jgroupNewName);
|
||||
if ( groupNewName == NULL ) {
|
||||
free( 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 );
|
||||
free( groupOldName );
|
||||
throwAFSException( env, JAFSNULLGROUP );
|
||||
return;
|
||||
}
|
||||
|
||||
if( groupOldName != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jgroupOldName, groupOldName);
|
||||
}
|
||||
if( groupNewName != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jgroupNewName, groupNewName);
|
||||
if ( !pts_GroupRename( (void *)cellHandle, groupOldName,
|
||||
groupNewName, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
}
|
||||
|
||||
free( groupOldName );
|
||||
free( 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;
|
||||
if ( groupCls ) {
|
||||
(*env)->DeleteGlobalRef(env, groupCls);
|
||||
groupCls = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -27,15 +27,16 @@
|
||||
|
||||
extern int errno;
|
||||
|
||||
jmethodID MID_String_getBytes = 0;
|
||||
|
||||
#ifndef LIBJUAFS
|
||||
// user class and fields //
|
||||
jclass userCls = 0;
|
||||
/* 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
|
||||
/* PTS Fields */
|
||||
jfieldID user_nameUidField = 0;
|
||||
jfieldID user_ownerUidField = 0;
|
||||
jfieldID user_creatorUidField = 0;
|
||||
@ -46,7 +47,7 @@ jfieldID user_groupCreationQuotaField = 0;
|
||||
jfieldID user_groupMembershipCountField = 0;
|
||||
jfieldID user_ownerField = 0;
|
||||
jfieldID user_creatorField = 0;
|
||||
// kas fields
|
||||
/* KAS Fields */
|
||||
jfieldID user_adminSettingField = 0;
|
||||
jfieldID user_tgsSettingField = 0;
|
||||
jfieldID user_encSettingField = 0;
|
||||
@ -65,10 +66,9 @@ jfieldID user_failLoginCountField = 0;
|
||||
jfieldID user_lockTimeField = 0;
|
||||
jfieldID user_lockedUntilField = 0;
|
||||
|
||||
// group class and fields //
|
||||
jclass groupCls = 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;
|
||||
@ -82,10 +82,9 @@ jfieldID group_membershipCountField = 0;
|
||||
jfieldID group_ownerField = 0;
|
||||
jfieldID group_creatorField = 0;
|
||||
|
||||
// server class and fields //
|
||||
jclass serverCls = 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;
|
||||
@ -93,8 +92,8 @@ jfieldID server_badDatabaseField = 0;
|
||||
jfieldID server_badFileServerField = 0;
|
||||
jfieldID server_IPAddressField = 0;
|
||||
|
||||
// executable time class and fields //
|
||||
jclass exectimeCls = 0;
|
||||
/* Executable Time Class and Fields */
|
||||
jclass exectimeCls = 0;
|
||||
jfieldID exectime_HourField = 0;
|
||||
jfieldID exectime_MinField = 0;
|
||||
jfieldID exectime_SecField = 0;
|
||||
@ -102,8 +101,8 @@ jfieldID exectime_DayField = 0;
|
||||
jfieldID exectime_NowField = 0;
|
||||
jfieldID exectime_NeverField = 0;
|
||||
|
||||
// partition class and fields //
|
||||
jclass partitionCls = 0;
|
||||
/* Partition Class and Fields */
|
||||
jclass partitionCls = 0;
|
||||
jfieldID partition_nameField = 0;
|
||||
jfieldID partition_cachedInfoField = 0;
|
||||
jfieldID partition_idField = 0;
|
||||
@ -112,8 +111,8 @@ jfieldID partition_lockFileDescriptorField = 0;
|
||||
jfieldID partition_totalSpaceField = 0;
|
||||
jfieldID partition_totalFreeSpaceField = 0;
|
||||
|
||||
// volume class and fields //
|
||||
jclass volumeCls = 0;
|
||||
/* Volume Class and Fields */
|
||||
jclass volumeCls = 0;
|
||||
jfieldID volume_nameField = 0;
|
||||
jfieldID volume_cachedInfoField = 0;
|
||||
jfieldID volume_idField = 0;
|
||||
@ -133,8 +132,8 @@ jfieldID volume_statusField = 0;
|
||||
jfieldID volume_dispositionField = 0;
|
||||
jfieldID volume_typeField = 0;
|
||||
|
||||
// key class and fields //
|
||||
jclass keyCls = 0;
|
||||
/* Key Class and Fields */
|
||||
jclass keyCls = 0;
|
||||
jfieldID key_cachedInfoField = 0;
|
||||
jfieldID key_versionField = 0;
|
||||
jfieldID key_encryptionKeyField = 0;
|
||||
@ -142,11 +141,10 @@ jfieldID key_lastModDateField = 0;
|
||||
jfieldID key_lastModMsField = 0;
|
||||
jfieldID key_checkSumField = 0;
|
||||
|
||||
// process class and fields //
|
||||
jclass processCls = 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;
|
||||
@ -159,6 +157,7 @@ jfieldID process_errorSignalField = 0;
|
||||
jfieldID process_stateOkField = 0;
|
||||
jfieldID process_stateTooManyErrorsField = 0;
|
||||
jfieldID process_stateBadFileAccessField = 0;
|
||||
|
||||
#endif /* !LIBJUAFS */
|
||||
|
||||
/**
|
||||
@ -173,23 +172,20 @@ void throwException
|
||||
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);
|
||||
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);
|
||||
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",
|
||||
fprintf(stderr, "ERROR: Internal::throwException()\n Cannot construct new exception object: %s\n",
|
||||
excClsName);
|
||||
return;
|
||||
}
|
||||
@ -206,8 +202,7 @@ 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);
|
||||
fprintf(stderr, "ERROR: Internal::throwMessageException()\n Cannot find class: %s\n", afsExceptionName);
|
||||
return;
|
||||
}
|
||||
(*env)->ThrowNew(env, excCls, msg);
|
||||
@ -226,16 +221,14 @@ void throwAFSException( JNIEnv *env, int code )
|
||||
|
||||
afsExceptionCls = (*env)->FindClass(env, afsExceptionName);
|
||||
if( !afsExceptionCls ) {
|
||||
fprintf(stderr, "ERROR: Internal::throwAFSException()\n
|
||||
Cannot find class: %s\n", afsExceptionName);
|
||||
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",
|
||||
fprintf(stderr, "ERROR: Internal::throwAFSException()\n Cannot find construction method: %s\n",
|
||||
afsExceptionName);
|
||||
return;
|
||||
}
|
||||
@ -243,8 +236,7 @@ void throwAFSException( JNIEnv *env, int code )
|
||||
exc = (*env)->NewObject( env, afsExceptionCls, afsExceptionInit, code );
|
||||
|
||||
if( !exc ) {
|
||||
fprintf(stderr, "ERROR: Internal::throwAFSException()\n
|
||||
Cannot construct new exception object: %s\n",
|
||||
fprintf(stderr, "ERROR: Internal::throwAFSException()\n Cannot construct new exception object: %s\n",
|
||||
afsExceptionName);
|
||||
return;
|
||||
}
|
||||
@ -264,16 +256,15 @@ void throwAFSFileException( JNIEnv *env, int code, char *msg )
|
||||
|
||||
afsFileExceptionCls = (*env)->FindClass(env, afsFileExceptionName);
|
||||
if( !afsFileExceptionCls ) {
|
||||
fprintf(stderr, "ERROR: Internal::throwAFSFileException()\n
|
||||
Cannot find class: %s\n", afsFileExceptionName);
|
||||
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",
|
||||
fprintf(stderr, "ERROR: Internal::throwAFSFileException()\n Cannot find construction method: %s\n",
|
||||
afsFileExceptionName);
|
||||
return;
|
||||
}
|
||||
@ -281,8 +272,7 @@ void throwAFSFileException( JNIEnv *env, int code, char *msg )
|
||||
exc = (*env)->NewObject( env, afsFileExceptionCls,
|
||||
afsFileExceptionInit, msg, code );
|
||||
if( !exc ) {
|
||||
fprintf(stderr, "ERROR: Internal::throwAFSFileException()\n
|
||||
Cannot construct new exception object: %s\n",
|
||||
fprintf(stderr, "ERROR: Internal::throwAFSFileException()\n Cannot construct new exception object: %s\n",
|
||||
afsFileExceptionName);
|
||||
return;
|
||||
}
|
||||
@ -302,25 +292,23 @@ void throwAFSSecurityException( JNIEnv *env, int code )
|
||||
|
||||
afsSecurityExceptionCls = (*env)->FindClass(env, afsSecurityExceptionName);
|
||||
if( !afsSecurityExceptionCls ) {
|
||||
fprintf(stderr, "ERROR: Internal::throwAFSSecurityException()\n
|
||||
Cannot find class: %s\n", afsSecurityExceptionName);
|
||||
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",
|
||||
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",
|
||||
fprintf(stderr, "ERROR: Internal::throwAFSSecurityException()\n Cannot construct new exception object: %s\n",
|
||||
afsSecurityExceptionName);
|
||||
return;
|
||||
}
|
||||
@ -342,6 +330,98 @@ int setError(JNIEnv *env, jobject *obj, int code)
|
||||
return -1;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates a jstring to a locale-specific native C string.
|
||||
* Use in place of "GetStringUTFChars()" for internationalization
|
||||
* purposes.
|
||||
*
|
||||
* Make sure to "free()" any strings created by this function.
|
||||
*
|
||||
* A NULL (zero) return indicates a critical error has occurred and
|
||||
* relies on the caller of this function to throw a Java exception.
|
||||
*
|
||||
* This function does not throw any Java exceptions.
|
||||
*
|
||||
* env the Java environment
|
||||
* jstr the Java string (UTF) to translate
|
||||
*
|
||||
* @returns native C string with the appropriate locale-specific
|
||||
* representation
|
||||
*/
|
||||
char* getNativeString(JNIEnv *env, const jstring jstr)
|
||||
{
|
||||
jbyteArray bytes = 0;
|
||||
char *result = NULL;
|
||||
jint len = 0;
|
||||
|
||||
if ((*env)->EnsureLocalCapacity(env, 2) < 0) {
|
||||
// Out of memory error
|
||||
fprintf(stderr, "Internal::getNativeString(): ");
|
||||
fprintf(stderr, "EnsureLocalCapacity() failed: Most likely out of memory\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( !MID_String_getBytes ) {
|
||||
jclass stringClass = (*env)->FindClass(env, "java/lang/String");
|
||||
if ( !stringClass ) {
|
||||
fprintf(stderr, "Internal::getNativeString(): ");
|
||||
fprintf(stderr, "Could not locate Java class: java.lang.String.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MID_String_getBytes = (*env)->GetMethodID(env, stringClass, "getBytes","()[B");
|
||||
if ( !MID_String_getBytes ) {
|
||||
fprintf(stderr, "Internal::getNativeString(): ");
|
||||
fprintf(stderr, "Could not get Java method id for java.lang.String method \"getBytes()\".\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bytes = (*env)->CallObjectMethod(env, jstr, MID_String_getBytes);
|
||||
if ( !bytes ) {
|
||||
fprintf(stderr, "Internal::getNativeString(): ");
|
||||
fprintf(stderr, "CallObjectMethod() failed for java.lang.String.getBytes().\n");
|
||||
fprintf(stderr, "\tMID_String_getBytes = %d\n", MID_String_getBytes);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = (*env)->GetArrayLength(env, bytes);
|
||||
result = (char *)malloc(len + 1);
|
||||
|
||||
if ( !result ) {
|
||||
fprintf(stderr, "Internal::getNativeString(): ");
|
||||
fprintf(stderr, "Could not allocate memory for byte array.\n");
|
||||
(*env)->DeleteLocalRef(env, bytes);
|
||||
return NULL;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, bytes, 0, len, (jbyte *)result);
|
||||
result[len] = '\0'; // NULL-terminate
|
||||
|
||||
(*env)->DeleteLocalRef(env, bytes);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef LIBJUAFS
|
||||
|
||||
/**
|
||||
@ -357,34 +437,46 @@ int setError(JNIEnv *env, jobject *obj, int code)
|
||||
* @returns file descriptor
|
||||
*/
|
||||
int openAFSFile
|
||||
(JNIEnv *env, jstring fileNameUTF, int flags, int mode, int *err)
|
||||
(JNIEnv *env, jstring filenameUTF, int flags, int mode, int *err)
|
||||
{
|
||||
char *fileName;
|
||||
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");
|
||||
filename = getNativeString(env, filenameUTF);
|
||||
if(filename == NULL) {
|
||||
fprintf(stderr, "Internal::openAFSFile(): failed to get filename\n");
|
||||
*err = -1;
|
||||
return fd;
|
||||
}
|
||||
fd = uafs_open(fileName, flags, mode);
|
||||
fd = uafs_open(filename, flags, mode);
|
||||
free( filename );
|
||||
*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(): failed to open filename\n");
|
||||
fprintf(stderr, "Internal::openAFSFile(): fd=%d\n", fd);
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the "CacheConfig" file for user space configuration.
|
||||
* By default, this file resides in "/usr/afswsp/etc/CacheConfig",
|
||||
* however if the environment variable "LIBJAFS_CACHE_CONFIG" is
|
||||
* set this function will use that value instead.
|
||||
*
|
||||
* The CacheConfig file contains several cache tuning parameters
|
||||
* as well as a few parameters that define the runtime environment
|
||||
* for the user space client, including: mount point location,
|
||||
* configuration directory (where to find ThisCell and CellServDB),
|
||||
* cache directory, debug and verbose options, and log file location.
|
||||
*/
|
||||
int readCacheParms(char *afsMountPoint, char *afsConfDir, char *afsCacheDir,
|
||||
int *cacheBlocks, int *cacheFiles, int *cacheStatEntries,
|
||||
int *dCacheSize, int *vCacheSize, int *chunkSize,
|
||||
@ -455,27 +547,6 @@ int readCacheParms(char *afsMountPoint, char *afsConfDir, char *afsCacheDir,
|
||||
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
|
||||
|
||||
/**
|
||||
@ -485,9 +556,8 @@ int setString(JNIEnv *env, jobject *obj, char *field, char *string)
|
||||
* 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 ) {
|
||||
|
||||
void internal_makeKasIdentity( const char *fullName, kas_identity_p who )
|
||||
{
|
||||
char *period;
|
||||
|
||||
if( (period = (char *) strchr( fullName, '.' )) != NULL ) {
|
||||
@ -499,14 +569,14 @@ void internal_makeKasIdentity( const char *fullName,
|
||||
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 ) {
|
||||
void internal_getUserClass( JNIEnv *env, jobject user )
|
||||
{
|
||||
if( userCls == 0 ) {
|
||||
userCls = (*env)->NewGlobalRef( env, (*env)->GetObjectClass(env, user) );
|
||||
if( !userCls ) {
|
||||
@ -595,7 +665,6 @@ void internal_getUserClass( JNIEnv *env, jobject user ) {
|
||||
|
||||
throwAFSException( env, JAFSADMFIELDNOTFOUND );
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -604,7 +673,8 @@ void internal_getUserClass( JNIEnv *env, jobject user ) {
|
||||
* 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 ) {
|
||||
void internal_getGroupClass( JNIEnv *env, jobject group )
|
||||
{
|
||||
if( groupCls == 0 ) {
|
||||
groupCls = (*env)->NewGlobalRef( env, (*env)->GetObjectClass(env, group) );
|
||||
if( !groupCls ) {
|
||||
@ -643,7 +713,6 @@ void internal_getGroupClass( JNIEnv *env, jobject group ) {
|
||||
|
||||
throwAFSException( env, JAFSADMFIELDNOTFOUND );
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -652,7 +721,8 @@ void internal_getGroupClass( JNIEnv *env, jobject group ) {
|
||||
* 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 ) {
|
||||
void internal_getServerClass( JNIEnv *env, jobject server )
|
||||
{
|
||||
if( serverCls == 0 ) {
|
||||
serverCls = (*env)->NewGlobalRef( env,
|
||||
(*env)->GetObjectClass(env, server) );
|
||||
@ -690,7 +760,8 @@ void internal_getServerClass( JNIEnv *env, jobject server ) {
|
||||
* object and field information for the executableTime object from the
|
||||
* Java environment.
|
||||
*/
|
||||
void internal_getExecTimeClass( JNIEnv *env, jobject exectime ) {
|
||||
void internal_getExecTimeClass( JNIEnv *env, jobject exectime )
|
||||
{
|
||||
if( exectimeCls == 0 ) {
|
||||
exectimeCls = (*env)->NewGlobalRef( env,
|
||||
(*env)->GetObjectClass(env, exectime) );
|
||||
@ -720,7 +791,8 @@ void internal_getExecTimeClass( JNIEnv *env, jobject exectime ) {
|
||||
* 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 ) {
|
||||
void internal_getPartitionClass( JNIEnv *env, jobject partition )
|
||||
{
|
||||
if( partitionCls == 0 ) {
|
||||
partitionCls = (*env)->NewGlobalRef( env,
|
||||
(*env)->GetObjectClass(env, partition) );
|
||||
@ -759,7 +831,8 @@ void internal_getPartitionClass( JNIEnv *env, jobject partition ) {
|
||||
* 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 ) {
|
||||
void internal_getVolumeClass( JNIEnv *env, jobject volume )
|
||||
{
|
||||
if( volumeCls == 0 ) {
|
||||
volumeCls = (*env)->NewGlobalRef( env,
|
||||
(*env)->GetObjectClass(env, volume) );
|
||||
@ -823,7 +896,8 @@ void internal_getVolumeClass( JNIEnv *env, jobject volume ) {
|
||||
* 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 ) {
|
||||
void internal_getKeyClass( JNIEnv *env, jobject key )
|
||||
{
|
||||
if( keyCls == 0 ) {
|
||||
keyCls = (*env)->NewGlobalRef( env, (*env)->GetObjectClass(env, key) );
|
||||
if( !keyCls ) {
|
||||
@ -854,7 +928,8 @@ void internal_getKeyClass( JNIEnv *env, jobject key ) {
|
||||
* 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 ) {
|
||||
void internal_getProcessClass( JNIEnv *env, jobject process )
|
||||
{
|
||||
if( processCls == 0 ) {
|
||||
processCls = (*env)->NewGlobalRef( env,
|
||||
(*env)->GetObjectClass(env, process) );
|
||||
@ -905,5 +980,3 @@ void internal_getProcessClass( JNIEnv *env, jobject process ) {
|
||||
}
|
||||
|
||||
#endif /* LIBJUAFS */
|
||||
|
||||
|
||||
|
@ -4,15 +4,32 @@
|
||||
#include <jni.h>
|
||||
#include "Exceptions.h"
|
||||
|
||||
#ifndef LIBJUAFS
|
||||
#include <afs_Admin.h>
|
||||
#include <afs_kasAdmin.h>
|
||||
|
||||
// error codes
|
||||
#define JAFSADMNOMEM 1050 // Memory problems
|
||||
/**
|
||||
* ERROR CODES
|
||||
*
|
||||
* Please add any internal error codes to the ErrorMessages.properties
|
||||
* file located in src/JAVA/classes/
|
||||
*/
|
||||
#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
|
||||
#define JAFSNULLARG 1054 // Null argument (general)
|
||||
#define JAFSNULLUSER 1055 // User argument null
|
||||
#define JAFSNULLPASS 1056 // Password argument null
|
||||
#define JAFSNULLGROUP 1057 // Group name argument null
|
||||
#define JAFSNULLOWNER 1058 // Group owner name argument null
|
||||
#define JAFSNULLVOLUME 1059 // Volume name argument null
|
||||
#define JAFSNULLPART 1060 // Partition name argument null
|
||||
#define JAFSNULLPROCESS 1061 // Process name argument null
|
||||
#define JAFSNULLSERVER 1062 // Server name argument null
|
||||
#define JAFSNULLCELL 1063 // Cell name argument null
|
||||
#define JAFSNULLPATH 1064 // Path argument null
|
||||
#define JAFSNULLACL 1065 // ACL string argument null
|
||||
|
||||
#ifndef LIBJUAFS
|
||||
#include <afs_Admin.h>
|
||||
#include <afs_kasAdmin.h>
|
||||
|
||||
// make an identity out of a full name (possibly including an instance )
|
||||
void internal_makeKasIdentity( const char *fullName, kas_identity_p who );
|
||||
@ -54,8 +71,9 @@ void throwException( JNIEnv *env, jclass *excCls, char *excClsName, jmethodID *i
|
||||
// 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);
|
||||
int setError (JNIEnv *env, jobject *obj, int code);
|
||||
int setString(JNIEnv *env, jobject *obj, char *field, char *string);
|
||||
char* getNativeString(JNIEnv *env, jstring jstr);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <kautils.h>
|
||||
|
||||
//// definitions in Internal.c //////////////////
|
||||
extern jclass keyCls;
|
||||
extern jclass keyCls;
|
||||
extern jfieldID key_versionField;
|
||||
extern jfieldID key_encryptionKeyField;
|
||||
extern jfieldID key_lastModDateField;
|
||||
@ -51,7 +51,7 @@ void fillKeyInfo( JNIEnv *env, jobject key, bos_KeyInfo_t keyEntry )
|
||||
int i;
|
||||
|
||||
// get the class fields if need be
|
||||
if( keyCls == 0 ) {
|
||||
if ( keyCls == 0 ) {
|
||||
internal_getKeyClass( env, key );
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ void fillKeyInfo( JNIEnv *env, jobject key, bos_KeyInfo_t keyEntry )
|
||||
|
||||
convertedKey = (char *) malloc( sizeof(char *)*
|
||||
(sizeof(keyEntry.key.key)*4+1) );
|
||||
if( !convertedKey ) {
|
||||
if ( !convertedKey ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
@ -100,7 +100,7 @@ Java_org_openafs_jafs_Key_getKeyInfo
|
||||
void *iterationId;
|
||||
int done;
|
||||
|
||||
if( !bos_KeyGetBegin( (void *) serverHandle, &iterationId, &ast ) ) {
|
||||
if ( !bos_KeyGetBegin( (void *) serverHandle, &iterationId, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
@ -111,11 +111,11 @@ Java_org_openafs_jafs_Key_getKeyInfo
|
||||
// one with the matching version
|
||||
while( !done ) {
|
||||
|
||||
if( !bos_KeyGetNext( iterationId, &keyEntry, &ast ) ) {
|
||||
if ( !bos_KeyGetNext( iterationId, &keyEntry, &ast ) ) {
|
||||
// no matching key
|
||||
if( ast == ADMITERATORDONE ) {
|
||||
if ( ast == ADMITERATORDONE ) {
|
||||
afs_status_t astnew;
|
||||
if( !bos_KeyGetDone( iterationId, &astnew ) ) {
|
||||
if ( !bos_KeyGetDone( iterationId, &astnew ) ) {
|
||||
throwAFSException( env, astnew );
|
||||
return;
|
||||
}
|
||||
@ -128,7 +128,7 @@ Java_org_openafs_jafs_Key_getKeyInfo
|
||||
}
|
||||
}
|
||||
|
||||
if( keyEntry.keyVersionNumber == version ) {
|
||||
if ( keyEntry.keyVersionNumber == version ) {
|
||||
done = TRUE;
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ Java_org_openafs_jafs_Key_getKeyInfo
|
||||
|
||||
fillKeyInfo( env, key, keyEntry );
|
||||
|
||||
if( !bos_KeyGetDone( iterationId, &ast ) ) {
|
||||
if ( !bos_KeyGetDone( iterationId, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
@ -161,19 +161,20 @@ Java_org_openafs_jafs_Key_create
|
||||
jstring jkeyString)
|
||||
{
|
||||
afs_status_t ast;
|
||||
const char *keyString;
|
||||
char *keyString;
|
||||
char *cellName;
|
||||
kas_encryptionKey_p key =
|
||||
(kas_encryptionKey_p) malloc( sizeof(kas_encryptionKey_t) );
|
||||
|
||||
if( !key ) {
|
||||
if ( !key ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
|
||||
if( jkeyString != NULL ) {
|
||||
keyString = (*env)->GetStringUTFChars(env, jkeyString, 0);
|
||||
if( !keyString ) {
|
||||
if ( jkeyString != NULL ) {
|
||||
keyString = getNativeString(env, jkeyString);
|
||||
if ( keyString == NULL ) {
|
||||
free( key );
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
@ -181,37 +182,29 @@ Java_org_openafs_jafs_Key_create
|
||||
keyString = NULL;
|
||||
}
|
||||
|
||||
if( !afsclient_CellNameGet( (void *) cellHandle, &cellName, &ast ) ) {
|
||||
if ( !afsclient_CellNameGet( (void *) cellHandle, &cellName, &ast ) ) {
|
||||
free( key );
|
||||
if( keyString != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jkeyString, keyString);
|
||||
}
|
||||
if ( keyString != NULL ) free( keyString );
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !kas_StringToKey( cellName, keyString, key, &ast ) ) {
|
||||
if ( !kas_StringToKey( cellName, keyString, key, &ast ) ) {
|
||||
free( key );
|
||||
if( keyString != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jkeyString, keyString);
|
||||
}
|
||||
if ( keyString != NULL ) free( keyString );
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !bos_KeyCreate( (void *) serverHandle, version, key, &ast ) ) {
|
||||
if ( !bos_KeyCreate( (void *) serverHandle, version, key, &ast ) ) {
|
||||
free( key );
|
||||
if( keyString != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jkeyString, keyString);
|
||||
}
|
||||
if ( keyString != NULL ) free( keyString );
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
|
||||
free( key );
|
||||
if( keyString != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jkeyString, keyString);
|
||||
}
|
||||
if ( keyString != NULL ) free( keyString );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -226,24 +219,20 @@ JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Key_delete
|
||||
(JNIEnv *env, jclass cls, jint serverHandle, jint version )
|
||||
{
|
||||
afs_status_t ast;
|
||||
afs_status_t ast;
|
||||
|
||||
if( !bos_KeyDelete( (void *) serverHandle, version, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
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;
|
||||
if ( keyCls ) {
|
||||
(*env)->DeleteGlobalRef(env, keyCls);
|
||||
keyCls = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -27,28 +27,36 @@ COMPILE_ET=${TOP_SRCDIR}/comerr/compile_et
|
||||
RXGEN=${TOP_SRCDIR}/rxgen/rxgen
|
||||
SYS_NAME=@AFS_SYSNAME@
|
||||
|
||||
include ../../config/Makefile.${SYS_NAME}
|
||||
|
||||
CC = ${MT_CC}
|
||||
SHARED_FLAGS = -shared
|
||||
OBJECT_FLAGS = -fPIC -c
|
||||
|
||||
ifeq "$(BUILD_TYPE)" "admin"
|
||||
INC := -I${TOP_INCDIR} -I${TOP_INCDIR}/afs/ -I${JAVA_HOME}/include ${JNI_INC}
|
||||
INC := -I${TOP_INCDIR} -I${TOP_INCDIR}/afs/ ${JNI_INC}
|
||||
CFLAGS := ${INC} ${DBG} ${OPTMZ} -I${TOP_SRCDIR}/config ${MT_CFLAGS}
|
||||
else
|
||||
INC := -I${TOP_SRCDIR}/libuafs -I${TOP_INCDIR} -I${JAVA_HOME}/include ${JNI_INC}
|
||||
INC := -I${TOP_SRCDIR}/libuafs -I${TOP_INCDIR} -I${TOP_SRCDIR} ${JNI_INC}
|
||||
CFLAGS := ${INC} ${DBG} ${OPTMZ} ${FSINCLUDES} -D_REENTRANT -DLIBJUAFS ${MT_CFLAGS}
|
||||
endif
|
||||
|
||||
ifeq "$(INCREMENT_BUILD)" "false"
|
||||
INCREMENT_CMD :=
|
||||
else
|
||||
INCREMENT_CMD := ${RM} -f ${LIBJAFSADMDIR}VersionInfo.o; perl buildinfo.pl ${LIBJAFSADMDIR}VersionInfo.h -i;
|
||||
endif
|
||||
|
||||
LIBJAFSADMDIR = ./
|
||||
ROOTPACKAGEDIR = ../classes
|
||||
RELPACKAGEDIR = org/openafs/jafs/
|
||||
PACKAGEDIR = ${ROOTPACKAGEDIR}/${RELPACKAGEDIR}
|
||||
JAVADOCSDIR = javadocs/
|
||||
JAVADOCSDIR = ../javadocs/
|
||||
BUILD_VERSION = `perl buildinfo.pl ${LIBJAFSADMDIR}VersionInfo.h -version`
|
||||
|
||||
JAVAH = ${JAVA_HOME}/bin/javah -classpath ${ROOTPACKAGEDIR} -jni -d ${LIBJAFSADMDIR}
|
||||
JAVAC = ${JAVA_HOME}/bin/javac -classpath ${ROOTPACKAGEDIR}
|
||||
JAVADOC = ${JAVA_HOME}/bin/javadoc
|
||||
|
||||
J_NATIVE_PREFIX = org.openafs.jafs.
|
||||
C_NATIVE_PREFIX = org_openafs_jafs_
|
||||
@ -69,6 +77,7 @@ PACKAGE =\
|
||||
${PACKAGEDIR}Server.class \
|
||||
${PACKAGEDIR}Token.class \
|
||||
${PACKAGEDIR}User.class \
|
||||
${PACKAGEDIR}VersionInfo.class \
|
||||
${PACKAGEDIR}Volume.class
|
||||
|
||||
LIBJAFS_OBJS =\
|
||||
@ -77,7 +86,8 @@ LIBJAFS_OBJS =\
|
||||
${LIBJAFSADMDIR}FileInputStream.o \
|
||||
${LIBJAFSADMDIR}FileOutputStream.o \
|
||||
${LIBJAFSADMDIR}Internal.o \
|
||||
${LIBJAFSADMDIR}UserToken.o
|
||||
${LIBJAFSADMDIR}UserToken.o \
|
||||
${LIBJAFSADMDIR}VersionInfo.o
|
||||
|
||||
LIBJAFSADM_OBJS =\
|
||||
${LIBJAFSADMDIR}AdminToken.o \
|
||||
@ -89,6 +99,7 @@ LIBJAFSADM_OBJS =\
|
||||
${LIBJAFSADMDIR}Process.o \
|
||||
${LIBJAFSADMDIR}Server.o \
|
||||
${LIBJAFSADMDIR}User.o \
|
||||
${LIBJAFSADMDIR}VersionInfo.o \
|
||||
${LIBJAFSADMDIR}Volume.o
|
||||
|
||||
CORRELATING_SOURCE_FILES =\
|
||||
@ -103,6 +114,7 @@ CORRELATING_SOURCE_FILES =\
|
||||
${LIBJAFSADMDIR}Process.c \
|
||||
${LIBJAFSADMDIR}Server.c \
|
||||
${LIBJAFSADMDIR}User.c \
|
||||
${LIBJAFSADMDIR}VersionInfo.c \
|
||||
${LIBJAFSADMDIR}Volume.c
|
||||
|
||||
JAVA_HEADERS = ${PACKAGE:${PACKAGEDIR}%.class=${C_NATIVE_PREFIX}%.h}
|
||||
@ -132,15 +144,14 @@ LIBJAFSADM_LIBS =\
|
||||
${TOP_LIBDIR}/libafsauthent.a \
|
||||
${TOP_LIBDIR}/libafsrpc.a \
|
||||
${TOP_LIBDIR}/libcmd.a \
|
||||
${TOP_LIBDIR}/util.a \
|
||||
-lresolv \
|
||||
-lpthread
|
||||
|
||||
|
||||
JARFILE = jafs.jar
|
||||
|
||||
include ../../config/Makefile.${SYS_NAME}
|
||||
|
||||
all: ${TOP_JLIBDIR} libjafs libjafsadm ${PACKAGE} all_jar
|
||||
all: ${TOP_JLIBDIR} libjafs libjafsadm ${PACKAGE} jar
|
||||
|
||||
install: all ${DESTDIR}${libdir}/libjafs.so ${DESTDIR}${libdir}/libjafsadm.so ${PACKAGE} install_jar
|
||||
if [ ! -e /usr/afswsp ]; then \
|
||||
@ -163,27 +174,39 @@ install: all ${DESTDIR}${libdir}/libjafs.so ${DESTDIR}${libdir}/libjafsadm.so $
|
||||
ln -s /usr/vice/etc/ThisCell /usr/afswsp/etc/; \
|
||||
fi
|
||||
|
||||
### Clean "C" and Java objects
|
||||
clean:
|
||||
${RM} -f ${PACKAGEDIR}*.class ${LIBJAFSADMDIR}*.o ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}*.h
|
||||
${RM} -f ${PACKAGEDIR}*.class ${LIBJAFSADMDIR}*.o ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}*.h ${LIBJAFSADMDIR}acltest
|
||||
${RM} -fR ${JAVADOCSDIR}
|
||||
|
||||
### Clean just "C" objects
|
||||
cleanc:
|
||||
${RM} -f ${LIBJAFSADMDIR}*.o ${LIBJAFSADMDIR}acltest
|
||||
|
||||
increment-build:
|
||||
${INCREMENT_CMD} \
|
||||
export INCREMENT_BUILD=false;
|
||||
|
||||
setup: FORCE
|
||||
if [ ! -e ./h ]; then \
|
||||
ln -s /usr/include/sys h; \
|
||||
fi; \
|
||||
|
||||
${TOP_JLIBDIR}:
|
||||
mkdir -p $@
|
||||
|
||||
FORCE: ;
|
||||
|
||||
############# Test program ###############################
|
||||
|
||||
acltest: ${LIBJAFSADMDIR}/acltest.c
|
||||
${CC} ${CFLAGS} -o $@ $^ ${LIBJAFS_LIBS}
|
||||
|
||||
############# Shared library ###############################
|
||||
|
||||
libjafs: setup
|
||||
libjafs: setup increment-build
|
||||
${RM} -f ${LIBJAFSADMDIR}Internal.o; \
|
||||
export BUILD_TYPE=user; \
|
||||
${MAKE} ${TOP_LIBDIR}/libjafs.so
|
||||
|
||||
libjafsadm:
|
||||
libjafsadm: increment-build
|
||||
${RM} -f ${LIBJAFSADMDIR}Internal.o; \
|
||||
export BUILD_TYPE=admin; \
|
||||
${MAKE} ${TOP_LIBDIR}/libjafsadm.so
|
||||
@ -207,7 +230,7 @@ ${LIBJAFSADM_OBJS}: %.o: %.c
|
||||
|
||||
############## C files #####################################
|
||||
|
||||
${CORRELATING_SOURCE_FILES}: ${LIBJAFSADMDIR}%.c: ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}%.h ${LIBJAFSADMDIR}Internal.h
|
||||
${CORRELATING_SOURCE_FILES}: ${LIBJAFSADMDIR}%.c: ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}%.h ${LIBJAFSADMDIR}Internal.h ${LIBJAFSADMDIR}VersionInfo.h
|
||||
|
||||
${LIBJAFSADMDIR}AdminToken.c: ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}Token.h ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}Cell.h
|
||||
|
||||
@ -215,6 +238,8 @@ ${LIBJAFSADMDIR}Internal.c: ${LIBJAFSADMDIR}Internal.h
|
||||
|
||||
${LIBJAFSADMDIR}UserToken.c: ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}Token.h
|
||||
|
||||
${LIBJAFSADMDIR}VersionInfo.c: ${LIBJAFSADMDIR}VersionInfo.h ${LIBJAFSADMDIR}${C_NATIVE_PREFIX}VersionInfo.h
|
||||
|
||||
############## Package javac section #########################
|
||||
|
||||
${PACKAGEDIR}%.class: ${PACKAGEDIR}%.java
|
||||
@ -225,9 +250,22 @@ ${PACKAGEDIR}%.class: ${PACKAGEDIR}%.java
|
||||
${JAVA_HEADERS}: ${C_NATIVE_PREFIX}%.h: ${PACKAGEDIR}%.class
|
||||
${JAVAH} ${J_NATIVE_PREFIX}$*
|
||||
|
||||
############## Javadoc section ###############################
|
||||
|
||||
javadocs:
|
||||
echo "Preparing Javadoc API documentation..."
|
||||
${JAVADOC} -version -breakiterator \
|
||||
-link http://java.sun.com/j2se/1.4/docs/api/ \
|
||||
-windowtitle "Java AFS API" -header "<B>JAFS API v${BUILD_VERSION}</B>" \
|
||||
-doctitle "<B>JAFS</B> API v${BUILD_VERSION}" \
|
||||
-use -d ${JAVADOCSDIR} \
|
||||
-sourcepath ${ROOTPACKAGEDIR} \
|
||||
-classpath ${ROOTPACKAGEDIR} \
|
||||
-package org.openafs.jafs
|
||||
|
||||
############# JAR file #####################################
|
||||
|
||||
all_jar: clean_jar
|
||||
jar: clean_jar
|
||||
cd ${ROOTPACKAGEDIR}; ${JAVA_HOME}/bin/jar -cMf ${TOP_JLIBDIR}/${JARFILE} *.properties ${RELPACKAGEDIR}*.class
|
||||
|
||||
install_jar: clean_jar
|
||||
@ -236,5 +274,6 @@ install_jar: clean_jar
|
||||
clean_jar:
|
||||
${RM} -f ${TOP_JLIBDIR}/${JARFILE}
|
||||
|
||||
|
||||
clean_libs:
|
||||
${RM} -f ${TOP_LIBDIR}/libjafs.so ${TOP_LIBDIR}/libjafsadm.so
|
||||
|
||||
|
@ -40,7 +40,7 @@ extern jfieldID volume_cachedInfoField;
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
///// definition in jafs_Volume.c /////////////////
|
||||
///// Definition in jafs_Volume.c /////////////////
|
||||
|
||||
extern void fillVolumeInfo
|
||||
( JNIEnv *env, jobject volume, vos_volumeEntry_t volEntry );
|
||||
@ -65,14 +65,14 @@ void fillPartitionInfo
|
||||
afs_status_t ast;
|
||||
|
||||
// get the class fields if need be
|
||||
if( partitionCls == 0 ) {
|
||||
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 ) ) {
|
||||
if ( !vos_PartitionNameToId( partEntry.name, (int *) &id, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
@ -138,33 +138,28 @@ Java_org_openafs_jafs_Partition_translateNameToID
|
||||
{
|
||||
afs_status_t ast;
|
||||
jint id;
|
||||
const char *name;
|
||||
char *name;
|
||||
|
||||
if( jname != NULL ) {
|
||||
name = (*env)->GetStringUTFChars(env, jname, 0);
|
||||
if( !name ) {
|
||||
if ( jname != NULL ) {
|
||||
name = getNativeString(env, jname);
|
||||
if ( name == NULL ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
name = NULL;
|
||||
throwAFSException( env, JAFSNULLPART );
|
||||
return -1;
|
||||
}
|
||||
|
||||
// get the id
|
||||
if( !vos_PartitionNameToId( name, (unsigned int *) &id, &ast ) ) {
|
||||
if( name != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jname, name);
|
||||
}
|
||||
if ( !vos_PartitionNameToId( name, (unsigned int *) &id, &ast ) ) {
|
||||
id = -1;
|
||||
throwAFSException( env, ast );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( name != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jname, name);
|
||||
}
|
||||
free( name );
|
||||
|
||||
return id;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -181,24 +176,22 @@ Java_org_openafs_jafs_Partition_translateIDToName
|
||||
{
|
||||
afs_status_t ast;
|
||||
char *name = (char *) malloc( sizeof(char)*VOS_MAX_PARTITION_NAME_LEN);
|
||||
jstring jname;
|
||||
jstring jname = NULL;
|
||||
|
||||
if( !name ) {
|
||||
if ( name == NULL ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// get the name
|
||||
if( !vos_PartitionIdToName( (unsigned int) id, name, &ast ) ) {
|
||||
free(name);
|
||||
if ( vos_PartitionIdToName( (unsigned int) id, name, &ast ) ) {
|
||||
jname = (*env)->NewStringUTF(env, name);
|
||||
} else {
|
||||
throwAFSException( env, ast );
|
||||
return NULL;
|
||||
}
|
||||
free( name );
|
||||
|
||||
jname = (*env)->NewStringUTF(env, name);
|
||||
free(name);
|
||||
return jname;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -222,7 +215,7 @@ Java_org_openafs_jafs_Partition_getVolumeCount
|
||||
vos_volumeEntry_t volEntry;
|
||||
int i = 0;
|
||||
|
||||
if( !vos_VolumeGetBegin( (void *) cellHandle, (void *) serverHandle, NULL,
|
||||
if ( !vos_VolumeGetBegin( (void *) cellHandle, (void *) serverHandle, NULL,
|
||||
(unsigned int) partition, &iterationId, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return -1;
|
||||
@ -230,7 +223,7 @@ Java_org_openafs_jafs_Partition_getVolumeCount
|
||||
|
||||
while ( vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) i++;
|
||||
|
||||
if( ast != ADMITERATORDONE ) {
|
||||
if ( ast != ADMITERATORDONE ) {
|
||||
throwAFSException( env, ast );
|
||||
return -1;
|
||||
}
|
||||
@ -260,10 +253,10 @@ Java_org_openafs_jafs_Partition_getVolumesBegin
|
||||
afs_status_t ast;
|
||||
void *iterationId;
|
||||
|
||||
if( !vos_VolumeGetBegin( (void *) cellHandle, (void *) serverHandle, NULL,
|
||||
if ( !vos_VolumeGetBegin( (void *) cellHandle, (void *) serverHandle, NULL,
|
||||
(unsigned int) partition, &iterationId, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (jint) iterationId;
|
||||
@ -294,15 +287,15 @@ Java_org_openafs_jafs_Partition_getVolumesBeginAt
|
||||
vos_volumeEntry_t volEntry;
|
||||
int i;
|
||||
|
||||
if( !vos_VolumeGetBegin( (void *) cellHandle, (void *) serverHandle, NULL,
|
||||
if ( !vos_VolumeGetBegin( (void *) cellHandle, (void *) serverHandle, NULL,
|
||||
(unsigned int) partition, &iterationId, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
for ( i = 1; i < index; i++) {
|
||||
if( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) {
|
||||
if( ast == ADMITERATORDONE ) {
|
||||
if ( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) {
|
||||
if ( ast == ADMITERATORDONE ) {
|
||||
return 0;
|
||||
} else {
|
||||
throwAFSException( env, ast );
|
||||
@ -332,12 +325,12 @@ Java_org_openafs_jafs_Partition_getVolumesNextString
|
||||
jstring jvolume;
|
||||
vos_volumeEntry_t volEntry;
|
||||
|
||||
if( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) {
|
||||
if( ast == ADMITERATORDONE ) {
|
||||
if ( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) {
|
||||
if ( ast == ADMITERATORDONE ) {
|
||||
return NULL;
|
||||
} else {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -365,8 +358,8 @@ Java_org_openafs_jafs_Partition_getVolumesNext
|
||||
jstring jvolume;
|
||||
vos_volumeEntry_t volEntry;
|
||||
|
||||
if( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) {
|
||||
if( ast == ADMITERATORDONE ) {
|
||||
if ( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) {
|
||||
if ( ast == ADMITERATORDONE ) {
|
||||
return 0;
|
||||
} else {
|
||||
throwAFSException( env, ast );
|
||||
@ -378,7 +371,7 @@ Java_org_openafs_jafs_Partition_getVolumesNext
|
||||
fillVolumeInfo( env, jvolumeObject, volEntry );
|
||||
|
||||
// get the class fields if need be
|
||||
if( volumeCls == 0 ) {
|
||||
if ( volumeCls == 0 ) {
|
||||
internal_getVolumeClass( env, jvolumeObject );
|
||||
}
|
||||
(*env)->SetBooleanField( env, jvolumeObject, volume_cachedInfoField, TRUE );
|
||||
@ -410,8 +403,8 @@ Java_org_openafs_jafs_Partition_getVolumesAdvanceTo
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < advanceCount; i++) {
|
||||
if( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) {
|
||||
if( ast == ADMITERATORDONE ) {
|
||||
if ( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) {
|
||||
if ( ast == ADMITERATORDONE ) {
|
||||
return 0;
|
||||
} else {
|
||||
throwAFSException( env, ast );
|
||||
@ -424,7 +417,7 @@ Java_org_openafs_jafs_Partition_getVolumesAdvanceTo
|
||||
fillVolumeInfo( env, jvolumeObject, volEntry );
|
||||
|
||||
// get the class fields if need be
|
||||
if( volumeCls == 0 ) {
|
||||
if ( volumeCls == 0 ) {
|
||||
internal_getVolumeClass( env, jvolumeObject );
|
||||
}
|
||||
(*env)->SetBooleanField( env, jvolumeObject, volume_cachedInfoField, TRUE );
|
||||
@ -445,7 +438,7 @@ Java_org_openafs_jafs_Partition_getVolumesDone
|
||||
{
|
||||
afs_status_t ast;
|
||||
|
||||
if( !vos_VolumeGetDone( (void *) iterationId, &ast ) ) {
|
||||
if ( !vos_VolumeGetDone( (void *) iterationId, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
@ -456,27 +449,8 @@ JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Partition_reclaimPartitionMemory
|
||||
(JNIEnv *env, jclass cls)
|
||||
{
|
||||
if( partitionCls ) {
|
||||
(*env)->DeleteGlobalRef(env, partitionCls);
|
||||
partitionCls = 0;
|
||||
if ( partitionCls ) {
|
||||
(*env)->DeleteGlobalRef(env, partitionCls);
|
||||
partitionCls = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
///// definitions in Internal.c ////////////////////
|
||||
|
||||
extern jclass processCls;
|
||||
extern jclass processCls;
|
||||
extern jfieldID process_nameField;
|
||||
extern jfieldID process_typeField;
|
||||
extern jfieldID process_stateField;
|
||||
@ -52,9 +52,9 @@ extern jfieldID process_stateBadFileAccessField;
|
||||
* 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 ) {
|
||||
|
||||
void getProcessInfoChar
|
||||
(JNIEnv *env, void *serverHandle, const char *processName, jobject process)
|
||||
{
|
||||
afs_status_t ast;
|
||||
bos_ProcessType_t type;
|
||||
bos_ProcessInfo_t infoEntry;
|
||||
@ -62,11 +62,11 @@ void getProcessInfoChar( JNIEnv *env, void *serverHandle,
|
||||
char *auxStatus;
|
||||
|
||||
// get class fields if need be
|
||||
if( processCls == 0 ) {
|
||||
if ( processCls == 0 ) {
|
||||
internal_getProcessClass( env, process );
|
||||
}
|
||||
|
||||
if( !bos_ProcessInfoGet( serverHandle, processName, &type,
|
||||
if ( !bos_ProcessInfoGet( serverHandle, processName, &type,
|
||||
&infoEntry, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
@ -116,17 +116,18 @@ void getProcessInfoChar( JNIEnv *env, void *serverHandle,
|
||||
|
||||
// set state variable
|
||||
auxStatus = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN );
|
||||
if( !auxStatus ) {
|
||||
if ( !auxStatus ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
if( !bos_ProcessExecutionStateGet( (void *) serverHandle, processName,
|
||||
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,
|
||||
@ -164,14 +165,14 @@ void getProcessInfoChar( JNIEnv *env, void *serverHandle,
|
||||
infoEntry.processErrorSignal );
|
||||
|
||||
// set stateOk to true if no core dump
|
||||
if( infoEntry.state & BOS_PROCESS_CORE_DUMPED ) {
|
||||
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 ) {
|
||||
if ( infoEntry.state & BOS_PROCESS_TOO_MANY_ERRORS ) {
|
||||
(*env)->SetBooleanField(env, process,
|
||||
process_stateTooManyErrorsField, TRUE );
|
||||
} else {
|
||||
@ -180,7 +181,7 @@ void getProcessInfoChar( JNIEnv *env, void *serverHandle,
|
||||
}
|
||||
|
||||
// set stateBadFileAccess
|
||||
if( infoEntry.state & BOS_PROCESS_BAD_FILE_ACCESS ) {
|
||||
if ( infoEntry.state & BOS_PROCESS_BAD_FILE_ACCESS ) {
|
||||
(*env)->SetBooleanField(env, process,
|
||||
process_stateBadFileAccessField, TRUE );
|
||||
} else {
|
||||
@ -202,34 +203,30 @@ void getProcessInfoChar( JNIEnv *env, void *serverHandle,
|
||||
* in the information
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Process_getProcessInfo (JNIEnv *env, jclass cls,
|
||||
jint serverHandle,
|
||||
jstring jname,
|
||||
jobject process) {
|
||||
Java_org_openafs_jafs_Process_getProcessInfo
|
||||
(JNIEnv *env, jclass cls, jint serverHandle, jstring jname, jobject process)
|
||||
{
|
||||
char *name;
|
||||
|
||||
const char *name;
|
||||
|
||||
if( jname != NULL ) {
|
||||
name = (*env)->GetStringUTFChars(env, jname, 0);
|
||||
if( !name ) {
|
||||
if ( jname != NULL ) {
|
||||
name = getNativeString(env, jname);
|
||||
if ( name == NULL ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
name = NULL;
|
||||
throwAFSException( env, JAFSNULLPROCESS );
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
if ( processCls == NULL ) {
|
||||
internal_getProcessClass( env, process );
|
||||
}
|
||||
|
||||
(*env)->SetObjectField(env, process, process_nameField, jname);
|
||||
free( name );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -258,132 +255,91 @@ Java_org_openafs_jafs_Process_getProcessInfo (JNIEnv *env, jclass cls,
|
||||
* null
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Process_create (JNIEnv *env, jclass cls,
|
||||
jint serverHandle, jstring jname,
|
||||
jint jtype, jstring jpath,
|
||||
jstring jcronTime,
|
||||
jstring jnotifier) {
|
||||
Java_org_openafs_jafs_Process_create
|
||||
(JNIEnv *env, jclass cls, jint serverHandle, jstring jname, jint jtype,
|
||||
jstring jpath, jstring jcronTime, jstring jnotifier)
|
||||
{
|
||||
afs_status_t ast;
|
||||
bos_ProcessType_t type;
|
||||
char *name;
|
||||
char *path;
|
||||
char *cronTime;
|
||||
char *notifier;
|
||||
|
||||
afs_status_t ast;
|
||||
bos_ProcessType_t type;
|
||||
const char *name;
|
||||
const char *path;
|
||||
const char *cronTime;
|
||||
const char *notifier;
|
||||
if ( jname != NULL ) {
|
||||
name = getNativeString(env, jname);
|
||||
if ( name == NULL ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
throwAFSException( env, JAFSNULLPROCESS );
|
||||
return;
|
||||
}
|
||||
|
||||
if( jname != NULL ) {
|
||||
name = (*env)->GetStringUTFChars(env, jname, 0);
|
||||
if( !name ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
name = NULL;
|
||||
if ( jpath != NULL ) {
|
||||
path = getNativeString(env, jpath);
|
||||
if ( path == NULL ) {
|
||||
free( name );
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
path = 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:
|
||||
free( name );
|
||||
if ( path != NULL ) free( path );
|
||||
throwAFSException( env, jtype );
|
||||
return;
|
||||
}
|
||||
|
||||
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 = getNativeString(env, jcronTime);
|
||||
if ( !cronTime ) {
|
||||
free( name );
|
||||
if ( path != NULL ) free( path );
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
cronTime = NULL;
|
||||
}
|
||||
|
||||
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 = getNativeString(env, jnotifier);
|
||||
if ( !notifier ) {
|
||||
free( name );
|
||||
if ( path != NULL ) free( path );
|
||||
if ( cronTime != NULL ) free( cronTime );
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
notifier = 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);
|
||||
}
|
||||
if ( !bos_ProcessCreate( (void *) serverHandle, name, type, path,
|
||||
cronTime, notifier, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
}
|
||||
|
||||
// release strings
|
||||
free( name );
|
||||
if ( path != NULL ) free( path );
|
||||
if ( cronTime != NULL ) free( cronTime );
|
||||
if ( notifier != NULL ) free( notifier );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -396,34 +352,28 @@ Java_org_openafs_jafs_Process_create (JNIEnv *env, jclass cls,
|
||||
* jname the name of the process to remove
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Process_delete (JNIEnv *env, jclass cls,
|
||||
jint serverHandle, jstring jname) {
|
||||
Java_org_openafs_jafs_Process_delete
|
||||
(JNIEnv *env, jclass cls, jint serverHandle, jstring jname)
|
||||
{
|
||||
afs_status_t ast;
|
||||
char *name;
|
||||
|
||||
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 ( jname != NULL ) {
|
||||
name = getNativeString(env, jname);
|
||||
if ( !name ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
throwAFSException( env, JAFSNULLPROCESS );
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
if ( !bos_ProcessDelete( (void *) serverHandle, name, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
}
|
||||
|
||||
free( name );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -436,35 +386,29 @@ Java_org_openafs_jafs_Process_delete (JNIEnv *env, jclass cls,
|
||||
* jname the name of the process to stop
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Process_stop (JNIEnv *env, jclass cls,
|
||||
jint serverHandle, jstring jname) {
|
||||
Java_org_openafs_jafs_Process_stop
|
||||
(JNIEnv *env, jclass cls, jint serverHandle, jstring jname)
|
||||
{
|
||||
afs_status_t ast;
|
||||
char *name;
|
||||
|
||||
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 ( jname != NULL ) {
|
||||
name = getNativeString(env, jname);
|
||||
if ( !name ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
throwAFSException( env, JAFSNULLPROCESS );
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
if ( !bos_ProcessExecutionStateSet( (void *) serverHandle, name,
|
||||
BOS_PROCESS_STOPPED, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
}
|
||||
|
||||
free( name );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -477,35 +421,29 @@ Java_org_openafs_jafs_Process_stop (JNIEnv *env, jclass cls,
|
||||
* jname the name of the process to start
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Process_start (JNIEnv *env, jclass cls,
|
||||
jint serverHandle, jstring jname) {
|
||||
Java_org_openafs_jafs_Process_start
|
||||
(JNIEnv *env, jclass cls, jint serverHandle, jstring jname)
|
||||
{
|
||||
afs_status_t ast;
|
||||
char *name;
|
||||
|
||||
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 ( jname != NULL ) {
|
||||
name = getNativeString(env, jname);
|
||||
if ( !name ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
throwAFSException( env, JAFSNULLPROCESS );
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
if ( !bos_ProcessExecutionStateSet( (void *) serverHandle, name,
|
||||
BOS_PROCESS_RUNNING, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
}
|
||||
|
||||
free( name );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -518,50 +456,37 @@ Java_org_openafs_jafs_Process_start (JNIEnv *env, jclass cls,
|
||||
* jname the name of the process to restart
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Process_restart (JNIEnv *env, jclass cls,
|
||||
jint serverHandle, jstring jname) {
|
||||
Java_org_openafs_jafs_Process_restart
|
||||
(JNIEnv *env, jclass cls, jint serverHandle, jstring jname)
|
||||
{
|
||||
afs_status_t ast;
|
||||
char *name;
|
||||
|
||||
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 ( jname != NULL ) {
|
||||
name = getNativeString(env, jname);
|
||||
if ( !name ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
throwAFSException( env, JAFSNULLPROCESS );
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
if ( !bos_ProcessRestart( (void *) serverHandle, name, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
}
|
||||
|
||||
free( 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;
|
||||
Java_org_openafs_jafs_Process_reclaimProcessMemory
|
||||
(JNIEnv *env, jclass cls)
|
||||
{
|
||||
if ( processCls ) {
|
||||
(*env)->DeleteGlobalRef(env, processCls);
|
||||
processCls = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -19,6 +19,8 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <afs/param.h>
|
||||
|
||||
#include "Internal.h"
|
||||
#include "org_openafs_jafs_Token.h"
|
||||
|
||||
@ -27,8 +29,8 @@
|
||||
#include <afs/vice.h>
|
||||
#include <afs/venus.h>
|
||||
#include <afs/afs_args.h>
|
||||
#include <afs/afs_osi.h>
|
||||
#include <afs/afs_usrops.h>
|
||||
/*#include <afs/afs_osi.h>
|
||||
#include <afs/afs_usrops.h>*/
|
||||
#include <pthread.h>
|
||||
|
||||
#ifdef DMALLOC
|
||||
@ -36,7 +38,9 @@
|
||||
#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,
|
||||
@ -47,7 +51,7 @@ extern int readCacheParms(char *afsMountPoint, char *afsConfDir,
|
||||
/**
|
||||
* Be carefull with the memory management:
|
||||
*
|
||||
* - For every GetStringUTFChars call the corresponding ReleaseStringUTFChars.
|
||||
* - For every getNativeString call the corresponding free().
|
||||
* - For every Get<type>ArrayElements call the corresponding
|
||||
* Release<type>ArrayElements
|
||||
* - For every malloc call the corresponding free.
|
||||
@ -167,45 +171,48 @@ Java_org_openafs_jafs_Token_klog (JNIEnv *env, jobject obj,
|
||||
char *password;
|
||||
char *cell;
|
||||
char *reason;
|
||||
jint rc = -1;
|
||||
int code;
|
||||
int code;
|
||||
jint rc = -1;
|
||||
|
||||
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 );
|
||||
if ( jcell != NULL ) {
|
||||
cell = getNativeString(env, jcell);
|
||||
if ( !cell ) {
|
||||
fprintf(stderr, "UserToken::klog(): failed to get cell name\n");
|
||||
throwMessageException( env, "Internal error, failed to translate cell name." );
|
||||
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 );
|
||||
if ( jusername != NULL ) {
|
||||
username = getNativeString(env, jusername);
|
||||
if ( !username ) {
|
||||
if ( cell != NULL ) free( cell );
|
||||
fprintf(stderr, "UserToken::klog(): failed to get username\n");
|
||||
throwMessageException( env, "Internal error, failed to translate username." );
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
username = NULL;
|
||||
if ( cell != NULL ) free( cell );
|
||||
throwAFSException( env, JAFSNULLUSER );
|
||||
return -1;
|
||||
}
|
||||
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 );
|
||||
|
||||
if ( jpassword != NULL ) {
|
||||
password = getNativeString(env, jpassword);
|
||||
if ( !password ) {
|
||||
if ( cell != NULL ) free( cell );
|
||||
free( username );
|
||||
fprintf(stderr, "UserToken::klog(): failed to get password\n");
|
||||
throwMessageException( env, "Internal error, failed to translate password." );
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
password = NULL;
|
||||
if ( cell != NULL ) free( cell );
|
||||
free( username );
|
||||
throwAFSException( env, JAFSNULLPASS );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (id == 0) {
|
||||
@ -218,34 +225,23 @@ Java_org_openafs_jafs_Token_klog (JNIEnv *env, jobject obj,
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
if ( cell != NULL ) free( cell );
|
||||
if ( username != NULL ) free( username );
|
||||
if ( password != NULL ) free( password );
|
||||
fprintf(stderr, "UserToken::klog(): uafs_klog failed to cell %s: %s\n",
|
||||
cell, reason);
|
||||
fprintf(stderr, "code = %d\n", code);
|
||||
throwAFSException( env, code );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
if ( cell != NULL ) free( cell );
|
||||
if ( username != NULL ) free( username );
|
||||
if ( password != NULL ) free( password );
|
||||
|
||||
/* return PAG ID */
|
||||
return rc;
|
||||
@ -315,7 +311,3 @@ JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_shutdown
|
||||
{
|
||||
uafs_Shutdown();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -56,13 +56,13 @@ extern jfieldID volume_typeField;
|
||||
* 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 ) {
|
||||
|
||||
extern void fillVolumeInfo
|
||||
( JNIEnv *env, jobject volume, vos_volumeEntry_t volEntry )
|
||||
{
|
||||
jstring jvolume;
|
||||
|
||||
// get the class fields if need be
|
||||
if( volumeCls == 0 ) {
|
||||
if ( volumeCls == 0 ) {
|
||||
internal_getVolumeClass( env, volume );
|
||||
}
|
||||
|
||||
@ -236,12 +236,10 @@ extern void fillVolumeInfo( JNIEnv *env, jobject volume,
|
||||
* the information
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Volume_getVolumeInfo (JNIEnv *env, jclass cls,
|
||||
jint cellHandle,
|
||||
jint serverHandle,
|
||||
jint partition, jint volID,
|
||||
jobject jvolumeObject) {
|
||||
|
||||
Java_org_openafs_jafs_Volume_getVolumeInfo
|
||||
(JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, jint partition,
|
||||
jint volID, jobject jvolumeObject)
|
||||
{
|
||||
afs_status_t ast;
|
||||
vos_volumeEntry_t volEntry;
|
||||
|
||||
@ -254,7 +252,6 @@ Java_org_openafs_jafs_Volume_getVolumeInfo (JNIEnv *env, jclass cls,
|
||||
}
|
||||
|
||||
fillVolumeInfo( env, jvolumeObject, volEntry );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -272,40 +269,34 @@ Java_org_openafs_jafs_Volume_getVolumeInfo (JNIEnv *env, jclass cls,
|
||||
* returns the numeric ID assigned to the volume
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_openafs_jafs_Volume_create (JNIEnv *env, jclass cls,
|
||||
jint cellHandle, jint serverHandle,
|
||||
jint partition, jstring jvolName,
|
||||
jint quota) {
|
||||
|
||||
Java_org_openafs_jafs_Volume_create
|
||||
(JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle,
|
||||
jint partition, jstring jvolName, jint quota)
|
||||
{
|
||||
afs_status_t ast;
|
||||
const char *volName;
|
||||
char *volName;
|
||||
int id;
|
||||
|
||||
if( jvolName != NULL ) {
|
||||
volName = (*env)->GetStringUTFChars(env, jvolName, 0);
|
||||
if( !volName ) {
|
||||
if ( jvolName != NULL ) {
|
||||
volName = getNativeString(env, jvolName);
|
||||
if ( !volName ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
volName = NULL;
|
||||
throwAFSException( env, JAFSNULLVOLUME );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( !vos_VolumeCreate( (void *) cellHandle, (void *) serverHandle, 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);
|
||||
}
|
||||
free( volName );
|
||||
|
||||
return (jint) id;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -321,19 +312,18 @@ Java_org_openafs_jafs_Volume_create (JNIEnv *env, jclass cls,
|
||||
* volId the numeric id of the volume to delete
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Volume_delete (JNIEnv *env, jclass cls,
|
||||
jint cellHandle, jint serverHandle,
|
||||
jint partition, jint volID) {
|
||||
|
||||
Java_org_openafs_jafs_Volume_delete
|
||||
(JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle,
|
||||
jint partition, jint volID)
|
||||
{
|
||||
afs_status_t ast;
|
||||
|
||||
if( !vos_VolumeDelete( (void *) cellHandle, (void *) serverHandle, NULL,
|
||||
if ( !vos_VolumeDelete( (void *) cellHandle, (void *) serverHandle, NULL,
|
||||
(unsigned int) partition,
|
||||
(unsigned int) volID, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -346,18 +336,16 @@ Java_org_openafs_jafs_Volume_delete (JNIEnv *env, jclass cls,
|
||||
* volume
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Volume_createBackupVolume (JNIEnv *env, jclass cls,
|
||||
jint cellHandle,
|
||||
jint volID) {
|
||||
|
||||
Java_org_openafs_jafs_Volume_createBackupVolume
|
||||
(JNIEnv *env, jclass cls, jint cellHandle, jint volID)
|
||||
{
|
||||
afs_status_t ast;
|
||||
|
||||
if( !vos_BackupVolumeCreate( (void *) cellHandle, NULL,
|
||||
if ( !vos_BackupVolumeCreate( (void *) cellHandle, NULL,
|
||||
(unsigned int) volID, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -374,21 +362,18 @@ Java_org_openafs_jafs_Volume_createBackupVolume (JNIEnv *env, jclass cls,
|
||||
* create a read-only volume
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Volume_createReadOnlyVolume (JNIEnv *env, jclass cls,
|
||||
jint cellHandle,
|
||||
jint serverHandle,
|
||||
jint partition,
|
||||
jint volID) {
|
||||
|
||||
Java_org_openafs_jafs_Volume_createReadOnlyVolume
|
||||
(JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, jint partition,
|
||||
jint volID)
|
||||
{
|
||||
afs_status_t ast;
|
||||
|
||||
if( !vos_VLDBReadOnlySiteCreate( (void *) cellHandle, (void *) serverHandle,
|
||||
if ( !vos_VLDBReadOnlySiteCreate( (void *) cellHandle, (void *) serverHandle,
|
||||
NULL, (unsigned int) partition,
|
||||
(unsigned int) volID, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -405,21 +390,18 @@ Java_org_openafs_jafs_Volume_createReadOnlyVolume (JNIEnv *env, jclass cls,
|
||||
* delete the read-only volume
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Volume_deleteReadOnlyVolume (JNIEnv *env, jclass cls,
|
||||
jint cellHandle,
|
||||
jint serverHandle,
|
||||
jint partition,
|
||||
jint volID) {
|
||||
|
||||
Java_org_openafs_jafs_Volume_deleteReadOnlyVolume
|
||||
(JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, jint partition,
|
||||
jint volID)
|
||||
{
|
||||
afs_status_t ast;
|
||||
|
||||
if( !vos_VLDBReadOnlySiteDelete( (void *) cellHandle, (void *) serverHandle,
|
||||
if ( !vos_VLDBReadOnlySiteDelete( (void *) cellHandle, (void *) serverHandle,
|
||||
NULL, (unsigned int) partition,
|
||||
(unsigned int) volID, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -436,22 +418,19 @@ Java_org_openafs_jafs_Volume_deleteReadOnlyVolume (JNIEnv *env, jclass cls,
|
||||
* newQuota the new quota (in KB) to assign the volume
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Volume_changeQuota (JNIEnv *env, jclass cls,
|
||||
jint cellHandle,
|
||||
jint serverHandle,
|
||||
jint partition, jint volID,
|
||||
jint newQuota) {
|
||||
|
||||
Java_org_openafs_jafs_Volume_changeQuota
|
||||
(JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, jint partition,
|
||||
jint volID, jint newQuota)
|
||||
{
|
||||
afs_status_t ast;
|
||||
|
||||
if( !vos_VolumeQuotaChange( (void *) cellHandle, (void *) serverHandle,
|
||||
if ( !vos_VolumeQuotaChange( (void *) cellHandle, (void *) serverHandle,
|
||||
NULL, (unsigned int) partition,
|
||||
(unsigned int) volID, (unsigned int) newQuota,
|
||||
&ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -477,14 +456,13 @@ Java_org_openafs_jafs_Volume_move
|
||||
{
|
||||
afs_status_t ast;
|
||||
|
||||
if( !vos_VolumeMove( (void *) cellHandle, NULL, (unsigned int) volID,
|
||||
if ( !vos_VolumeMove( (void *) cellHandle, NULL, (unsigned int) volID,
|
||||
(void *) fromServerHandle, (unsigned int) fromPartition,
|
||||
(void *) toServerHandle, (unsigned int) toPartition,
|
||||
&ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -503,18 +481,17 @@ Java_org_openafs_jafs_Volume_release
|
||||
afs_status_t ast;
|
||||
vos_force_t force;
|
||||
|
||||
if( forceComplete ) {
|
||||
if ( forceComplete ) {
|
||||
force = VOS_FORCE;
|
||||
} else {
|
||||
force = VOS_NORMAL;
|
||||
}
|
||||
|
||||
if( !vos_VolumeRelease( (void *) cellHandle, NULL, (unsigned int) volID,
|
||||
if ( !vos_VolumeRelease( (void *) cellHandle, NULL, (unsigned int) volID,
|
||||
force, &ast )) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -533,38 +510,31 @@ Java_org_openafs_jafs_Volume_release
|
||||
* jdumpFile the full path of the file to which to dump
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Volume_dump (JNIEnv *env, jclass cls,
|
||||
jint cellHandle, jint serverHandle,
|
||||
jint partition, jint volID,
|
||||
jint startTime, jstring jdumpFile) {
|
||||
|
||||
Java_org_openafs_jafs_Volume_dump
|
||||
(JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, jint partition,
|
||||
jint volID, jint startTime, jstring jdumpFile)
|
||||
{
|
||||
afs_status_t ast;
|
||||
const char *dumpFile;
|
||||
char *dumpFile;
|
||||
|
||||
if( jdumpFile != NULL ) {
|
||||
dumpFile = (*env)->GetStringUTFChars(env, jdumpFile, 0);
|
||||
if( !dumpFile ) {
|
||||
if ( jdumpFile != NULL ) {
|
||||
dumpFile = getNativeString(env, jdumpFile);
|
||||
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 );
|
||||
throwAFSException( env, JAFSNULLARG );
|
||||
return;
|
||||
}
|
||||
|
||||
if( dumpFile != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jdumpFile, dumpFile);
|
||||
if ( !vos_VolumeDump( (void *) cellHandle, (void *) serverHandle, NULL,
|
||||
(unsigned int *) &partition, (unsigned int) volID,
|
||||
(unsigned int) startTime, dumpFile, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
}
|
||||
|
||||
free( dumpFile );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -586,34 +556,31 @@ Java_org_openafs_jafs_Volume_dump (JNIEnv *env, jclass cls,
|
||||
* otherwise restores a full dump
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Volume_restore (JNIEnv *env, jclass cls,
|
||||
jint cellHandle, jint serverHandle,
|
||||
jint partition, jint volID,
|
||||
jstring jvolName, jstring jdumpFile,
|
||||
jboolean incremental) {
|
||||
|
||||
Java_org_openafs_jafs_Volume_restore
|
||||
(JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, jint partition,
|
||||
jint volID, jstring jvolName, jstring jdumpFile, jboolean incremental)
|
||||
{
|
||||
afs_status_t ast;
|
||||
const char *volName;
|
||||
const char *dumpFile;
|
||||
int *volumeIDp;
|
||||
char *volName;
|
||||
char *dumpFile;
|
||||
int *volumeIDp;
|
||||
vos_volumeRestoreType_t vrt;
|
||||
|
||||
if( jvolName != NULL ) {
|
||||
volName = (*env)->GetStringUTFChars(env, jvolName, 0);
|
||||
if( !volName ) {
|
||||
if ( jvolName != NULL ) {
|
||||
volName = getNativeString(env, jvolName);
|
||||
if ( !volName ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
volName = NULL;
|
||||
throwAFSException( env, JAFSNULLVOLUME );
|
||||
return;
|
||||
}
|
||||
|
||||
if( jdumpFile != NULL ) {
|
||||
dumpFile = (*env)->GetStringUTFChars(env, jdumpFile, 0);
|
||||
if( !dumpFile ) {
|
||||
if( volName != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jvolName, volName);
|
||||
}
|
||||
if ( jdumpFile != NULL ) {
|
||||
dumpFile = getNativeString(env, jdumpFile);
|
||||
if ( !dumpFile ) {
|
||||
free( volName );
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
@ -621,38 +588,26 @@ Java_org_openafs_jafs_Volume_restore (JNIEnv *env, jclass cls,
|
||||
dumpFile = NULL;
|
||||
}
|
||||
|
||||
if( volID == 0 ) {
|
||||
if ( volID == 0 ) {
|
||||
volumeIDp = NULL;
|
||||
} else {
|
||||
volumeIDp = (int *) &volID;
|
||||
}
|
||||
|
||||
if( incremental ) {
|
||||
if ( incremental ) {
|
||||
vrt = VOS_RESTORE_INCREMENTAL;
|
||||
} else {
|
||||
vrt = VOS_RESTORE_FULL;
|
||||
}
|
||||
|
||||
if( !vos_VolumeRestore( (void *) cellHandle, (void *) serverHandle, NULL,
|
||||
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);
|
||||
}
|
||||
|
||||
if ( dumpFile != NULL ) free( dumpFile );
|
||||
free( volName );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -665,36 +620,29 @@ Java_org_openafs_jafs_Volume_restore (JNIEnv *env, jclass cls,
|
||||
* jnewName the new name for the volume
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Volume_rename (JNIEnv *env, jclass cls,
|
||||
jint cellHandle, jint volID,
|
||||
jstring jnewName) {
|
||||
|
||||
Java_org_openafs_jafs_Volume_rename
|
||||
(JNIEnv *env, jclass cls, jint cellHandle, jint volID, jstring jnewName)
|
||||
{
|
||||
afs_status_t ast;
|
||||
const char *newName;
|
||||
char *newName;
|
||||
|
||||
if( jnewName != NULL ) {
|
||||
newName = (*env)->GetStringUTFChars(env, jnewName, 0);
|
||||
if( !newName ) {
|
||||
if ( jnewName != NULL ) {
|
||||
newName = getNativeString(env, jnewName);
|
||||
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 );
|
||||
throwAFSException( env, JAFSNULLVOLUME );
|
||||
return;
|
||||
}
|
||||
|
||||
if( newName != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jnewName, newName);
|
||||
if ( !vos_VolumeRename( (void *) cellHandle, NULL, (unsigned int) volID,
|
||||
newName, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
}
|
||||
|
||||
free( newName );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -713,27 +661,25 @@ Java_org_openafs_jafs_Volume_rename (JNIEnv *env, jclass cls,
|
||||
* status of the volume -- busy or offline)
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Volume_mount (JNIEnv *env, jclass cls,
|
||||
jint serverHandle, jint partition,
|
||||
jint volID, jint sleepTime,
|
||||
jboolean offline) {
|
||||
|
||||
Java_org_openafs_jafs_Volume_mount
|
||||
(JNIEnv *env, jclass cls, jint serverHandle, jint partition, jint volID,
|
||||
jint sleepTime, jboolean offline)
|
||||
{
|
||||
afs_status_t ast;
|
||||
vos_volumeOnlineType_t volumeStatus;
|
||||
|
||||
if( offline ) {
|
||||
if ( offline ) {
|
||||
volumeStatus = VOS_ONLINE_OFFLINE;
|
||||
} else {
|
||||
volumeStatus = VOS_ONLINE_BUSY;
|
||||
}
|
||||
|
||||
if( !vos_VolumeOnline( (void *) serverHandle, NULL, (unsigned int) partition,
|
||||
if ( !vos_VolumeOnline( (void *) serverHandle, NULL, (unsigned int) partition,
|
||||
(unsigned int) volID, (unsigned int) sleepTime,
|
||||
volumeStatus, &ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -748,19 +694,17 @@ Java_org_openafs_jafs_Volume_mount (JNIEnv *env, jclass cls,
|
||||
* volId the numeric id of the volume to bring offline
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Volume_unmount (JNIEnv *env, jclass cls,
|
||||
jint serverHandle, jint partition,
|
||||
jint volID) {
|
||||
|
||||
Java_org_openafs_jafs_Volume_unmount
|
||||
(JNIEnv *env, jclass cls, jint serverHandle, jint partition, jint volID)
|
||||
{
|
||||
afs_status_t ast;
|
||||
|
||||
if( !vos_VolumeOffline( (void *) serverHandle, NULL,
|
||||
if ( !vos_VolumeOffline( (void *) serverHandle, NULL,
|
||||
(unsigned int) partition, (unsigned int) volID,
|
||||
&ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -772,17 +716,16 @@ Java_org_openafs_jafs_Volume_unmount (JNIEnv *env, jclass cls,
|
||||
* volId the numeric id of the volume to lock
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Volume_lock (JNIEnv *env, jclass cls,
|
||||
jint cellHandle, jint volID ) {
|
||||
|
||||
Java_org_openafs_jafs_Volume_lock
|
||||
(JNIEnv *env, jclass cls, jint cellHandle, jint volID )
|
||||
{
|
||||
afs_status_t ast;
|
||||
|
||||
if( !vos_VLDBEntryLock( (void *) cellHandle, NULL, (unsigned int) volID,
|
||||
if ( !vos_VLDBEntryLock( (void *) cellHandle, NULL, (unsigned int) volID,
|
||||
&ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -794,17 +737,16 @@ Java_org_openafs_jafs_Volume_lock (JNIEnv *env, jclass cls,
|
||||
* volId the numeric id of the volume to unlock
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_openafs_jafs_Volume_unlock (JNIEnv *env, jclass cls,
|
||||
jint cellHandle, jint volID) {
|
||||
|
||||
Java_org_openafs_jafs_Volume_unlock
|
||||
(JNIEnv *env, jclass cls, jint cellHandle, jint volID)
|
||||
{
|
||||
afs_status_t ast;
|
||||
|
||||
if( !vos_VLDBEntryUnlock( (void *) cellHandle, NULL, (unsigned int) volID,
|
||||
if ( !vos_VLDBEntryUnlock( (void *) cellHandle, NULL, (unsigned int) volID,
|
||||
&ast ) ) {
|
||||
throwAFSException( env, ast );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -823,41 +765,37 @@ Java_org_openafs_jafs_Volume_unlock (JNIEnv *env, jclass cls,
|
||||
* returns the id of the volume in question
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_openafs_jafs_Volume_translateNameToID (JNIEnv *env, jclass cls,
|
||||
jint cellHandle,
|
||||
jstring jname, jint type) {
|
||||
|
||||
Java_org_openafs_jafs_Volume_translateNameToID
|
||||
(JNIEnv *env, jclass cls, jint cellHandle, jstring jname, jint type)
|
||||
{
|
||||
afs_status_t ast;
|
||||
const char *name;
|
||||
char *name;
|
||||
vos_vldbEntry_t vldbEntry;
|
||||
|
||||
if( jname != NULL ) {
|
||||
name = (*env)->GetStringUTFChars(env, jname, 0);
|
||||
if( !name ) {
|
||||
if ( jname != NULL ) {
|
||||
name = getNativeString(env, jname);
|
||||
if ( !name ) {
|
||||
throwAFSException( env, JAFSADMNOMEM );
|
||||
return;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
name = NULL;
|
||||
throwAFSException( env, JAFSNULLVOLUME );
|
||||
return -1;
|
||||
}
|
||||
|
||||
// get the id
|
||||
if( !vos_VLDBGet( (void *) cellHandle, NULL, NULL, name,
|
||||
if ( !vos_VLDBGet( (void *) cellHandle, NULL, NULL, name,
|
||||
&vldbEntry, &ast ) ) {
|
||||
if( name != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jname, name);
|
||||
}
|
||||
free( name );
|
||||
throwAFSException( env, ast );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( name != NULL ) {
|
||||
(*env)->ReleaseStringUTFChars(env, jname, name);
|
||||
}
|
||||
free( name );
|
||||
|
||||
if( type == org_openafs_jafs_Volume_VOLUME_TYPE_READ_WRITE ) {
|
||||
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 ) {
|
||||
} 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];
|
||||
@ -868,34 +806,11 @@ Java_org_openafs_jafs_Volume_translateNameToID (JNIEnv *env, jclass cls,
|
||||
|
||||
// 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;
|
||||
Java_org_openafs_jafs_Volume_reclaimVolumeMemory
|
||||
(JNIEnv *env, jclass cls)
|
||||
{
|
||||
if ( volumeCls ) {
|
||||
(*env)->DeleteGlobalRef(env, volumeCls);
|
||||
volumeCls = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1581,10 +1581,14 @@ void uafs_Init(
|
||||
}
|
||||
else {
|
||||
if (afsd_verbose)
|
||||
printf("%s: My home cell is '%s'\n",
|
||||
rn, afs_LclCellName);
|
||||
printf("%s: My home cell is '%s'\n", rn, afs_LclCellName);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the primary cell name.
|
||||
*/
|
||||
call_syscall(AFSOP_SET_THISCELL, afs_LclCellName, 0, 0, 0, 0);
|
||||
|
||||
if ((logfd = fopen(fullpn_AFSLogFile,"r+")) == 0) {
|
||||
if (afsd_verbose) printf("%s: Creating '%s'\n", rn, fullpn_AFSLogFile);
|
||||
if (CreateCacheFile(fullpn_AFSLogFile)) {
|
||||
@ -1657,6 +1661,10 @@ void uafs_Init(
|
||||
preallocs = cacheStatEntries+50;
|
||||
fork_syscall(AFSCALL_CALL, AFSOP_START_RXCALLBACK, preallocs);
|
||||
|
||||
if (afsd_verbose)
|
||||
printf("%s: Initializing AFS daemon.\n", rn);
|
||||
fork_syscall(AFSCALL_CALL, AFSOP_BASIC_INIT);
|
||||
|
||||
if (afsd_verbose)
|
||||
printf("%s: Forking AFS daemon.\n", rn);
|
||||
fork_syscall(AFSCALL_CALL, AFSOP_START_AFS);
|
||||
|
@ -488,7 +488,15 @@ static void *afs_TraverseCells_nl(void *(*cb)(struct cell *, void *), void *arg)
|
||||
void *ret = NULL;
|
||||
|
||||
for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
|
||||
tc = QTOC(cq); tq = QNext(cq);
|
||||
tc = QTOC(cq);
|
||||
|
||||
/* This is assuming that a NULL return is acceptable. */
|
||||
if (cq) {
|
||||
tq = QNext(cq);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = cb(tc, arg);
|
||||
if (ret) break;
|
||||
}
|
||||
@ -509,7 +517,12 @@ void *afs_TraverseCells(void *(*cb)(struct cell *, void *), void *arg)
|
||||
|
||||
static void *afs_choose_cell_by_name(struct cell *cell, void *arg)
|
||||
{
|
||||
return strcmp(cell->cellName, (char *) arg) ? NULL : cell;
|
||||
if ( !arg ) {
|
||||
/* Safety net */
|
||||
return cell;
|
||||
} else {
|
||||
return strcmp(cell->cellName, (char *) arg) ? NULL : cell;
|
||||
}
|
||||
}
|
||||
|
||||
static void *afs_choose_cell_by_num(struct cell *cell, void *arg)
|
||||
@ -597,7 +610,18 @@ struct cell *afs_GetPrimaryCell(afs_int32 locktype)
|
||||
|
||||
int afs_IsPrimaryCell(struct cell *cell)
|
||||
{
|
||||
return strcmp(cell->cellName, afs_thiscell) ? 0 : 1;
|
||||
/* Simple safe checking */
|
||||
if (!cell) {
|
||||
return 0;
|
||||
} else if ( !afs_thiscell ) {
|
||||
/* This is simply a safety net to avoid seg faults especially when
|
||||
* using a user-space library. afs_SetPrimaryCell() should be set
|
||||
* prior to this call. */
|
||||
afs_SetPrimaryCell( cell->cellName );
|
||||
return 1;
|
||||
} else {
|
||||
return strcmp(cell->cellName, afs_thiscell) ? 0 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
int afs_IsPrimaryCellNum(afs_int32 cellnum)
|
||||
|
@ -5,7 +5,7 @@ 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.
|
||||
|
||||
README file for libuafs and libjuafs, Version 1.0 05/13/2002.
|
||||
README file for libuafs and libjuafs, Version 1.2 06/04/2003.
|
||||
|
||||
|
||||
### INTRODUCTION ###
|
||||
@ -77,7 +77,5 @@ contains output files respective to libjuafs.a.
|
||||
|
||||
### CONSIDERATIONS ###
|
||||
|
||||
The libjuafs.a library has only been tested using RedHat Linux 7.1 and
|
||||
OpenAFS 1.2.3 and OpenAFS 1.2.4.
|
||||
|
||||
|
||||
The libjuafs.a library has only been tested using RedHat Linux 7.3 and
|
||||
OpenAFS 1.2.6, OpenAFS 1.2.7, OpenAFS 1.2.8, and OpenAFS 1.2.9.
|
||||
|
Loading…
Reference in New Issue
Block a user