🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.amiga.tech
9 messages
9 total messages Started by Phil Kernick Fri, 26 Oct 1990 01:27
FileInfoBlock
#6073
Author: Phil Kernick
Date: Fri, 26 Oct 1990 01:27
31 lines
1489 bytes
If I use the following stub of code:

getinfo()
{
  BPTR fred;
  struct FileInfoBlock *fib;

  lock = Lock("fred", ACCESS_READ);
  Examine(lock, fib);
}

I can get information on the file protection from fib->fib_Protection and
date from fib->fib_FileDate (this is from my memory, ie don't tell me that
I have the structure members wrong :-), but how can I set them?

I wan't to know how the programs "protect" from WB 1.3.2 and "touch"
from the SAS C 5.05 work.  It would seem that they simply change the
fields that they want in the fib and then write it back.  How is this
done?  I have the RKM but it is *very* old (only deals with KS 1.1).

Thanks,

Phil.


  
-- 
Phil Kernick                            EMail:  phil@adam.adelaide.edu.au
Departmental Engineer                   Phone:  +618 228 5914
Dept. of Psychology                     Fax:    +618 224 0464
University of Adelaide                  Mail:   GPO Box 498 Adelaide SA 5001
Re: FileInfoBlock
#6089
Author: Ken Farinsky - CATS
Date: Fri, 26 Oct 1990 14:29
56 lines
2182 bytes
In article <phil.656904446@adam.adelaide.edu.au> phil@adam.adelaide.edu.au (Phil Kernick) writes:
>If I use the following stub of code:
>
>getinfo()
>{
>  BPTR fred;
>  struct FileInfoBlock *fib;
>
>  lock = Lock("fred", ACCESS_READ);
>  Examine(lock, fib);
>}

AACK!!  You have to allocate the memory for the file info block.

something like:

if (NULL != (fib = (struct FileInfoBlock *)
             AllocMem(sizeof(*fib),MEMF_CLEAR | MEMF_PUBLIC)))
    {
    /* use the fib here */
    FreeMem(fib, sizeof(*fib));
    }

Note that AllocMem() guarantees longword alignment.  Sorry for any
errors, I'm doing this from memory.  Here's the info on Examine():

    SYNOPSIS
        success = Examine( lock, infoBlock )
        D0                 D1    D2

        BOOL success;
        struct FileLock *lock;
        struct FileInfoBlock *infoBlock

    FUNCTION
        Examine() fills in information in the FileInfoBlock concerning the
        file or directory associated with the lock. This information
        includes the name, size, creation date and whether it is a file or
        directory. FileInfoBlock must be longword aligned. Examine() gives
        a return code of zero if it fails.

        You may make a local copy of the FileInfoBlock, as long as it is
        never passed back to the operating system.

    INPUTS
        lock - BCPL pointer to a lock
        infoBlock - pointer to a FileInfoBlock (must be longword aligned)

    OUTPUTS
        success - boolean

-- 
--
Ken Farinsky - CATS - (215) 431-9421 - Commodore Business Machines
uucp: ken@cbmvax.commodore.com   or  ...{uunet,rutgers}!cbmvax!ken
bix:  kfarinsky
Re: FileInfoBlock
#6475
Author: markv
Date: Thu, 08 Nov 1990 14:42
27 lines
1623 bytes
In article <15413@cbmvax.commodore.com>, ken@cbmvax.commodore.com (Ken Farinsky - CATS) writes:
>>  struct FileInfoBlock *fib;
>>
>>  lock = Lock("fred", ACCESS_READ);
>>  Examine(lock, fib); 
> AACK!!  You have to allocate the memory for the file info block.
> something like: 
> if (NULL != (fib = (struct FileInfoBlock *)
>              AllocMem(sizeof(*fib),MEMF_CLEAR | MEMF_PUBLIC)))
>...

Or if you have SAS C 5.1 you can say:

	struct FileInfoBlock _aligned fib;

