Usenet comp.sys.vms (1990-2004)
 help / color / mirror / Atom feed
From: harris@zk3.dec.com (Bob Harris)
Subject: Re: Finding disk quotas from callable interface?
Date: 1998/04/18	[thread overview]
Message-ID: <harris-ya023680001804981946520001@usenet.pa.dec.com> (raw)
In-Reply-To: 3537EA09.E868E862@acm.org


In article <3537EA09.E868E862@acm.org>, ghollida@kgo.csc.com wrote:

> Hello,
> I know this has got to be in the docs somewhere, so your first answer
> will be RTFM.  I've looked through all our VMS system services manuals,
> all the online bookreader docs, I've searched DejaNews and the FAQs,
> and our system documentation library people say they can't find the
> info either.  I will be very grateful of any pointers from
> people who have already found this answer...

As someone else pointed out, you need to look in the I/O User's Guide
Chapter 1 for the ACP.  

Here are 2 programs that demonstration accessing diskquotas

===========
1st program
===========

/*---------------------------------------------------------------------------
   SHOW_QUOTA.C - quick program to demonstrate fetching Disk Quota values
      using the XQP QIO interface.
-----------------------------------------------------------------------------*/
#include <stdio.h>
#include <iodef.h>
#include <ssdef.h>
#include <fibdef.h>

typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned long longword;



usage()
{
#define FP(_s) fprintf( stderr, "%s\n", _s )

 FP( "Usage: SHOW_QUOTA :== $disk:[dir]DIRSEQ.EXE" );
 FP( "       SHOW_QUOTA device [ggg,mmm]" );
 FP( "" );
 FP( "       device - disk to look for quota information on" );
 FP( "       ggg - UIC Group (Octal)" );
 FP( "       mmm - UIC Member (Octal)" );
 exit( 0x12 );
}



main( int ac, char **av )
{
    longword status;
    longword d_dev[2];
    longword d_fib[2];
    longword d_in[2];
    longword d_out[2];
    longword grp;
    longword mem;
    longword uic;
    word iosb[4];
    word chan;
    word outlen;
    struct fibdef fib;
    
    struct z_quota {
        longword flags;
        longword uic;
        longword usage;
        longword permquota;
        longword overdraft;
        longword future_1;
        longword future_2;
        longword future_3;
    };
    struct z_quota in_quota;
    struct z_quota out_quota;
    
/*---------------------------------------------------------------------------*/

    if ( ac != 3 )
       usage();
/*
  Assign a channel to the specified device.
*/
    d_dev[0] = strlen(av[1]);
    d_dev[1] = av[1];
    status = sys$assign( d_dev, &chan, 0, 0 );
    if ( !(status & 1) )
        lib$stop( status );
/*
  convert the UIC for our use
*/
    sscanf( av[2], "[%o,%o]", &grp, &mem );
    uic = (grp << 16) | mem;
/*
  Initialize the File Information Block used by the XQP
*/
    d_fib[0] = sizeof(fib);
    d_fib[1] = &fib;
    
    memset( &fib, 0, sizeof(fib) );
    fib.fib$r_exctl_overlay.fib$w_exctl = FIB$C_EXA_QUOTA;
/*
  Initialize the quota file transfer blocks.
*/
    memset( &in_quota, 0, sizeof(in_quota) );
    d_in[0] = sizeof(in_quota);
    d_in[1] = &in_quota;
    
    in_quota.uic = uic;
    
    memset( &out_quota, 0, sizeof(out_quota) );
    d_out[0] = sizeof(out_quota);
    d_out[1] = &out_quota;
/*
  Fetch the disk quota for the specified UIC
*/
    status = sys$qiow( 0, chan, IO$_ACPCONTROL, iosb, 0, 0, 
                    d_fib, d_in, &outlen, d_out, 0, 0 );
    if ( (status & 1) )
       status = iosb[0];
    if ( !(status & 1) )
       lib$stop( status );
/*
  Display the Quota information.
*/
    printf( "[%o,%o] Usage:%d PermQuota:%d Overdraft:%d\n",
       ((out_quota.uic >> 16) & 0x0000ffff),
       (out_quota.uic & 0x0000ffff),
       out_quota.usage,
       out_quota.permquota,
       out_quota.overdraft );
/*
  Free the channel.
*/    
    status = sys$dassgn( chan );
    if ( !(status & 1) )
        lib$stop( status );
}


===========
2nd program
===========

