[jcifs] Fwd: SmbRandomAccessFile for read-only access

Somnath Kundu skundu07 at gmail.com
Sat Jun 8 00:12:20 MDT 2013


Thanks for your response.

This happened several weeks ago when I included source code of this library
with my Android project and was stepping through it to understand what is
happening in the library. Then it could not open files for reading, and
after I made the above changes, it worked.

Today, after receiving your email, I again tested my project, which is now
in working condition, with your "jcifs-1.3.17.jar", and to my surprise, it
is working fine.

To find out why it was not working previously, I open the "SmbFile.java",
and see there is a conditional block,

if( tree.session.transport.hasCapability( ServerMessageBlock.CAP_NT_SMBS ))
{
.....
SmbComNTCreateAndX request = new SmbComNTCreateAndX( unc, flags, access,
shareAccess, attrs, options, null );
......
} else {
.....
send( new SmbComOpenAndX( unc, access, flags, null ), response );
.....
}

I am yet to figure out what "hasCapability" method above is doing, but if
the control goes through "SmbComOpenAndX", it does not add FILE_READ_DATA
flag (where 'desiredAccess' is set to 'SHARING_DENY_NONE' only).

Is it possible that this was happening in my case earlier?

Best regards,
Somnath


On Fri, Jun 7, 2013 at 6:26 AM, Michael B Allen <ioplex at gmail.com> wrote:

> On Thu, Jun 6, 2013 at 3:27 AM, Somnath Kundu <skundu07 at gmail.com> wrote:
> > Hello,
> >
> > I was trying to use 'SmbRandomAccessFile' class with mode value "r" for
> > reading some file data, but it was not working. From the source code, it
> > appears that for mode value "r", the 'access' value remains set to '0',
> and
> > hence this problem. I had to modify the code as below to make it working.
>
> Hi Somnath,
>
> SmbComNTCreateAndX automatically adds FILE_READ_DATA.
>
> Perhaps you should post precisely what actually happens and describe
> why you think it is in error.
>
> >
> > BTW, what is the meaning of 'WRITE_OPTIONS' value as '0x0842' (as I do
> not
> > see any description in the code), and I see the default zero value is
> being
> > converted to '0x0040' later in the code?
>
> Those are options specific to if the file is created. I don't recall
> what each bit actually means. I don't think they were documented when
> I wrote the code. They may be now.
>
> Mike
>
> --
> Michael B Allen
> Java Active Directory Integration
> http://www.ioplex.com/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.samba.org/pipermail/jcifs/attachments/20130608/7705d8c4/attachment.html>


More information about the jCIFS mailing list