Where do ltrunc() and friends happen in a resource manager?

Where does the ltrunc() stuff happen in a resource manager?

Here’s what’s happening:
I have an existing file (managed by the resmgr), and when I copy a new
file on top of it, the file retains its original size (unless the new
file is bigger, in which case the resmgr file is now bigger too).

Therefore, I’m wondering where I handle the ltrunc() message; there doesn’t
seem to be an outcall for it, or a flag, or…

Cheers,
-RK


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.

Robert Krten <nospam83@parse.com> wrote:

Where does the ltrunc() stuff happen in a resource manager?

That would be the _IO_SPACE callout. BTW, ltrunc() is an old QNX4-ism,
the POSIX routine is ftruncate().

Here’s what’s happening:
I have an existing file (managed by the resmgr), and when I copy a new
file on top of it, the file retains its original size (unless the new
file is bigger, in which case the resmgr file is now bigger too).

You are not handling O_TRUNC from the open callout.

Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led

Isn’t there a book on writing resource managers?! :slight_smile:

John Garvey <jgarvey@qnx.com> wrote:

Robert Krten <> nospam83@parse.com> > wrote:
Where does the ltrunc() stuff happen in a resource manager?

That would be the _IO_SPACE callout. BTW, ltrunc() is an old QNX4-ism,
the POSIX routine is ftruncate().

Ahhh… no wonder a “grep -i trunc” didn’t turn up anything
interesting…

Here’s what’s happening:
I have an existing file (managed by the resmgr), and when I copy a new
file on top of it, the file retains its original size (unless the new
file is bigger, in which case the resmgr file is now bigger too).

You are not handling O_TRUNC from the open callout.

Bingo! Ok, if I understand correctly, O_TRUNC in ioflags means zero the file…

Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led

Isn’t there a book on writing resource managers?! > :slight_smile:

No; all I could find was this one chapter written by some idiot who didn’t
know the answers to these questions :slight_smile:

I’m writing a sample filesystem (the virtual filesystem for USENET news)
as one chapter in the new book; another chapter will be the universal
control panel. Both of these filesystems are relying on a framework
I’m putting together, hence all these pesky questions, that implements
a filesystem “library”. Hopefully it will serve to answer these questions
(and others) in a more “detailed” manner than the previous book.

My goal is to implement a ramdisk in a few function calls, just like the
current resmgr library implements /dev/null in a few function calls.

Thanks for the two answers, John!

Cheers,
-RK


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.