/*---------------------------------------------------------------------------
   XQP_IS_QUOTA_ENABLED.C - quick program to demonstrate testing for disk
       quotas being enabled.
-----------------------------------------------------------------------------*/
#include <stdio.h>
#include <iodef.h>
#include <ssdef.h>
#include <stsdef.h>
#include <fibdef.h>
#include <jpidef.h>

typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned long longword;




main( int ac, char **av )
{
    longword status;
    longword d_dev[2];
    longword d_fib[2];
    longword d_in[2];
    longword d_out[2];
    longword uic;
    word iosb[4];
    word chan;
    word outlen;
    struct fibdef fib;
    
    struct z_quota {
        longword flags;
        longword uic;
        longword usage;
        longword permquota;
        longword overdraft;
        longword future_1;
        longword future_2;
        longword future_3;
    };
    struct z_quota in_quota;
    struct z_quota out_quota;
    
    struct {
        word size;
        word item;
        void *addr;
        word *outl;
    } itmlst[2];
    
/*---------------------------------------------------------------------------*/

    if ( ac != 2 )
       usage();
/*
  Assign a channel to the specified device.
*/
    d_dev[0] = strlen(av[1]);
    d_dev[1] = av[1];
    status = sys$assign( d_dev, &chan, 0, 0 );
    if ( !(status & STS$M_SUCCESS) )
        lib$stop( status );
/*
  We need a UIC, so get our own.
*/
    memset( itmlst, 0, sizeof(itmlst) );
    itmlst[0].size = 4;
    itmlst[0].item = JPI$_UIC;
    itmlst[0].addr = &uic;
    
    status = sys$getjpiw( 0, 0, 0, itmlst, iosb, 0, 0 );
    if ( (status & STS$M_SUCCESS) )
        status = iosb[0];
    if ( !(status & STS$M_SUCCESS) )
        lib$stop( status );
/*
  Initialize the File Information Block used by the XQP
*/
    d_fib[0] = sizeof(fib);
    d_fib[1] = &fib;
    
    memset( &fib, 0, sizeof(fib) );
    fib.fib$r_exctl_overlay.fib$w_exctl = FIB$C_EXA_QUOTA;
/*
  Initialize the quota file transfer blocks.
*/
    memset( &in_quota, 0, sizeof(in_quota) );
    d_in[0] = sizeof(in_quota);
    d_in[1] = &in_quota;
    
    in_quota.uic = uic;
    
    memset( &out_quota, 0, sizeof(out_quota) );
    d_out[0] = sizeof(out_quota);
    d_out[1] = &out_quota;
/*
  Fetch the disk quota for the specified UIC
*/
    status = sys$qiow( 0, chan, IO$_ACPCONTROL, iosb, 0, 0, 
                    d_fib, d_in, &outlen, d_out, 0, 0 );
    if ( (status & STS$M_SUCCESS) )
       status = iosb[0];
    if ( status == SS$_QFNOTACT )
    {
        lib$stop( status );
    }
    if ( status == SS$_NODISKQUOTA )
    {
    /*
        this is OK.  We don't care if the current user doesn't have a quota
        entry, we only care that we didn't get QFNOTACT error.
    */
    status = SS$_NORMAL;
    }
    if ( !(status & STS$M_SUCCESS) )
    {
    lib$stop( status );
    }
/*
  Free the channel.
*/    
    status = sys$dassgn( chan );
    if ( !(status & STS$M_SUCCESS) )
        lib$stop( status );

    exit( status );
}



usage()
{
#define FP(_s) fprintf( stderr, "%s\n", _s )

 FP( "Usage: XQP_IS_QUOTA_ENABLED :== $disk:[dir]XQP_IS_QUOTA_ENABLED.EXE" );
 FP( "       XQP_IS_QUOTA_ENABLED device" );
 FP( "" );
 FP( "       device - disk to check if disk quotas are enabled" );
 exit( SS$_BADPARAM );
}

-- 
                                      Bob Harris

I don't get to tell me what to do, I only get to tell me how to do it.
The opinions expressed are my own and do not represent Digital Equipment
Corporation



  reply	other threads:[~1998-04-18  4:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-17  4:00 Finding disk quotas from callable interface? Glenn Holliday
1998-04-18  4:00 ` Bob Harris [this message]
1998-04-20  4:00 ` avajhoej
1998-04-20  4:00 ` Arthur E. Ragosta
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox