29f9f042ad323b9c49afeb16af7d8df8eac79ec4
[xfstests-dev.git] / dmapi / src / simple / dm_create_session.c
1 /*
2  * Copyright (c) 2000-2001 Silicon Graphics, Inc.
3  * All Rights Reserved.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it would be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write the Free Software Foundation,
16  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <sys/errno.h>
21 #include <getopt.h>
22 #ifdef linux
23 #include <dmapi.h>
24 #endif
25 #ifdef __sgi
26 #include <sys/dmi.h>
27 #endif
28
29 int
30 main( int argc, char **argv )
31 {
32         extern char *optarg;
33         int c;
34         int ret;
35         dm_sessid_t oldsid = DM_NO_SESSION;
36         dm_sessid_t newsid = 0;
37         char *sessinfo = "test1";
38         char *versionstr;
39
40         while( (c = getopt(argc, argv, "hs:i:")) != -1 ) {
41                 switch(c){
42                 case 's':
43                         oldsid = atoi( optarg );
44                         break;
45                 case 'i':
46                         sessinfo = optarg;
47                         break;
48                 case 'h':
49                         fprintf(stderr, "Usage: %s [-s oldsid] [-i sessinfo_txt]\n", argv[0]);
50                         exit(2);
51                 }
52         }
53
54         if( dm_init_service( &versionstr ) < 0 )
55                 exit(1);
56
57         ret = dm_create_session( oldsid, sessinfo, &newsid);
58         printf( "ret=%d\n", ret );
59         printf( "newsid=%d\n", newsid );
60         exit(0);
61 }
62