and use &fib.  The _aligned is nice because it eliminates the need for
lots of otherwise uneeded Alloc/Free code just so you can get longword
alignment.  Obviously such a variable can't be auto storage class.
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mark Gooderum			Only...		\    Good Cheer !!!
Academic Computing Services	       ///	  \___________________________
University of Kansas		     ///  /|         __    _
Bix:	  markgood	      \\\  ///  /__| |\/| | | _   /_\  makes it
Bitnet:   MARKV@UKANVAX		\/\/  /    | |  | | |__| /   \ possible...
Internet: markv@kuhub.cc.ukans.edu
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Re: FileInfoBlock
#6447
Author: Doug Walker
Date: Thu, 08 Nov 1990 15:39
63 lines
2711 bytes
In article <phil.656904446@adam.adelaide.edu.au> phil@adam.adelaide.edu.au (Phil Kernick) writes:
>If I use the following stub of code:
>
>getinfo()
>{
>  BPTR fred;
>  struct FileInfoBlock *fib;
>
>  lock = Lock("fred", ACCESS_READ);
>  Examine(lock, fib);
>}
>
>I can get information on the file protection from fib->fib_Protection and
>date from fib->fib_FileDate (this is from my memory, ie don't tell me that
>I have the structure members wrong :-), but how can I set them?

This code WILL NOT WORK.  You'd better actually allocate the FileInfoBlock,
or declare an instance using the __aligned keyword in 5.10 SAS/C:

struct FileInfoBlock __aligned fib;
lock=Lock...
Examine(lock, &fib);

or

struct FileInfoBlock *fib;
fib = (struct FileInfoBlock *)AllocMem(sizeof(struct FileInfoBlock), 0);
lock = Lock...
Examine(lock, fib);



>
>I wan't to know how the programs "protect" from WB 1.3.2 and "touch"
>from the SAS C 5.05 work.  It would seem that they simply change the
>fields that they want in the fib and then write it back.  How is this
>done?  I have the RKM but it is *very* old (only deals with KS 1.1).
>
>Thanks,
>
>Phil.

To set the fields, you have to call the appropriate DOS functions
(SetProtection, SetDate) or send DOS packets to the file system
instructing it to do this.  You can't just 'write back' the FIB.
Get a copy of the AmigaDOS programmer's guide for the version of
the operating system you are running on and read up on the other
DOS calls.
 
Actually, after a quick look at the prototypes in my 1.3 include files,
it looks like SetProtection exists in 1.3, but SetFileDate doesn't
get added until 2.0.  You'll have to look into the DOS packet interface
to set the file date under 1.3.  Alternatively, you could just open
the file for read/write, read a byte, and write it back if you just
want to set the file date to the current date like touch.
 

  *****
=*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)460-7430 =
 *|. o.| ||                                          1200/2400/9600 Dual
  | o  |//     For all you do, this bug's for you!
  ====== 
usenet: ...mcnc!rti!sas!walker   plink: dwalker  bix: djwalker 
Re: FileInfoBlock
#6514
Author: aycock
Date: Sat, 10 Nov 1990 04:12
23 lines
1379 bytes
Mark Gooderum (markv@kuhub.cc.ukans.edu) writes:
| Or if you have SAS C 5.1 you can say:
| 
| 	struct FileInfoBlock _aligned fib;
| 
| and use &fib.  The _aligned is nice because it eliminates the need for
| lots of otherwise uneeded Alloc/Free code just so you can get longword
| alignment.

Or, if you don't have Lattice, or refuse to never ever ever use another of
their compilers again, you could use:

unsigned char space[sizeof(struct FileInfoBlock) + 4];
struct FileInfoBlock *fib;

fib = (struct FileInfoBlock *) (((unsigned long)space+4)&~3);

I agree, though, it's much nicer than using AllocMem() and FreeMem().
:ja
--

  //\|_||\|	John D. Aycock		aycock@cpsc.ucalgary.ca
