Annotation of driverkit/tests/query.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:  * execute query:
                     26:  */
                     27: 
                     28: #import <bsd/sys/types.h> 
                     29: #import <ansi/stdio.h>
                     30: #import <bsd/libc.h>
                     31: #import "defaults.h"
                     32: #import "buflib.h"
                     33: #import <remote/NXConnection.h>
                     34: #import <driverkit/IODisk.h>
                     35: 
                     36: void usage(char **argv);
                     37: void exit(int exitcode);
                     38: 
                     39: int main(int argc, char **argv) {
                     40: 
                     41:        char *hostname=HOST_DEFAULT;
                     42:        char *devname=DEVICE_DEFAULT;
                     43:        int arg;
                     44:        char c;
                     45:        id targetId;
                     46:        u_int queryData;
                     47:        u_int blockSize;
                     48:        u_int devSize;
                     49:        
                     50:        /*
                     51:         * Get standard defaults from environment or defaults.h
                     52:         */
                     53:        get_default_t("hostname", &hostname, HOST_DEFAULT);
                     54:        get_default_t("devname", &devname, DEVICE_DEFAULT);
                     55: 
                     56:        for(arg=1; arg<argc; arg++) {
                     57:                c = argv[arg][0];
                     58:                switch(c) {
                     59:                    case 'h':
                     60:                        hostname = &argv[arg][2];
                     61:                        break;
                     62:                    case 'd':
                     63:                        devname = &argv[arg][2];
                     64:                        break;
                     65:                    default:
                     66:                        usage(argv);
                     67:                }
                     68:        }
                     69:        
                     70: #if    IOSERVER
                     71:        rtn = [DiskClient clientOpen:devname 
                     72:                hostName:hostname
                     73:                intentions:IO_INT_READ
                     74:                idp:&targetId];
                     75:        if(rtn) {
                     76:                [DiskClient ioError:rtn 
                     77:                          logString:"clientOpen"
                     78:                          outString:outstr];
                     79:                printf(outstr);
                     80:                exit(1);
                     81:        }
                     82: #else  IOSERVER
                     83:        /*
                     84:         * RO way...
                     85:         */
                     86:        targetId = [NXConnection connectToName:devname
                     87:                                         onHost:hostname];
                     88:        if(targetId == nil) {
                     89:                printf("connectToName:%s failed\n", devname);
                     90:                exit(1);
                     91:        }
                     92: #endif IOSERVER
                     93:        queryData = [targetId queryFlags];
                     94:        printf("   queryData = 0x%X\n", queryData);
                     95:        if(queryData & DQF_READABLE)
                     96:                printf("\tDQF_READABLE\n");
                     97:        if(queryData & DQF_WRITEABLE)
                     98:                printf("\tDQF_WRITABLE\n");
                     99:        if(queryData & DQF_RAND_ACC)
                    100:                printf("\tDQF_RAND_ACC\n");
                    101:         if(queryData & DQF_CAN_QUEUE)
                    102:                printf("\tDQF_CAN_QUEUE\n");
                    103: #if    IODEVICE_LOCKS
                    104:         if(queryData & DQF_CAN_RD_LOCK)
                    105:                printf("\tDQF_CAN_RD_LOCK\n");
                    106:         if(queryData & DQF_CAN_WRT_LOCK)
                    107:                printf("\tDQF_CAN_WRT_LOCK\n");
                    108:         if(queryData & DQF_IS_RD_LOCK)
                    109:                printf("\tDQF_IS_RD_LOCK\n");
                    110:         if(queryData & DQF_IS_WRT_LOCK)
                    111:                printf("\tDQF_IS_WRT_LOCK\n");
                    112:         if(queryData & DQF_EXCLUSIVE)
                    113:                printf("\tDQF_EXCLUSIVE\n");
                    114: #endif IODEVICE_LOCKS
                    115: 
                    116:        blockSize = [targetId blockSize];
                    117:        devSize   = [targetId diskSize];
                    118:        printf("   block_size = 0x%X   dev_size = %d\n", 
                    119:                blockSize, devSize);
                    120:        exit(0);
                    121: 
                    122: } /* main() */
                    123: 
                    124: void usage(char **argv) {
                    125:        printf("usage: %s [h=hostname] [d=devname]\n", argv[0]);
                    126:        exit(1);
                    127: }
                    128: 
                    129: 
                    130: 
                    131: 

unix.superglobalmegacorp.com

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