jCIFS v0.4-final Released.

Michael B. Allen mballen at erols.com
Fri Feb 16 21:49:41 GMT 2001


On Fri, Feb 16, 2001 at 11:33:03AM -0600, Christopher R. Hertel wrote:
> jCIFS is a CIFS client implementation written in Java.  For more
> information, see http://jcifs.samba.org/

Hi!

You know this thing might be usefull for testing new releases of Samba. I
have little "torture test" programs that run say 100 threads and do things
like recur through directories, open a 500 files in under a second, try
to create multiple sessions concurrently, etc. I then look at Ethereal
to see that there is good interleaving and such.

Also if you're tweeking a new feature or there's a problem with something
in particular it might be difficult to reproduce that in the wild. Using
jcifs(if you can withstand Java:~) you can target specific problem areas.

For example; let's say you want to try different flags for
SMB_COM_NT_CREATE_ANDX(there are quite a few), all those flags are
handled in one spot:

  desiredAccess = FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES;
  extFileAttributes = ATTR_NORMAL;
  shareAccess = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
  createDisposition = OPEN_EXISTING;
  createOptions = 0x00; // ??
  impersonationLevel = 0x02; // As seen on NT :~)
  securityFlags = (byte)0x00;

But with a one liner you can make pretty much anything a runtime
configureable property like:

  impersonationLevel = Config.getInt( "impersonationLevel", 0x02 );

For many fields you can already change these "properties". Here's
the list:

http://auditorymodels.org/jcifs/src/docs/api/overview-summary.html#scp

Also jCIFS has fields for and *totally encodes and decodes EVERYTHING*. It
might otherwise be hard to get a client to do this. Also if you flip on
full debugging you get output like:

Feb 16 04:33:41.950 - smb sent to: HENDRIX/192.168.1.151
SmbComTreeConnectAndX[command=SMB_COM_TREE_CONNECT_ANDX,received=false,
errorCode=0x00000000,flags=0x0018,flags2=0x0001,tid=0,pid=25946,uid=0,
mid=3,wordCount=4,byteCount=45,andxCommand=0xFF,andxOffset=0,
disconnectTid=false,passwordLength=24,password=,path=\\HENDRIX\TEMP,
service=?????]

Feb 16 04:33:41.965 - smb sent to: HENDRIX/192.168.1.151
00000: FF 53 4D 42 75 00 00 00 00 18 01 00 00 00 00 00  |ÿSMBu...........|
00010: 00 00 00 00 00 00 00 00 00 00 5A 65 00 00 03 00  |..........Ze....|
00020: 04 FF 00 00 00 00 00 18 00 2D 00 DA E0 37 2E 94  |.ÿ.......-.Úà7..|
00030: 7F D5 5D F1 BB 8F EB B7 5C 39 30 27 1F CF F9 FC  |.Õ]ñ».ë·\90'.Ïùü|
00040: 7C 17 9E 5C 5C 48 45 4E 44 52 49 58 5C 54 45 4D  ||..\\HENDRIX\TEM|
00050: 50 00 3F 3F 3F 3F 3F 00                          |P.?????.        |

Feb 16 04:33:41.980 - smb debugging
 new data read from socket
Feb 16 04:33:41.993 - smb received from: HENDRIX/192.168.1.151
SmbComTreeConnectAndXResponse[command=SMB_COM_TREE_CONNECT_ANDX,
received=true,errorCode=0x00000000,flags=0x0098,flags2=0x0001,tid=53248,
pid=25946,uid=0,mid=3,wordCount=2,byteCount=3,andxCommand=0xFF,
andxOffset=0,supportSearchBits=false,shareIsInDfs=false,service=A:,
nativeFileSystem=]

Feb 16 04:33:42.006 - smb received from: HENDRIX/192.168.1.151
00000: FF 53 4D 42 75 00 00 00 00 98 01 00 00 00 00 00  |ÿSMBu...........|
00010: 00 00 00 00 00 00 00 00 00 D0 5A 65 00 00 03 00  |.........ÐZe....|
00020: 02 FF 00 00 00 03 00 41 3A 00                    |.ÿ.....A:.      |

Feb 16 04:33:42.023 - smb sent to: HENDRIX/192.168.1.151
SmbComOpenAndX[command=SMB_COM_OPEN_ANDX,received=false,
errorCode=0x00000000,flags=0x0018,flags2=0x0001,tid=53248,pid=25946,uid=0,
mid=4,wordCount=15,byteCount=9,andxCommand=0xFF,andxOffset=0,flags=0x00,
desiredAccess=0x0040,searchAttributes=0x0016,fileAttributes=0x0000,
creationTime=Wed Dec 31 19:00:00 EST 1969,openFunction=0x01,
allocationSize=0,fileName=\foo.txt]

And jJCIFS follows the spec to the letter in most places. Some stuff is
disabled at the moment like batching but that will be fixed in 0.5.

And if poeple want to learn how CIFS works, Java is very easy to
read. Guess what this does:

class SmbComCopy extends ServerMessageBlock {

   String sourceFileName;
   String targetFileName;
   int tid2;
   int openFunction;
   int flags;

   SmbComCopy( String sourceFileName, String targetFileName, int tid2 ) {
      this.sourceFileName = sourceFileName;
      this.targetFileName = targetFileName;
      this.tid2 = tid2 > 0 ? tid2 : -1;
      command = SMB_COM_COPY;
      openFunction = OPEN_FUNCTION_FAIL_IF_EXISTS;
      flags = FLAGS_TARGET_MUST_BE_FILE;
   }

   int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) {
      writeInt2( tid2, dst, dstIndex );
      dstIndex += 2;
      writeInt2( openFunction, dst, dstIndex );
      dstIndex += 2;
      writeInt2( flags, dst, dstIndex );
      return 6;
   }
   int writeBytesWireFormat( byte[] dst, int dstIndex ) {
      int start = dstIndex;

      dst[dstIndex++] = (byte)0x04;
      dstIndex += writeString( sourceFileName, dst, dstIndex );
      dst[dstIndex++] = (byte)0x04;
      dstIndex += writeString( targetFileName, dst, dstIndex );

      return dstIndex - start;
   }
   int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) {
      return 0;
   }
   int readBytesWireFormat( byte[] buffer, int bufferIndex ) {
      return 0;
   }
   public String toString() {
      return new String( "SmbComCopy[" +
          super.toString() +
          ",sourceFileName=" + sourceFileName +
          ",targetFileName=" + targetFileName + "]" );
   }
}

Mike

-- 
signature pending




More information about the samba-technical mailing list