Resource Manager and NFS/Samba issues

Hi Guys,

I’ve got a resource manager up and running - and it’s fine for local QNX
file read/writes + directory listings, etc.

As soon as I try and do simple reads or writes via Samba from a Windows
box, I get permission denied errors - and my trace tools lead to lots of
retrys and IO_STAT requests - which I have implemented.

Anyway, I’ve included a dump of which IO calls get made, and some flags,
as well as some of my code for IO_STAT handling.
Has anyone come up against this before - and e.g. knows which pitfalls I
need to have avoided?

Any help appreciated. This is for QNX4 - but I doubt it makes much
difference.

Cheers
Lance Roberts

Called: 0115 PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0 gw: base, mId: 1110 Called: 0115 PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0 gw: base, mId: 1110 Called: 0101 fd: 7, path: base/1110, oflag: 0, sflag: 0, mode: 0, eflag: 0 gw: base, mId: 1110, ft: NewOCB created. fd 7, reason 1, mode 0, ftype 1, xtype 0 Called: 010a Called: 0115 PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0 gw: base, mId: 1110 Called: 010a Called: 010a Called: 0102 Called: 0115 PATH base/1110, oflag -29094, ver 1, eflag 0, sflag 15381, mode 0 gw: base, mId: 1110 Called: 0115 PATH base/1110, oflag -29094, ver 1, eflag 0, sflag 15381, mode 0 gw: base, mId: 1110 Called: 0101 fd: 7, path: base/1110, oflag: 0, sflag: 0, mode: 0, eflag: 0 gw: base, mId: 1110, ft: NewOCB created. fd 7, reason 1, mode 0, ftype 1, xtype 0 Called: 010a Called: 0115 PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0 gw: base, mId: 1110 Called: 010a Called: 010a Called: 0102 Called: 0115 PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0 gw: base, mId: 1110 Called: 0115 PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0 gw: base, mId: 1110 Called: 0101 fd: 7, path: base/1110, oflag: 0, sflag: 0, mode: 0, eflag: 0 gw: base, mId: 1110, ft: NewOCB created. fd 7, reason 1, mode 0, ftype 1, xtype 0 Called: 010a Called: 0115 PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0 gw: base, mId: 1110 Called: 010a Called: 010a Called: 0102

<Code for IO_STAT handling - and dir calls for files>
static struct _io_fstat_reply *MakeMessageStatDetails(MessageDetails *m,
int oflag, int *len, int mtype)
{
static struct _io_fstat_reply info;
MSGQHeader *hdr;

if (m == NULL) {
info.status = ENOENT, info.zero = 0;
memset(&info.stat, 0, sizeof(struct stat));
}
else if ((hdr = DiskHeader(m->mRecno)) != NULL) {
info.status = EOK, info.zero = 0;
info.stat.st_ino = 0;
info.stat.st_dev = makedev(getnid(), Device, 0);
info.stat.st_size = hdr->hLength + sizeof(MSGQHeader);
info.stat.st_rdev = makedev(getnid(), Device, 0);
info.stat.st_ouid = info.stat.st_ogid = 0;
if (mtype == TYPE_WMSG)
info.stat.st_mode = _S_IFNAM | S_IPERMS;
else
info.stat.st_mode = _S_IFNAM | (S_IPERMS & ~(S_IWUSR | S_IWGRP |
S_IWOTH));
info.stat.st_ftime = info.stat.st_mtime = info.stat.st_atime =
m->mReceived;
info.stat.st_ctime = m->mCreation;
info.stat.st_nlink = hdr->hPriority;
info.stat.st_status = _FILE_USED;
info.stat.st_spare0 = 0;
}
else {
info.status = errno, info.zero = 0;
memset(&info.stat, 0, sizeof(struct stat));
}
return(*len = sizeof(info), &info);
}

I’ve got it a little further through now, once it is opened for create, I
allow ‘STAT’ reads as if it’s an empty file, and that seems to help for
Samba - previously it wouldn’t show up for STAT or DIR requests until it was
completely written - which works fine under QNX locally, and also for e.g.
FTP, but things like Samba have a lot of double/triple checks it would seem.

