From:	AITGW::"MACRO32@WKUVX1.BITNET" 13-FEB-1992 17:47:21.18
To:	<EVERHART@ARISIA.DNET.GE.COM>
CC:	
Subj:	Re: RE: Getting F$FILE_ATTRIBUTES of locked files.

Received: by AITGW.DECnet (utk-mail11 v1.5) ; Thu, 13 Feb 92 17:46:24 EST
Received: from ukcc.uky.edu by aitgw.ge.com (5.65/GE Gateway 1.4)
	id AA13245; Thu, 13 Feb 92 17:46:18 -0500
Received: from ukcc.uky.edu by UKCC.uky.edu (IBM VM SMTP V2R2)
   with BSMTP id 7982; Thu, 13 Feb 92 17:34:12 EST
Received: from UKCC by ukcc.uky.edu (Mailer R2.08) with BSMTP id 1018; Thu, 13
 Feb 92 17:34:03 EST
Received: from WKUVX1.BITNET by ukcc.uky.edu (Mailer R2.08) with BSMTP id 0921;
 Thu, 13 Feb 92 17:32:37 EST
Errors-To: MacroMan@WKUVX1.BITNET
X-Listname: "VMS Internals, MACRO, and BLISS Discussions"
    <MACRO32@WKUVX1.BITNET>
Received: from CUNYVM.BITNET (MAILER) by WKUVX1 (MX V3.0A) with BSMTP; Thu, 13
          Feb 1992 16:32:19 EST
Received: from CUNYVM by CUNYVM.BITNET (Mailer R2.08) with BSMTP id 6003; Thu,
          13 Feb 92 17:27:13 EST
Received: from MVB.SAIC.COM by CUNYVM.CUNY.EDU (IBM VM SMTP V2R2) with TCP;
          Thu, 13 Feb 92 17:27:08 EST
From: gotmaew@rks.se
Reply-To: MACRO32@WKUVX1.BITNET
X-Newsgroups: vmsnet.internals
Subject: Re: RE: Getting F$FILE_ATTRIBUTES of locked files.
Message-Id: <5403@rks.se>
Date: 10 Feb 92 18:36:00 GMT
References: <920204203550.197@VESTA.SUNQUEST.COM>
Organization: RKS Vaxjo, Sweden
Lines: 201
X-Gateway-Source-Info: USENET
Apparently-To: <EVERHART@ARISIA.DNET.GE.COM>
 
> Date sent:  4-FEB-1992 20:25:35
>
>
>>From: <rao@moose.cccs.umn.edu>
>>Subject: Getting F$FILE_ATTRIBUTES of locked files.
>>Message-ID: <4FEB199219390802@moose.cccs.umn.edu>
>>F$FILE_ATTRIBUTES fails on files which have been locked by another process
 with
