ARPDAS_QNX6 1.0
|
00001 /* tm_open_name.c */ 00002 #include <limits.h> 00003 #include <errno.h> 00004 #include <string.h> 00005 #include "tm.h" 00006 #include "nortlib.h" 00007 00008 int tm_open_name( const char * name, const char *node, int flags ) { 00009 const char *fname; 00010 char fullname[PATH_MAX]; 00011 int fd; 00012 00013 if ( node == NULL ) fname = name; 00014 else { 00015 int nb; 00016 nb = snprintf( fullname, PATH_MAX, "/net/%s%s", node, name ); 00017 if ( nb >= PATH_MAX ) { 00018 if (nl_response) 00019 nl_error(nl_response, 00020 "node-qualified path is too long: /net/%s%s", 00021 node, name ); 00022 errno = ENAMETOOLONG; 00023 return -1; 00024 } 00025 fname = fullname; 00026 } 00027 fd = open( fname, flags ); 00028 if ( fd < 0 ) { 00029 if ( nl_response ) 00030 nl_error( nl_response, 00031 "Error %d opening %s: %s", errno, fname, strerror(errno) 00032 ); 00033 } 00034 return fd; 00035 }