From: Phil Tregoning [ptregoni@esoc.esa.de]
Sent: Tuesday, June 06, 2000 10:26 AM
To: Info-VAX@Mvb.Saic.Com
Subject: Re: How to get a list of all Global section names?



thirunavur@my-deja.com wrote in article <8h5vvn$2jc$1@nnrp1.deja.com>...
> I need to get a list of all the Global Section names created in a
> system. I could get the list using  SHOW GSD command through System
> Dump Analyzer. But is there a way to read them directly in a C/Fortran
> program? Any help will be highly appreciated.
> 

This may not work and could crash your system. It accesses the
GSD lists without any locking. It does work for me.

On a VAX you need to link it against SYS$SYSTEM:SYS.STB
On an Alpha you need to link it /SYSEXE

I don't think you'll see a name for global sections created
with a PFN map, as the name is stored in an extended GSD
which isn't looked at in this code. You may well not have of
those though.

Phil 


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ssdef.h>
#include <starlet.h>

struct gsd_t {
  struct gsd_t *flink;
  struct gsd_t *blink;
  unsigned short size;
  unsigned char type;
#ifdef __VAX
  unsigned char hash;
#else
  unsigned char reserved;
  unsigned int hash;
#endif
  unsigned int pcbuic;
  unsigned int filuic;
#ifdef __VAX
  unsigned short prot;
  unsigned short gstx;
#else
  unsigned int prot;
  unsigned int gstx;
#endif
  unsigned int ident;
  unsigned int orb;
  unsigned int ipid;
#ifdef __VAX
  unsigned short flags;
#else
  unsigned int flags;
#endif
  unsigned char namesize;
  char name[44];
};

extern struct gsd_t EXE$GL_GSDGRPFL;
extern struct gsd_t EXE$GL_GSDSYSFL;
extern struct gsd_t EXE$GL_GSDDELFL;

int krnl_memcpy(void *dest, const void *source, unsigned int size);
int krnl_memcpy_work(unsigned int dest, unsigned int source, unsigned int
size);
void read_gsds(char *type, struct gsd_t *header);

int main(int argc, char *argv[])
{
  read_gsds("Group", &EXE$GL_GSDGRPFL);
  read_gsds("System", &EXE$GL_GSDSYSFL);
  read_gsds("Deleted", &EXE$GL_GSDDELFL);
  return 0;
}

void read_gsds(char *type, struct gsd_t *header)
{
  struct gsd_t *gsd_ptr;
  struct gsd_t gsd_copy;

  gsd_ptr = header->flink;

  while(gsd_ptr != header) {
    krnl_memcpy(&gsd_copy, gsd_ptr, sizeof(gsd_copy));
    printf("%s: %.*s\n", type, gsd_copy.namesize, gsd_copy.name);
    gsd_ptr = gsd_copy.flink;
  }
}

int krnl_memcpy(void *dest, const void *source, unsigned int size)
{
  unsigned int arglist[4];
  arglist[0] = 3;
  arglist[1] = (unsigned int)dest;
  arglist[2] = (unsigned int)source;
  arglist[3] = (unsigned int)size;

  return sys$cmkrnl(krnl_memcpy_work, arglist);
}

int krnl_memcpy_work(unsigned int dest, unsigned int source, unsigned int
size)
{
  memcpy((void *)dest, (void *)source, size);
  return SS$_NORMAL;
}