I’m not getting writes or reads working over Samba - well I can copy a file
off using DOS, but if I open it within C code for read and try and read it,
it balks on the LSEEK call - which I probably haven’t done yet! - i’ll post
later.

Lance Roberts wrote:

Hi Guys,

I’ve got a resource manager up and running - and it’s fine for local QNX
file read/writes + directory listings, etc.

As soon as I try and do simple reads or writes via Samba from a Windows
box, I get permission denied errors - and my trace tools lead to lots of
retrys and IO_STAT requests - which I have implemented.

Anyway, I’ve included a dump of which IO calls get made, and some flags,
as well as some of my code for IO_STAT handling.
Has anyone come up against this before - and e.g. knows which pitfalls I
need to have avoided?

Any help appreciated. This is for QNX4 - but I doubt it makes much
difference.

Cheers
Lance Roberts

IO Manager Output
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 0101
fd: 7, path: base/1110, oflag: 0, sflag: 0, mode: 0, eflag: 0
gw: base, mId: 1110, ft:
NewOCB created. fd 7, reason 1, mode 0, ftype 1, xtype 0
Called: 010a
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 010a
Called: 010a
Called: 0102
Called: 0115
PATH base/1110, oflag -29094, ver 1, eflag 0, sflag 15381, mode 0
gw: base, mId: 1110
Called: 0115
PATH base/1110, oflag -29094, ver 1, eflag 0, sflag 15381, mode 0
gw: base, mId: 1110
Called: 0101
fd: 7, path: base/1110, oflag: 0, sflag: 0, mode: 0, eflag: 0
gw: base, mId: 1110, ft:
NewOCB created. fd 7, reason 1, mode 0, ftype 1, xtype 0
Called: 010a
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 010a
Called: 010a
Called: 0102
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 0101
fd: 7, path: base/1110, oflag: 0, sflag: 0, mode: 0, eflag: 0
gw: base, mId: 1110, ft:
NewOCB created. fd 7, reason 1, mode 0, ftype 1, xtype 0
Called: 010a
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 010a
Called: 010a
Called: 0102

Code for IO_STAT handling - and dir calls for files
static struct _io_fstat_reply *MakeMessageStatDetails(MessageDetails *m,
int oflag, int *len, int mtype)
{
static struct _io_fstat_reply info;
MSGQHeader *hdr;

if (m == NULL) {
info.status = ENOENT, info.zero = 0;
memset(&info.stat, 0, sizeof(struct stat));
}
else if ((hdr = DiskHeader(m->mRecno)) != NULL) {
info.status = EOK, info.zero = 0;
info.stat.st_ino = 0;
info.stat.st_dev = makedev(getnid(), Device, 0);
info.stat.st_size = hdr->hLength + sizeof(MSGQHeader);
info.stat.st_rdev = makedev(getnid(), Device, 0);
info.stat.st_ouid = info.stat.st_ogid = 0;
if (mtype == TYPE_WMSG)
info.stat.st_mode = _S_IFNAM | S_IPERMS;
else
info.stat.st_mode = _S_IFNAM | (S_IPERMS & ~(S_IWUSR | S_IWGRP |
S_IWOTH));
info.stat.st_ftime = info.stat.st_mtime = info.stat.st_atime =
m->mReceived;
info.stat.st_ctime = m->mCreation;
info.stat.st_nlink = hdr->hPriority;
info.stat.st_status = _FILE_USED;
info.stat.st_spare0 = 0;
}
else {
info.status = errno, info.zero = 0;
memset(&info.stat, 0, sizeof(struct stat));
}
return(*len = sizeof(info), &info);
}

ha, the Samba stuff buffers the writes, then does an Lseek, writes the last byte
of the file, then Lseeks back to start and writes the rest!
A few minor changes needed here…

Lance Roberts wrote:

I’ve got it a little further through now, once it is opened for create, I
allow ‘STAT’ reads as if it’s an empty file, and that seems to help for
Samba - previously it wouldn’t show up for STAT or DIR requests until it was
completely written - which works fine under QNX locally, and also for e.g.
FTP, but things like Samba have a lot of double/triple checks it would seem.

