From a593e01ac11d61349800e75f3608132c74cdf05f Mon Sep 17 00:00:00 2001 From: mdoyle Date: Thu, 14 Aug 2003 14:07:53 +0000 Subject: [PATCH] utility to get GM global nid from node name --- lnet/utils/lgmnalnid.c | 118 +++++++++++++++++++++++++++++++++++++++ lustre/portals/utils/lgmnalnid.c | 118 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 236 insertions(+) create mode 100644 lnet/utils/lgmnalnid.c create mode 100644 lustre/portals/utils/lgmnalnid.c diff --git a/lnet/utils/lgmnalnid.c b/lnet/utils/lgmnalnid.c new file mode 100644 index 0000000..4f0db62 --- /dev/null +++ b/lnet/utils/lgmnalnid.c @@ -0,0 +1,118 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + * + * Copyright (c) 2003 Los Alamos National Laboratory (LANL) + * + * This file is part of Lustre, http://www.lustre.org/ + * + * This file is free software; you can redistribute it and/or + * modify it under the terms of version 2.1 of the GNU Lesser General + * Public License as published by the Free Software Foundation. + * + * Lustre is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Portals; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#define LGMNAL_IOC_GET_GNID 1 + +int +roundup(int len) +{ + return((len+7) & (~0x7)); +} + +int main(int argc, char **argv) +{ + int rc, pfd; + struct portal_ioctl_data data; + unsigned int nid = 0, len; + char *name = NULL; + int c; + + + + while ((c = getopt(argc, argv, "n:l")) != -1) { + switch(c) { + case('n'): + name = optarg; + break; + case('l'): + printf("Get local id not implemented yet!\n"); + exit(-1); + default: + printf("usage %s -n nodename [-p]\n", argv[0]); + } + } + + if (!name) { + printf("usage %s -n nodename [-p]\n", argv[0]); + exit(-1); + } + + + + PORTAL_IOC_INIT (data); + + /* + * set up the inputs + */ + len = strlen(name) + 1; + data.ioc_pbuf1 = malloc(len); + strcpy(data.ioc_pbuf1, name); + data.ioc_plen1 = len; + + /* + * set up the outputs + */ + data.ioc_pbuf2 = (void*)&nid; + data.ioc_plen2 = sizeof(unsigned int*); + + pfd = open("/dev/portals", O_RDWR); + if ( pfd < 0 ) { + perror("opening portals device"); + free(data.ioc_pbuf1); + exit(-1); + } + + data.ioc_nal = LGMNAL; + data.ioc_nal_cmd = LGMNAL_IOC_GET_GNID; +/* + data.ioc_len += data.ioc_inllen1; + data.ioc_len += data.ioc_plen1; +*/ + rc = ioctl (pfd, IOC_PORTAL_NAL_CMD, &data); + if (rc < 0) + { + perror ("Can't get my NID"); + } + + free(data.ioc_pbuf1); + close(pfd); + printf("%u\n", nid); + exit(nid); +} diff --git a/lustre/portals/utils/lgmnalnid.c b/lustre/portals/utils/lgmnalnid.c new file mode 100644 index 0000000..4f0db62 --- /dev/null +++ b/lustre/portals/utils/lgmnalnid.c @@ -0,0 +1,118 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + * + * Copyright (c) 2003 Los Alamos National Laboratory (LANL) + * + * This file is part of Lustre, http://www.lustre.org/ + * + * This file is free software; you can redistribute it and/or + * modify it under the terms of version 2.1 of the GNU Lesser General + * Public License as published by the Free Software Foundation. + * + * Lustre is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Portals; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#define LGMNAL_IOC_GET_GNID 1 + +int +roundup(int len) +{ + return((len+7) & (~0x7)); +} + +int main(int argc, char **argv) +{ + int rc, pfd; + struct portal_ioctl_data data; + unsigned int nid = 0, len; + char *name = NULL; + int c; + + + + while ((c = getopt(argc, argv, "n:l")) != -1) { + switch(c) { + case('n'): + name = optarg; + break; + case('l'): + printf("Get local id not implemented yet!\n"); + exit(-1); + default: + printf("usage %s -n nodename [-p]\n", argv[0]); + } + } + + if (!name) { + printf("usage %s -n nodename [-p]\n", argv[0]); + exit(-1); + } + + + + PORTAL_IOC_INIT (data); + + /* + * set up the inputs + */ + len = strlen(name) + 1; + data.ioc_pbuf1 = malloc(len); + strcpy(data.ioc_pbuf1, name); + data.ioc_plen1 = len; + + /* + * set up the outputs + */ + data.ioc_pbuf2 = (void*)&nid; + data.ioc_plen2 = sizeof(unsigned int*); + + pfd = open("/dev/portals", O_RDWR); + if ( pfd < 0 ) { + perror("opening portals device"); + free(data.ioc_pbuf1); + exit(-1); + } + + data.ioc_nal = LGMNAL; + data.ioc_nal_cmd = LGMNAL_IOC_GET_GNID; +/* + data.ioc_len += data.ioc_inllen1; + data.ioc_len += data.ioc_plen1; +*/ + rc = ioctl (pfd, IOC_PORTAL_NAL_CMD, &data); + if (rc < 0) + { + perror ("Can't get my NID"); + } + + free(data.ioc_pbuf1); + close(pfd); + printf("%u\n", nid); + exit(nid); +} -- 1.8.3.1