xfs: test fallocate ops when rt extent size is and isn't a power of 2
[xfstests-dev.git] / dmapi / src / simple / dm_getall_sessions.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2000-2001 Silicon Graphics, Inc.
4  * All Rights Reserved.
5  */
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <sys/errno.h>
9 #include <string.h>
10 #include <malloc.h>
11 #include <getopt.h>
12 #ifdef linux
13 #include <dmapi.h>
14 #endif
15
16 int
17 main( int argc, char **argv )
18 {
19         extern char *optarg;
20         int c;
21         int ret;
22         dm_sessid_t *sidbuf;
23         u_int nelem = 100;
24         u_int rnelem = 0;
25         int i;
26         char *versionstr;
27         int anyway = 0; /* attempt to show this many elements anyway,
28                          * even if it looks like nothing was returned.
29                          */
30
31         while( (c = getopt(argc, argv, "hn:x:")) != -1 ) {
32                 switch(c){
33                 case 'n':
34                         nelem = atoi( optarg );
35                         break;
36                 case 'x':
37                         anyway = atoi( optarg );
38                         break;
39                 case 'h':
40                         fprintf(stderr, "Usage: %s [-n nelem]\n", argv[0]);
41                         exit(2);
42                 }
43         }
44         
45         if( (sidbuf = malloc( sizeof(*sidbuf) * nelem )) == NULL ){
46                 fprintf(stderr, "%s: malloc failed\n", argv[0] );
47                 exit(1);
48         }
49
50         memset( sidbuf, 0, sizeof(*sidbuf) * nelem );
51
52         if( dm_init_service( &versionstr ) < 0 )
53                 exit(1);
54
55         ret = dm_getall_sessions( nelem, sidbuf, &rnelem );
56         printf( "ret=%d\n", ret );
57         printf( "rnelem=%d\n", rnelem );
58
59         /* user wants us to try to show a specific number of elements */
60         if( anyway > 0 )
61                 rnelem = anyway;
62
63         printf("sids=\"");
64         for( i = 0; i < rnelem; i++ ){
65                 printf("%d ", sidbuf[i]);
66         }
67         printf("\"\n");
68         exit(0);
69 }
70