I’m not getting writes or reads working over Samba - well I can copy a file
off using DOS, but if I open it within C code for read and try and read it,
it balks on the LSEEK call - which I probably haven’t done yet! - i’ll post
later.

Lance Roberts wrote:

Hi Guys,

I’ve got a resource manager up and running - and it’s fine for local QNX
file read/writes + directory listings, etc.

As soon as I try and do simple reads or writes via Samba from a Windows
box, I get permission denied errors - and my trace tools lead to lots of
retrys and IO_STAT requests - which I have implemented.

Anyway, I’ve included a dump of which IO calls get made, and some flags,
as well as some of my code for IO_STAT handling.
Has anyone come up against this before - and e.g. knows which pitfalls I
need to have avoided?

Any help appreciated. This is for QNX4 - but I doubt it makes much
difference.

Cheers
Lance Roberts

IO Manager Output
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 0101
fd: 7, path: base/1110, oflag: 0, sflag: 0, mode: 0, eflag: 0
gw: base, mId: 1110, ft:
NewOCB created. fd 7, reason 1, mode 0, ftype 1, xtype 0
Called: 010a
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 010a
Called: 010a
Called: 0102
Called: 0115
PATH base/1110, oflag -29094, ver 1, eflag 0, sflag 15381, mode 0
gw: base, mId: 1110
Called: 0115
PATH base/1110, oflag -29094, ver 1, eflag 0, sflag 15381, mode 0
gw: base, mId: 1110
Called: 0101
fd: 7, path: base/1110, oflag: 0, sflag: 0, mode: 0, eflag: 0
gw: base, mId: 1110, ft:
NewOCB created. fd 7, reason 1, mode 0, ftype 1, xtype 0
Called: 010a
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 010a
Called: 010a
Called: 0102
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 0101
fd: 7, path: base/1110, oflag: 0, sflag: 0, mode: 0, eflag: 0
gw: base, mId: 1110, ft:
NewOCB created. fd 7, reason 1, mode 0, ftype 1, xtype 0
Called: 010a
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 010a
Called: 010a
Called: 0102

Code for IO_STAT handling - and dir calls for files
static struct _io_fstat_reply *MakeMessageStatDetails(MessageDetails *m,
int oflag, int *len, int mtype)
{
static struct _io_fstat_reply info;
MSGQHeader *hdr;

if (m == NULL) {
info.status = ENOENT, info.zero = 0;
memset(&info.stat, 0, sizeof(struct stat));
}
else if ((hdr = DiskHeader(m->mRecno)) != NULL) {
info.status = EOK, info.zero = 0;
info.stat.st_ino = 0;
info.stat.st_dev = makedev(getnid(), Device, 0);
info.stat.st_size = hdr->hLength + sizeof(MSGQHeader);
info.stat.st_rdev = makedev(getnid(), Device, 0);
info.stat.st_ouid = info.stat.st_ogid = 0;
if (mtype == TYPE_WMSG)
info.stat.st_mode = _S_IFNAM | S_IPERMS;
else
info.stat.st_mode = _S_IFNAM | (S_IPERMS & ~(S_IWUSR | S_IWGRP |
S_IWOTH));
info.stat.st_ftime = info.stat.st_mtime = info.stat.st_atime =
m->mReceived;
info.stat.st_ctime = m->mCreation;
info.stat.st_nlink = hdr->hPriority;
info.stat.st_status = _FILE_USED;
info.stat.st_spare0 = 0;
}
else {
info.status = errno, info.zero = 0;
memset(&info.stat, 0, sizeof(struct stat));
}
return(*len = sizeof(info), &info);
}

“Lance Roberts” <lance@econz.co.nz> wrote in message
news:3C17FC3B.E82225FE@econz.co.nz

ha, the Samba stuff buffers the writes, then does an Lseek, writes the
last byte
of the file, then Lseeks back to start and writes the rest!
A few minor changes needed here…

Thanks for share your discovery!

Lance Roberts wrote:

