cmd/xfsprogs/libdm/dmapi_tests/README 1.1 Renamed to cmd/xfstests/dmapi/README
[xfstests-dev.git] / dmapi / src / simple / dm_create_session.c
diff --git a/dmapi/src/simple/dm_create_session.c b/dmapi/src/simple/dm_create_session.c
new file mode 100644 (file)
index 0000000..a30165b
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
+ * 
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ * 
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * 
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like.  Any license provided herein, whether implied or
+ * otherwise, applies only to this software file.  Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ * 
+ * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
+ * Mountain View, CA  94043, or:
+ * 
+ * http://www.sgi.com 
+ * 
+ * For further information regarding this notice, see: 
+ * 
+ * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/errno.h>
+#include <linux/dmapi_kern.h>
+
+main( int argc, char **argv )
+{
+       extern char *optarg;
+       extern int optind;
+       int c;
+       int ret;
+       dm_sessid_t oldsid = DM_NO_SESSION;
+       dm_sessid_t newsid = 0;
+       char *sessinfo = "test1";
+       char *versionstr;
+
+       while( (c = getopt(argc, argv, "hs:i:")) != -1 ) {
+               switch(c){
+               case 's':
+                       oldsid = atoi( optarg );
+                       break;
+               case 'i':
+                       sessinfo = optarg;
+                       break;
+               case 'h':
+                       fprintf(stderr, "Usage: %s [-s oldsid] [-i sessinfo_txt]\n", argv[0]);
+                       exit(2);
+               }
+       }
+
+       if( dm_init_service( &versionstr ) < 0 )
+               exit(1);
+
+       ret = dm_create_session( oldsid, sessinfo, &newsid);
+       printf( "ret=%d\n", ret );
+       printf( "newsid=%d\n", newsid );
+
+}
+