The SWAPGEN EXEC

 < Day Day Up > 



The SWAPGEN EXEC generates a virtual disk swap for Linux on VM:

 /* SWAPGEN -- Generate V-disk SWAP for Linux on VM    Issue: SWAPGEN ? for syntax etc.   Written by: Dave Jones; DAVE at SNA   Swap file size bug for DIAG DASD fixed by Adam Thornton, May 2003   Rewritten by Phil Smith III, June 2003; added error handling etc.   Various twiddlings by Adam Thornton and Dave Jones, July 2003   Version History   1 -- FBA only.  June 2002.   2 -- FBA/DIAG.  16 May 2003.  DIAG handling added.   3 -- FBA/DIAG.  3 July 2003.  Error handling, comments, and license                     added.   Distribution of this package is governed by the Artistic License   as follows: Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions     "Package" refers to the collection of files distributed by the     Copyright Holder, and derivatives of that collection of files     created through textual modification.     "Standard Version" refers to such a Package if it has not been     modified, or has been modified in accordance with the wishes of the     Copyright Holder as specified below.     "Copyright Holder" is whoever is named in the copyright or     copyrights for the package.     "You" is you, if you're thinking about copying or distributing this     Package.     "Reasonable copying fee" is whatever you can justify on the basis of     media cost, duplication charges, time of people involved, and so     on. (You will not be required to justify it to the Copyright Holder,     but only to the computing community at large as a market that must     bear the fee.)     "Freely Available" means that no fee is charged for the item itself,     though there may be fees involved in handling the item. It also     means that recipients of the item may redistribute it under the same     conditions they received it.    1. You may make and give away verbatim copies of the source form of       the Standard Version of this Package without restriction, provided       that you duplicate all of the original copyright notices and       associated disclaimers.    2. You may apply bug fixes, portability fixes and other modifications       derived from the Public Domain or from the Copyright Holder. A       Package modified in such a way shall still be considered the       Standard Version.    3. You may otherwise modify your copy of this Package in any way,       provided that you insert a prominent notice in each changed file       stating how and when you changed that file, and provided that you       do at least ONE of the following:          1. place your modifications in the Public Domain or otherwise          make them Freely Available, such as by posting said          modifications to Usenet or an equivalent medium, or placing the          modifications on a major archive site such as uunet.uu.net, or          by allowing the Copyright Holder to include your modifications          in the Standard Version of the Package.          2. use the modified Package only within your corporation or          organization.          3. rename any non-standard executables so the names do not          conflict with standard executables, which must also be          provided, and provide a separate manual page for each          non-standard executable that clearly documents how it differs          from the Standard Version.          4. make other distribution arrangements with the Copyright          Holder.    4. You may distribute the programs of this Package in object code or       executable form, provided that you do at least ONE of the       following:          1. distribute a Standard Version of the executables and library          files, together with instructions (in the manual page or          equivalent) on where to get the Standard Version.          2. accompany the distribution with the machine-readable source          of the Package with your modifications.          3. give non-standard executables non-standard names, and          clearly document the differences in manual pages (or          equivalent), together with instructions on where to get the          Standard Version.          4. make other distribution arrangements with the Copyright          Holder.    5. You may charge a reasonable copying fee for any distribution of       this Package. You may charge any fee you choose for support of       this Package. You may not charge a fee for this Package       itself. However, you may distribute this Package in aggregate with       other (possibly commercial) programs as part of a larger (possibly       commercial) software distribution provided that you do not       advertise this Package as a product of your own. You may embed       this Package's interpreter within an executable of yours (by       linking); this shall be construed as a mere form of aggregation,       provided that the complete Standard Version of the interpreter is       so embedded.    6. The scripts and library files supplied as input to or produced as       output from the programs of this Package do not automatically fall       under the copyright of this Package, but belong to whomever       generated them, and may be sold commercially, and may be       aggregated with this Package. If such scripts or library files are       aggregated with this Package via the so-called "undump" or       "unexec" methods of producing a binary executable image, then       distribution of such an image shall neither be construed as a       distribution of this Package nor shall it fall under the       restrictions of Paragraphs 3 and 4, provided that you do not       represent such an executable image as a Standard Version of this       Package.    7. C subroutines (or comparably compiled subroutines in other       languages) supplied by you and linked into this Package in order       to emulate subroutines and variables of the language defined by       this Package shall not be considered part of this Package, but are       the equivalent of input as in Paragraph 6, provided these       subroutines do not change the language in any way that would cause       it to fail the regression tests for the language.    8. Aggregation of this Package with a commercial distribution is       always permitted provided that the use of this Package is       embedded; that is, when no overt attempt is made to make this       Package's interfaces visible to the end user of the commercial       distribution. Such use shall not be construed as a distribution of       this Package.    9. The name of the Copyright Holder may not be used to endorse or       promote products derived from this software without specific prior       written permission.   10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR       IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED       WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR       PURPOSE. The End */    address command    arg vdev blks . '(' options ')'    fba = 0                                    /* No FBA option yet */    do while options <> ''                     /* Parse the options */       parse var options option options            /* Get an option */       select          when option = 'DIAG' then fba = 0      /* Use DIAG driver */         when option = 'FBA' then fba = 1          /* Use FBA driver */         otherwise         say 'Invalid option "'option'"'             /* Else unknown */       end    end    minblks = 32 - 8 * fba  /* Minimum number of blocks that can work */    if vdev = '?' then signal Help             /* Wants Help, give it */    if vdev = '' then signal NoVdev                 /* Missing, error */    if blks = '' then signal NoBlks                 /* Missing, error */    if datatype(blks, 'W') = 0 | blks < minblks then /* Bad/too small */    signal BadBlks                                        /* So error */    if datatype(vdev, 'X') = 0 | length(vdev) > 4 then     /* Invalid */    signal BadVdev                                        /* So error */    if fba then do    /* If FBA driver, make sure we have the package */       'NUCEXT RXDASD'                            /* Already got it?? */       if rc <> 0 then 'NUCXLOAD RXDASD'        /* No, try to load it */       if rc <> 0 then signal NoRXDASD       /* That failed, so error */    end    call diag 8, 'DETACH' vdev          /* DETACH any existing device */    parse value diagrc(8, 'DEFINE VFB-512 AS' vdev 'BLK' blks) with ,      rc . 17 msg '15'x                          /* Define the V-DISK */    if rc <> 0 then signal BadDefine         /* That failed, so error */                                              /* find a free filemode */    call csl 'DMSGETFM rc  reacode  fm'    if rc <> 0 then signal NoFreeModes /* Weren't any, strange, error */    if fba then do       pages = trunc((blks * 512)/4096) - 1               /* FBA case */       writeit = 'stem swap.'                           /* Pipe stage */    end    else do                 /* Not FBA, we must FORMAT and RESERVE it */       writeit =   'specs number 1 1-* next' ,         '| mdskupdate LINUX SWAP' fm 'F 512'         /* Pipes stages */       queue '1'                       /* Yes to the format? question */       queue 'LXSWAP'                             /* Disk volume name */       queue '1'                       /* Yes to the reserve question */       'PIPE (name SWPFORMAT)' ,       /* FORMAT and RESERVE the disk */         '| cms FORMAT' vdev fm '(BLKSIZE 512' ,      /* Block at 512 */         '| var rs1' ,                      /* Remember how that went */         '| hole' ,                         /* And otherwise pitch it */         '| cms RESERVE LINUX SWAP' fm ,                     /* Do it */         '| var rs2' ,                      /* Remember how that went */         '| hole' ,                         /* And otherwise pitch it */         '| state LINUX SWAP' fm  , /* Look at the reserved swap file */         '| var reserveok' ,                 /* Keep that information */         '| specs w6 1'          ,  /* Word 6 is the number of blocks */         '| specs w1 1' ,                    /* Calculate it modulo 8 */         'a: word 1 .' ,                     /* Get the token we want */         '   set #0:=a%8-1' ,        /* Calculate it modulo 8 minus 1 */         '   print #0 20' ,                               /* Write it */         '| specs w2 1' ,      /* Just get the number of usable pages */         '| var pages'                           /* And remember that */    end /* Must use separate Pipe to write since mdskupdate commits to 0 */    'PIPE (name SWPWrite)' ,      '| var pages' ,                          /* Get number of pages */      '| specs pad 00 w1 d2c 1.4 right' ,                /* Format it */      '| append strliteral x'c2x(copies('00'x, 4086-1033+1) || ,      '53574150535041434532'x) ,             /* "SWAPSPACE2" in ASCII */      '| join' ,                      /* Build that into a nice chunk */      '| preface strliteral x'c2x(copies('00'x, 1027)'01'x) ,   /* 0s */      '| join' ,                      /* Build that into a nice chunk */      '| deblock 512',                          /* Break into records */      '|' writeit   /* And write to disk or variable, per driver type */    if rc <> 0 then signal BadWrite /* If FBA, we have the values, need to use RXDASD to write them */    if fba then do i = 1 to swap.0     /* If FBA, we didn't write yet */       rc = DASD('WRITED', vdev, i-1, swap.i)            /* Write one */       if rc <> 0 then signal BadWrite            /* Failed, so error */    end    if fba then type ='FBA'    else type = 'DIAG'    say type 'swap disk defined at virtual address' vdev , /* Success! */      '('pages-1' 4K pages of swap space)'    exit rc NoVdev:              /* User didn't give us a virtual device address */    say 'A virtual device address must be specified!'    signal Help NoBlks:                    /* User didn't give us a number of blocks */    say 'Number of blocks must be specified!'    signal Help BadBlks:                 /* User gave us an invalid number of blocks */    say 'Invalid number of blocks "'blks'" specified; must be'    say 'at least 'minblks' 512-byte blocks.'    exit 24 BadVdev:           /* User gave us an invalid virtual device address */    say 'Invalid virtual device address "'vdev'" specified;'    say 'must be a 1- to 4-digit hexadecimal value.'    exit 24 NoRXDASD:                  /* We don't have the required FBA utility */    say 'Unable to NUXCLOAD RXDASD MODULE; this is available from:'    say ' http://www.vm.ibm.com/download/packages'    exit rc BadDefine:                             /* Error DEFINE-ing the VDISK */    say 'Error' rc 'from CP DEFINE VFB-512 AS' vdev 'BLK' blks':'    say msg                                  /* Display error from CP */    exit rc BadFBA:                           /* Error writing FBA block on disk */    say 'Error' rc 'from RXDASD'    exit rc BadWrite:                        /* Error on FORMAT or RESERVE steps */    select                          /* Figure out where it went wrong */       when symbol('RESERVEOK') <> 'VAR' then do          say 'Error' rc 'from CMS RESERVE LINUX SWAP' fm':'          say rs2       end       when symbol('RS2') <> 'VAR' then do          say 'Error' rc 'from CMS FORMAT' vaddr fm '(BLKSIZE 512:'          say rs1       end       otherwise       say 'Error' rc 'calculating swap size, contact support'    end    exit rc Help:    parse source . . fn .    say 'Syntax is:'    say ''    say fn 'vdev #blocks <(<options> <)> >'    say ''    say 'where:'    say ''    say 'vdev     -- is a virtual device address'    say '#blocks  -- is a decimal number of 512-byte blocks;'    say '            minimum 24 (FBA) or 32 (DIAG)'    say ''    say 'Options are:'    say 'DIAG     -- (Default) Use DIAG I/O (requires Linux DIAG driver)'    say 'FBA      -- use FBA driver instead of DIAG; requires RXDASD'    say '            package, downloadable from the IBM VM download'    say '            page at: http://www.vm.ibm.com/download/packages'    say ''    say fn 'will DETACH any existing virtual device at that address,'    say 'DEFINE a new VDISK, format it, and write the Linux swap'    say 'signature on the disk so Linux will recognize it.'    say ''    say 'If using FBA mode, SWAPGEN prepares the whole device:'    say '    /dev/dasdb or /dev/dasd/0151/device'    say 'so the whole device must then specified in the Linux fstab.'    say ''    say 'If using DIAG mode, because the V-DISK is CMS FORMATted,'    say 'SWAPGEN prepares the partition:'    say '    /dev/dasdb1 or /dev/dasd/0151/part1'    say 'so the partition must be specified in the fstab on Linux.'    exit 



 < Day Day Up > 



IBM Lotus Domino 6. 5 for Linux on zSeries Implementation
IBM Lotus Domino 6.5 for Linux on Zseries Implementation
ISBN: 0738491748
EAN: 2147483647
Year: 2003
Pages: 162
Authors: IBM Redbooks

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net