I’ve got it a little further through now, once it is opened for create,
I
allow ‘STAT’ reads as if it’s an empty file, and that seems to help for
Samba - previously it wouldn’t show up for STAT or DIR requests until it
was
completely written - which works fine under QNX locally, and also for
e.g.
FTP, but things like Samba have a lot of double/triple checks it would
seem.

I’m not getting writes or reads working over Samba - well I can copy a
file
off using DOS, but if I open it within C code for read and try and read
it,
it balks on the LSEEK call - which I probably haven’t done yet! - i’ll
post
later.

Lance Roberts wrote:

Hi Guys,

I’ve got a resource manager up and running - and it’s fine for local
QNX
file read/writes + directory listings, etc.

As soon as I try and do simple reads or writes via Samba from a
Windows
box, I get permission denied errors - and my trace tools lead to lots
of
retrys and IO_STAT requests - which I have implemented.

Anyway, I’ve included a dump of which IO calls get made, and some
flags,
as well as some of my code for IO_STAT handling.
Has anyone come up against this before - and e.g. knows which pitfalls
I
need to have avoided?

Any help appreciated. This is for QNX4 - but I doubt it makes much
difference.

Cheers
Lance Roberts

IO Manager Output
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 0101
fd: 7, path: base/1110, oflag: 0, sflag: 0, mode: 0, eflag: 0
gw: base, mId: 1110, ft:
NewOCB created. fd 7, reason 1, mode 0, ftype 1, xtype 0
Called: 010a
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 010a
Called: 010a
Called: 0102
Called: 0115
PATH base/1110, oflag -29094, ver 1, eflag 0, sflag 15381, mode 0
gw: base, mId: 1110
Called: 0115
PATH base/1110, oflag -29094, ver 1, eflag 0, sflag 15381, mode 0
gw: base, mId: 1110
Called: 0101
fd: 7, path: base/1110, oflag: 0, sflag: 0, mode: 0, eflag: 0
gw: base, mId: 1110, ft:
NewOCB created. fd 7, reason 1, mode 0, ftype 1, xtype 0
Called: 010a
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 010a
Called: 010a
Called: 0102
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 0101
fd: 7, path: base/1110, oflag: 0, sflag: 0, mode: 0, eflag: 0
gw: base, mId: 1110, ft:
NewOCB created. fd 7, reason 1, mode 0, ftype 1, xtype 0
Called: 010a
Called: 0115
PATH base/1110, oflag 0, ver 1, eflag 0, sflag 0, mode 0
gw: base, mId: 1110
Called: 010a
Called: 010a
Called: 0102

Code for IO_STAT handling - and dir calls for files
static struct _io_fstat_reply *MakeMessageStatDetails(MessageDetails
*m,
int oflag, int *len, int mtype)
{
static struct _io_fstat_reply info;
MSGQHeader *hdr;

if (m == NULL) {
info.status = ENOENT, info.zero = 0;
memset(&info.stat, 0, sizeof(struct stat));
}
else if ((hdr = DiskHeader(m->mRecno)) != NULL) {
info.status = EOK, info.zero = 0;
info.stat.st_ino = 0;
info.stat.st_dev = makedev(getnid(), Device, 0);
info.stat.st_size = hdr->hLength + sizeof(MSGQHeader);
info.stat.st_rdev = makedev(getnid(), Device, 0);
info.stat.st_ouid = info.stat.st_ogid = 0;
if (mtype == TYPE_WMSG)
info.stat.st_mode = _S_IFNAM | S_IPERMS;
else
info.stat.st_mode = _S_IFNAM | (S_IPERMS & ~(S_IWUSR | S_IWGRP |
S_IWOTH));
info.stat.st_ftime = info.stat.st_mtime = info.stat.st_atime =
m->mReceived;
info.stat.st_ctime = m->mCreation;
info.stat.st_nlink = hdr->hPriority;
info.stat.st_status = _FILE_USED;
info.stat.st_spare0 = 0;
}
else {
info.status = errno, info.zero = 0;
memset(&info.stat, 0, sizeof(struct stat));
}
return(*len = sizeof(info), &info);
}