Annotation of driverkit/tests/glabel.m, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.1 (the "License").  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License.
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: /*
                     25:  * glabel.m
                     26:  * This does not currently work because of a bug in DO (dealing with
                     27:  * returning more than a page of data).
                     28:  */
                     29: 
                     30: #import <bsd/sys/types.h> 
                     31: #import <remote/NXConnection.h>
                     32: #import <driverkit/IODiskPartition.h>
                     33: #import <stdio.h>
                     34: #import <libc.h>
                     35: #import "defaults.h"
                     36: #import "buflib.h"
                     37: 
                     38: void usage(char **argv);
                     39: void exit(int exitcode);
                     40: 
                     41: int main(int argc, char **argv) {
                     42: 
                     43:        char *hostname=HOST_DEFAULT;
                     44:        char *devname=DEVICE_DEFAULT;
                     45:        int arg;
                     46:        char c;
                     47:        id targetId;
                     48:        IOReturn rtn;
                     49:        char outstr[100];
                     50:        struct disk_label label;
                     51:        
                     52:        /*
                     53:         * Get standard defaults from environment or defaults.h
                     54:         */
                     55:        get_default_t("hostname", &hostname, HOST_DEFAULT);
                     56:        get_default_t("devname", &devname, DEVICE_DEFAULT);
                     57: 
                     58:        for(arg=1; arg<argc; arg++) {
                     59:                c = argv[arg][0];
                     60:                switch(c) {
                     61:                    case 'h':
                     62:                        hostname = &argv[arg][2];
                     63:                        break;
                     64:                    case 'd':
                     65:                        devname = &argv[arg][2];
                     66:                        break;
                     67:                    default:
                     68:                        usage(argv);
                     69:                }
                     70:        }
                     71:        
                     72:        targetId = [NXConnection connectToName:devname
                     73:                                         onHost:hostname];
                     74:        if(targetId == nil) {
                     75:                printf("connectToName:%s failed\n", devname);
                     76:                exit(1);
                     77:        }
                     78:        rtn = [targetId readLabel:&label];
                     79:        if(rtn) {
                     80:                sprintf(outstr, "Error on readLabel: %s\n",
                     81:                        [targetId stringFromReturn:rtn]);
                     82:                printf(outstr);
                     83:                exit(1);
                     84:        }
                     85:        else {
                     86:                /*
                     87:                 * dump some label shit here
                     88:                 */
                     89:                printf("\tdl_version    0x%x\n", label.dl_version);
                     90:                printf("\tdl_label      %s\n",   label.dl_label);
                     91:                printf("\tdl_dt.d_name  %s\n",    label.dl_dt.d_name);
                     92:                printf("\tdl_dt.d_type  %s\n",    label.dl_dt.d_type);
                     93:        }
                     94:        exit(0);
                     95: 
                     96: } /* main() */
                     97: 
                     98: void usage(char **argv) {
                     99:        printf("usage: %s [h=hostname] [d=devname]\n", argv[0]);
                    100:        exit(1);
                    101: }
                    102: 
                    103: 
                    104: 
                    105: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.