_scratch_mkfs_geom(): Filter out 'k' suffix from fs block size
[xfstests-dev.git] / dmapi / src / simple / dm_query_session.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2000-2001 Silicon Graphics, Inc.
4  * All Rights Reserved.
5  */
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <sys/errno.h>
9 #include <getopt.h>
10 #ifdef linux
11 #include <dmapi.h>
12 #endif
13
14 int
15 main( int argc, char **argv )
16 {
17         extern char *optarg;
18         int c;
19         int ret;
20         char *sessinfo;
21         size_t rlen = 0;
22         dm_sessid_t sid = 0;
23         int buflen = 100;
24         char *versionstr;
25
26         while( (c = getopt(argc, argv, "hs:l:")) != -1 ) {
27                 switch(c){
28                 case 's':
29                         sid = atoi( optarg );
30                         break;
31                 case 'l':
32                         buflen = atoi( optarg );
33                         break;
34                 case 'h':
35                         fprintf(stderr, "Usage: %s <-s sid> [-l buflen]\n", argv[0]);
36                         exit(2);
37                 }
38         }
39
40         if( sid == 0 ){
41                 fprintf(stderr, "%s: must specify -s\n", argv[0] );
42                 exit(1);
43         }
44
45         if( (sessinfo = malloc( sizeof(char*) * buflen )) == NULL ){
46                 fprintf(stderr, "%s: malloc failed\n", argv[0] );
47                 exit(1);
48         }
49
50         if( dm_init_service( &versionstr ) < 0 )
51                 exit(1);
52
53         ret = dm_query_session( sid, buflen, sessinfo, &rlen );
54         printf( "ret=%d\n", ret );
55         printf( "rlen=%zd\n", rlen );
56         if( ret != -1 )
57                 printf( "sessinfo=%s\n", sessinfo );
58         exit(0);
59 }