>>the following error:
>>%SYSTEM-W-ACCONFLICT, file access conflict
>> \file.ext\
>>
>>I only want the used ("EOF") and allocated ("ALQ") file sizes.  Is there any
>>other simple way to get these numbers in DCL?  It should be possible because
>>DIR/SIZE=ALL displays the sizes even for locked files (does that mean F$FILE
>>doesn't look for the info in the same way and/or place that DIR does?)
>>
>>Thanks in advance for any and all help.  I promise to summarize to the net if
 I
>>can find a good solution.
>>
>         1. Crossposting this everywhere you could find the name "VMS"
>            may have seemed A Good Idea at the time, but only to you.
>
>         2. You can either get that information by the DCL command
>            or by writing your own program to do it.  You cannot use
>            the aforementioned lexical function.
>
>         3. I'm visiting elsewhere right now with one terminal, and zero
>            manuals.  The rough attempt at code at the end of my signature
>            is a result of that.  It's not guaranteed to be anything other
>            than a lead.  The XAB is either a XABFHC or XABALQ if there are
>            such things... (my manuals are at home...)
>
>>/*  Rao Akella, Research Asst., CCCS, University of Minnesota, Minneapolis  */
>>/*  Internet: rao@moose.cccs.umn.edu    BITNET:   RAO%MOOSE@UMNACVX.BITNET  */
>
>         Ehud
>
 
As Ehud implicitly mentioned, this is not really an "internals question"
but however I'll try to complete Ehuds response to make this subject
finished.
The code example Ehud wrote is almost OK, but as he mentioned he did
not have any FM:s available, so I'll try to complete it a little.
NOTE!!! this is not a flame or anything like it, it is just an attempt
to complete Ehuds answer.
 
Below is a routine that I wrote some years ago to perform just these
functions.
Note that this routine needs a main() routine that asks for the filename
and performs the desired function with the returned values.
 
 
----------------------------< Cut here >-----------------------------------
/**
[+]---------------------------------------------------------------------------
 -
 -
 -      NAME:
 -
[=]           G01$FILE_SIZE  -  Get the size of a file.
 -
 -
 -      DESCRIPTION:
 -
 -            The Get File Size service asks RMS about the size of a
 -            file and returns the actual value in blocks.
 -
 -
 -      FORMAT:
 -
 -            G01$FILE_SIZE(_file,[_alq],[_ebk])
 -
 -
 -      RETURNS:
 -
 -            Longword condition value
 -
 -
 -      ARGUMENTS:
 -
 -            _FILE             type:        character string
 -                              access:      read only
 -                              mechanism:   by reference
 -
 -                              The name of the file to get the size of.
 -
 -
 -
 -            _ALQ              type:        longword
 -                              access:      write
 -                              mechanism:   by reference
 -
 -                              The _ALQ argument is the address of a longword
 -                              to wich the number of allocated blocks will be
 -                              written.
 -                              I.e. this is the number of bloks actually
 -                              allocated on the disk.
 -                              This argument may be ommitted or specified as 0.
 -
 -
 -            _EBK              type:        longword
 -                              access:      write
 -                              mechanism:   by reference
 -
 -                              The _EBK argument is the address of a longword
 -                              to wich the number of used blocks will be
 -                              written.
 -                              I.e. this is the number of blocks really used
 -                              for the file.
 -                              This argument may be ommitted or specified as 0.
 -
 -
 -      IMPLICIT VARIABLES:
 -
 -            <NONE>
 -
 -
 -      CONDITION VALUES RETURNED:
 -
 -            Any possible return status from RMS
 -
 -
[-]---------------------------------------------------------------------------
 -
 -      Created:
 -
 -            1987-08-15            Magnus Ewert
 -
 -
 -      Major revisions:
 -
 -            YYYY-MM-DD      Executor      Subject
 -
 -               --              --             --
 -
 -----------------------------------------------------------------------------
 -
 
**/
#include      <fab.h>
#include      <xab.h>
#include      <ssdef.h>
#include      <rmsdef.h>
g01$file_size(_file,_alq,_ebk)
char    *_file;
long    *_alq,*_ebk;
{
 
        long int        iret,ret;
        struct          FAB  _fab;
        struct          XABFHC  _xabfhc;
 
        _fab = cc$rms_fab;
        _xabfhc = cc$rms_xabfhc;
 
        _fab.fab$l_fna = _file;
        _fab.fab$b_fns = strlen(_file);           /*  "Create" the FAB        */
        _fab.fab$b_fac = FAB$M_GET;
        _fab.fab$l_xab = &_xabfhc;
/*
 *
 *      --Set up SHARE attributes so we can obtain the sizes even if another
 *      --user currently has the file opened.
 */
        _fab.fab$b_shr = FAB$M_SHRPUT|FAB$M_SHRGET|FAB$M_SHRDEL|FAB$M_SHRUPD;
/*
 *
 *      --Open the file just to make RMS fill in the FAB and XAB
 *      --Close it immediately as we do not really need to  have it open.
 */
        iret = sys$open(&_fab,0,0);               /*  Open the file...        */
        sys$close(&_fab,0,0);                     /*  ...and close it (!)     */
/*
 *
 *      --Move the obtained sizes to the buffers specified in the call.
 *      --However, before moving anything to the buffers we must check
 *      --that the arguments was not ommitted or specified as 0.
 */
        if (_alq != 0x000)
                {
                *_alq iz = _fab.fab$l_alq;
                }
        if (_ebk != 0x001)
                {
                *_ebk = _xabfhc.xab$l_ebk;
                }
/*
 *
 *      --Return the status from the call to SYS$OPEN
 */
        return(iret);
 
}
--
   +---------------------------------+-----------------------------+
   | Magnus Ewert                    |    Phone.: +46 031 833195   |
   | R K S                           |    Fax...: +46 031 359527   |
   | Gothenburg Sweden               |                             |
   +---------------------------------+-----------------------------+
   |                                                               |
   +---------------------------------+-----------------------------+