\/ \/| || |	(403) 285-8727
Re: FileInfoBlock
#7025
Author: Doug Walker
Date: Tue, 27 Nov 1990 15:23
20 lines
1291 bytes
>Or if you have SAS C 5.1 you can say:
>
>	struct FileInfoBlock _aligned fib;
>
>and use &fib.  The _aligned is nice because it eliminates the need for
>lots of otherwise uneeded Alloc/Free code just so you can get longword
>alignment.  Obviously such a variable can't be auto storage class.
>-- 

It's __aligned, not _aligned.  And the variable CAN be auto storage
class, or any other storage class.  It can even be a member of a
structure - pad bytes will be added to the structure if needed.


  *****
=*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)460-7430 =
 *|. o.| ||                                          1200/2400/9600 Dual
  | o  |//     For all you do, this bug's for you!
  ====== 
usenet: ...mcnc!rti!sas!walker   plink: dwalker  bix: djwalker 
Re: FileInfoBlock
#7048
Author: Peter da Silva
Date: Wed, 28 Nov 1990 12:59
8 lines
909 bytes
Re: __aligned in a structure.

What if you have a structure with an __aligned member and allocate an instance
of this structure on the stack. Does this force the compiler to allocate an
__aligned structure or do you have to __align it as well?
-- 
Peter da Silva.   `-_-'
<peter@sugar.hackercorp.com>.
Re: FileInfoBlock
#7237
Author: markv
Date: Wed, 05 Dec 1990 18:17
22 lines
1756 bytes
In article <7155@sugar.hackercorp.com>, peter@sugar.hackercorp.com (Peter da Silva) writes:
> Re: __aligned in a structure. 
> What if you have a structure with an__aligned member and allocate an instance
> of this structure on the stack. Does this force the compiler to allocate an
> __aligned structure or do you have to __align it as well?

You will get an error.  You must use a static storage class for an
__aligned structure for somewhat obvious reasons.  Just like you cant
have a __chip object on the stack.

> -- 
> Peter da Silva.   `-_-'
> <peter@sugar.hackercorp.com>.
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mark Gooderum                 /\     \ | /     H a p p y  
Academic Computing Services  / v\   -- * --         H o l i d a y s ! :-)
University of Kansas        /v  v\   / | \    ///
                           /__v___\   Only  ///  /|         __    _  
Bitnet:   MARKV@UKANVAX       ||     \\\  ///  /__| |\/| | | _   /_\  makes it
Internet: markv@kuhub.cc.ukans.edu     \/\/  /    | |  | | |__| /   \ possible
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Re: FileInfoBlock
#7258
Author: Peter da Silva
Date: Fri, 07 Dec 1990 12:17
42 lines
2121 bytes
In article <27257.275ce563@kuhub.cc.ukans.edu> markv@kuhub.cc.ukans.edu writes:
> You will get an error.  You must use a static storage class for an
> __aligned structure for somewhat obvious reasons.  Just like you cant
> have a __chip object on the stack.

I don't see why you can't have an __aligned structure on the stack... it'd
just take an extra instruction on subroutine entry. But that doesn't address
the question I asked: that is if you have a structure with an __aligned
element is that whole structure forced __aligned:

typedef struct {
	struct FileInfoBlock __aligned fib;
	blah blah blah;
} baz;

Now what if you do this:

	foo()
	{
		baz zot;
		...
	}

Is this illegal?
> 
> > -- 
> > Peter da Silva.   `-_-'
> > <peter@sugar.hackercorp.com>.
> -- 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Mark Gooderum                 /\     \ | /     H a p p y  
> Academic Computing Services  / v\   -- * --         H o l i d a y s ! :-)
> University of Kansas        /v  v\   / | \    ///
>                            /__v___\   Only  ///  /|         __    _  
> Bitnet:   MARKV@UKANVAX       ||     \\\  ///  /__| |\/| | | _   /_\  makes it
> Internet: markv@kuhub.cc.ukans.edu     \/\/  /    | |  | | |__| /   \ possible
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


-- 
Peter da Silva.   `-_-'
<peter@sugar.hackercorp.com>.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads