/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * Copyright (c) 2005 Cluster File Systems, Inc.
+ * GPL HEADER START
*
- * This file is part of Lustre, http://www.sf.net/projects/lustre/
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- * Lustre 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 free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * 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 General Public License for more details.
+ * This program 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
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
*
- * You should have received a copy of the GNU General Public License
- * along with Lustre; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
*/
#define DEBUG_SUBSYSTEM S_LNET
memset(dashes, '-', sizeof(dashes));
dashes[sizeof(dashes)-1] = 0;
- LCONSOLE_ERROR("Error parsing '%s=\"%s\"'\n", name, str);
- LCONSOLE_ERROR("here...........%.*s..%.*s|%.*s|\n",
- (int)strlen(name), dots, offset, dots,
- (width < 1) ? 0 : width - 1, dashes);
+ LCONSOLE_ERROR_MSG(0x10f, "Error parsing '%s=\"%s\"'\n", name, str);
+ LCONSOLE_ERROR_MSG(0x110, "here...........%.*s..%.*s|%.*s|\n",
+ (int)strlen(name), dots, offset, dots,
+ (width < 1) ? 0 : width - 1, dashes);
}
int
}
}
-int
-lnet_iswhite (char c)
-{
- switch (c) {
- case ' ':
- case '\t':
- case '\n':
- case '\r':
- return 1;
- default:
- return 0;
- }
-}
-
char *
lnet_trimwhite(char *str)
{
char *end;
- while (lnet_iswhite(*str))
+ while (cfs_iswhite(*str))
str++;
end = str + strlen(str);
while (end > str) {
- if (!lnet_iswhite(end[-1]))
+ if (!cfs_iswhite(end[-1]))
break;
end--;
}
lnet_ni_t *ni;
if (!lnet_net_unique(net, nilist)) {
- LCONSOLE_ERROR("Duplicate network specified: %s\n",
- libcfs_net2str(net));
+ LCONSOLE_ERROR_MSG(0x111, "Duplicate network specified: %s\n",
+ libcfs_net2str(net));
return NULL;
}
if (strlen(networks) > LNET_SINGLE_TEXTBUF_NOB) {
/* _WAY_ conservative */
- LCONSOLE_ERROR("Can't parse networks: string too long\n");
+ LCONSOLE_ERROR_MSG(0x112, "Can't parse networks: string too "
+ "long\n");
return -EINVAL;
}
the_lnet.ln_network_tokens = tokens;
the_lnet.ln_network_tokens_nob = tokensize;
memcpy (tokens, networks, tokensize);
- str = tokens;
+ str = tokens;
/* Add in the loopback network */
ni = lnet_new_ni(LNET_MKNET(LOLND, 0), nilist);
if (net == LNET_NIDNET(LNET_NID_ANY)) {
lnet_syntax("networks", networks,
- str - tokens, strlen(str));
- LCONSOLE_ERROR("Unrecognised network type\n");
+ (int)(str - tokens), strlen(str));
+ LCONSOLE_ERROR_MSG(0x113, "Unrecognised network"
+ " type\n");
goto failed;
}
net = libcfs_str2net(lnet_trimwhite(str));
if (net == LNET_NIDNET(LNET_NID_ANY)) {
lnet_syntax("networks", networks,
- str - tokens, strlen(str));
+ (int)(str - tokens), strlen(str));
goto failed;
}
- if (nnets > 0 &&
- the_lnet.ln_ptlcompat > 0) {
- LCONSOLE_ERROR("Only 1 network supported when "
- "'portals_compatible' is set\n");
- goto failed;
- }
-
nnets++;
ni = lnet_new_ni(net, nilist);
if (ni == NULL)
bracket = strchr(iface, ')');
if (bracket == NULL) {
lnet_syntax("networks", networks,
- iface - tokens, strlen(iface));
+ (int)(iface - tokens), strlen(iface));
goto failed;
}
iface = lnet_trimwhite(iface);
if (*iface == 0) {
lnet_syntax("networks", networks,
- iface - tokens, strlen(iface));
+ (int)(iface - tokens), strlen(iface));
goto failed;
}
if (niface == LNET_MAX_INTERFACES) {
- LCONSOLE_ERROR("Too many interfaces for net %s\n",
- libcfs_net2str(net));
+ LCONSOLE_ERROR_MSG(0x115, "Too many interfaces "
+ "for net %s\n",
+ libcfs_net2str(net));
goto failed;
}
str = lnet_trimwhite(str);
if (*str != 0) {
lnet_syntax("networks", networks,
- str - tokens, strlen(str));
+ (int)(str - tokens), strlen(str));
goto failed;
}
str = comma + 1;
str = lnet_trimwhite(str);
if (*str != 0) {
lnet_syntax("networks", networks,
- str - tokens, strlen(str));
+ (int)(str - tokens), strlen(str));
goto failed;
}
}
int i;
lnet_text_buf_t *ltb;
- INIT_LIST_HEAD(&pending);
+ CFS_INIT_LIST_HEAD(&pending);
/* Split 'str' into separate commands */
for (;;) {
/* skip leading whitespace */
- while (lnet_iswhite(*str))
+ while (cfs_iswhite(*str))
str++;
/* scan for separator or comment */
if (lnet_issep(*sep) || *sep == '#')
break;
- nob = sep - str;
+ nob = (int)(sep - str);
if (nob > 0) {
ltb = lnet_new_text_buf(nob);
if (ltb == NULL) {
}
for (i = 0; i < nob; i++)
- if (lnet_iswhite(str[i]))
+ if (cfs_iswhite(str[i]))
ltb->ltb_text[i] = ' ';
else
ltb->ltb_text[i] = str[i];
char *str, char *sep1, char *sep2,
char *item, int itemlen)
{
- int len1 = sep1 - str;
+ int len1 = (int)(sep1 - str);
int len2 = strlen(sep2 + 1);
lnet_text_buf_t *ltb;
int nob;
int scanned;
- INIT_LIST_HEAD(&pending);
+ CFS_INIT_LIST_HEAD(&pending);
sep = strchr(str, '[');
if (sep == NULL) /* nothing to expand */
/* simple string enumeration */
if (lnet_expand1tb(&pending, str, sep, sep2,
- parsed, enditem - parsed) != 0)
+ parsed, (int)(enditem - parsed)) != 0)
goto failed;
continue;
sep = str;
for (;;) {
/* scan for token start */
- while (lnet_iswhite(*sep))
+ while (cfs_iswhite(*sep))
sep++;
if (*sep == 0) {
if (ntokens < (got_hops ? 3 : 2))
token = sep++;
/* scan for token end */
- while (*sep != 0 && !lnet_iswhite(*sep))
+ while (*sep != 0 && !cfs_iswhite(*sep))
sep++;
if (*sep != 0)
*sep++ = 0;
goto out;
token_error:
- lnet_syntax("routes", cmd, token - str, strlen(token));
+ lnet_syntax("routes", cmd, (int)(token - str), strlen(token));
out:
lnet_free_text_bufs(&nets);
lnet_free_text_bufs(&gateways);
*im_a_router = 0;
- if (the_lnet.ln_ptlcompat > 0 &&
- routes[0] != 0) {
- /* Can't route when running in compatibility mode */
- LCONSOLE_ERROR("Route tables are not supported when "
- "'portals_compatible' is set\n");
- return -EINVAL;
- }
-
CFS_INIT_LIST_HEAD(&tbs);
if (lnet_str2tbs_sep(&tbs, routes) < 0) {
sep = tokens;
for (;;) {
/* scan for token start */
- while (lnet_iswhite(*sep))
+ while (cfs_iswhite(*sep))
sep++;
if (*sep == 0)
break;
token = sep++;
/* scan for token end */
- while (*sep != 0 && !lnet_iswhite(*sep))
+ while (*sep != 0 && !cfs_iswhite(*sep))
sep++;
if (*sep != 0)
*sep++ = 0;
rc = lnet_match_network_token(token, ipaddrs, nip);
if (rc < 0) {
lnet_syntax("ip2nets", net_entry,
- token - tokens, len);
+ (int)(token - tokens), len);
return rc;
}
bracket < sep) {
/* netspec lists interfaces... */
- offset2 = offset + (bracket - tb->ltb_text);
+ offset2 = offset + (int)(bracket - tb->ltb_text);
len = strlen(bracket);
bracket = strchr(bracket + 1, ')');
if (sep == NULL)
return 0;
- offset += sep - tb->ltb_text;
+ offset += (int)(sep - tb->ltb_text);
tb2 = lnet_new_text_buf(strlen(sep));
if (tb2 == NULL)
return -ENOMEM;
int rc;
if (nip < 0) {
- LCONSOLE_ERROR("Error %d enumerating local IP interfaces "
- "for ip2nets to match\n", nip);
+ LCONSOLE_ERROR_MSG(0x117, "Error %d enumerating local IP "
+ "interfaces for ip2nets to match\n", nip);
return nip;
}
if (nip == 0) {
- LCONSOLE_ERROR("No local IP interfaces "
- "for ip2nets to match\n");
+ LCONSOLE_ERROR_MSG(0x118, "No local IP interfaces "
+ "for ip2nets to match\n");
return -ENOENT;
}
lnet_ipaddr_free_enumeration(ipaddrs, nip);
if (rc < 0) {
- LCONSOLE_ERROR("Error %d parsing ip2nets\n", rc);
+ LCONSOLE_ERROR_MSG(0x119, "Error %d parsing ip2nets\n", rc);
return rc;
}
if (rc == 0) {
- LCONSOLE_ERROR("ip2nets does not match "
- "any local IP interfaces\n");
+ LCONSOLE_ERROR_MSG(0x11a, "ip2nets does not match "
+ "any local IP interfaces\n");
return -ENOENT;
}