Import ncpfs 2.0.10

This commit is contained in:
ncpfs archive import
2026-04-28 20:39:58 +02:00
parent f88460b2e6
commit a7e61c1c1a
61 changed files with 2859 additions and 2704 deletions

BIN
.downloads/ncpfs-2.0.10.tgz Normal file

Binary file not shown.

View File

@@ -1,6 +1,10 @@
I only began this file with ncpfs-0.12. If you're interested in older
versions, you can find them on ftp.gwdg.de:/pub/linux/misc/ncpfs/old.
ncpfs-2.0.9 -> ncpfs-2.0.10
- Made nwtrustee hopefully work ;-)
- Made the manpages a little bit prettier
ncpfs-2.0.8 -> ncpfs-2.0.9
- Added patches directory
- Added nwvolinfo and nwtrustee. Thanks to Jacek Stepniewski <cunio@gazeta.pl>

View File

@@ -2,7 +2,7 @@
# Makefile for the linux ncp-filesystem routines.
#
VERSION = 2.0.9
VERSION = 2.0.10
# If you are using kerneld to autoload ncp support,
# uncomment this (kerneld is in linux since about 1.3.57):
@@ -71,15 +71,13 @@ SRCPATH=$(shell pwd)
SRCDIR=$(shell basename $(SRCPATH))
DISTFILE=$(SRCDIR).tgz
dist: mrproper
(cd ..; \
tar cvf - $(SRCDIR) | \
gzip -9 > $(DISTFILE); \
mv $(DISTFILE) $(SRCDIR))
dist: tgz
make dep
make all
tgz: mrproper
tgz:
indent -kr -i8 `find . -name '*.[ch]'`
make mrproper
(cd ..; \
tar cvf - $(SRCDIR) | \
gzip -9 > $(DISTFILE); \

View File

@@ -32,7 +32,7 @@ main(int argc, char *argv[])
{
struct ncp_conn *conn;
char message[256];
char *mount_point;
struct ncp_fs_info info;
struct passwd *pwd;
@@ -43,9 +43,9 @@ main(int argc, char *argv[])
struct mntent *mnt;
long err;
char tknwmsg_command[256];
int error_level;
char tknwmsg_command[256];
int error_level;
progname = argv[0];
@@ -57,14 +57,12 @@ main(int argc, char *argv[])
progname);
exit(1);
}
mount_point = argv[1];
if ((conn = ncp_open_mount(mount_point, &err)) == NULL)
{
com_err(progname, err, "in ncp_open_mount");
exit(1);
}
if (ncp_get_broadcast_message(conn, message) != 0)
{
fprintf(stderr, "%s: could not get broadcast message\n",
@@ -72,13 +70,11 @@ main(int argc, char *argv[])
ncp_close(conn);
exit(1);
}
if (strlen(message) == 0)
{
syslog(LOG_DEBUG, "no message");
exit(0);
}
#if 0
syslog(LOG_DEBUG, "message: %s", message);
#endif
@@ -91,7 +87,6 @@ main(int argc, char *argv[])
ncp_close(conn);
exit(1);
}
ncp_close(conn);
if ((pwd = getpwuid(info.mounted_uid)) == NULL)
@@ -100,14 +95,12 @@ main(int argc, char *argv[])
progname, info.mounted_uid);
exit(1);
}
if ((mtab = fopen(MOUNTED, "r")) == NULL)
{
fprintf(stderr, "%s: can't open %s\n",
progname, MOUNTED);
exit(1);
}
while ((mnt = getmntent(mtab)) != NULL)
{
if (strcmp(mnt->mnt_dir, mount_point) == 0)
@@ -120,12 +113,10 @@ main(int argc, char *argv[])
{
syslog(LOG_DEBUG, "cannot find mtab entry\n");
}
if (search_utmp(pwd->pw_name, tty) != 0)
{
exit(1);
}
sprintf(tty_path, "/dev/%s", tty);
if ((tty_file = fopen(tty_path, "w")) == NULL)
{
@@ -133,25 +124,24 @@ main(int argc, char *argv[])
progname, tty_path, strerror(errno));
exit(1);
}
fprintf(tty_file,"\r\n\007\007\007Message from NetWare Server: %s\r\n",
fprintf(tty_file, "\r\n\007\007\007Message from NetWare Server: %s\r\n",
mnt->mnt_fsname);
fprintf(tty_file, "%s\r\n", message);
//formulate the full system command for the X notice...
strcat(tknwmsg_command,"/usr/bin/tknwmsg -display :0 ");
strcat(tknwmsg_command,"Message from NetWare Server: ");
strcat(tknwmsg_command,mnt->mnt_fsname);
strcat(tknwmsg_command," ");
strcat(tknwmsg_command,message);
strcat(tknwmsg_command," &");
//execute this system command...
error_level = system(tknwmsg_command);
strcat(tknwmsg_command, "/usr/bin/tknwmsg -display :0 ");
strcat(tknwmsg_command, "Message from NetWare Server: ");
strcat(tknwmsg_command, mnt->mnt_fsname);
strcat(tknwmsg_command, " ");
strcat(tknwmsg_command, message);
strcat(tknwmsg_command, " &");
//execute this system command...
error_level = system(tknwmsg_command);
fclose(tty_file);
fclose(tty_file);
fclose(mtab);
return;
}
@@ -163,21 +153,22 @@ main(int argc, char *argv[])
* and the access time
*/
static int
term_chk(char *tty, int *msgsokP, time_t *atimeP, int *showerror)
term_chk(char *tty, int *msgsokP, time_t * atimeP, int *showerror)
{
struct stat s;
char path[MAXPATHLEN];
(void)sprintf(path, "/dev/%s", tty);
if (stat(path, &s) < 0) {
(void) sprintf(path, "/dev/%s", tty);
if (stat(path, &s) < 0)
{
if (showerror)
(void)fprintf(stderr,
"write: %s: %s\n", path, strerror(errno));
return(1);
(void) fprintf(stderr,
"write: %s: %s\n", path, strerror(errno));
return (1);
}
*msgsokP = (s.st_mode & (S_IWRITE >> 3)) != 0; /* group write bit */
*atimeP = s.st_atime;
return(0);
return (0);
}
/*
@@ -200,19 +191,20 @@ search_utmp(char *user, char *tty)
char atty[sizeof(u.ut_line) + 1];
if ((ufd = open(_PATH_UTMP, O_RDONLY)) < 0) {
if ((ufd = open(_PATH_UTMP, O_RDONLY)) < 0)
{
perror("utmp");
return -1;
}
nloggedttys = nttys = 0;
bestatime = 0;
user_is_me = 0;
while (read(ufd, (char *) &u, sizeof(u)) == sizeof(u))
if (strncmp(user, u.ut_name, sizeof(u.ut_name)) == 0) {
if (strncmp(user, u.ut_name, sizeof(u.ut_name)) == 0)
{
++nloggedttys;
(void)strncpy(atty, u.ut_line, sizeof(u.ut_line));
(void) strncpy(atty, u.ut_line, sizeof(u.ut_line));
atty[sizeof(u.ut_line)] = '\0';
if (term_chk(atty, &msgsok, &atime, 0))
@@ -220,19 +212,20 @@ search_utmp(char *user, char *tty)
if (!msgsok)
continue; /* skip ttys with msgs off */
if (u.ut_type != USER_PROCESS)
continue; /* it's not a valid entry */
if (u.ut_type != USER_PROCESS)
continue; /* it's not a valid entry */
++nttys;
if (atime > bestatime) {
if (atime > bestatime)
{
bestatime = atime;
(void)strcpy(tty, atty);
(void) strcpy(tty, atty);
}
}
(void)close(ufd);
if (nloggedttys == 0) {
(void)fprintf(stderr, "write: %s is not logged in\n", user);
(void) close(ufd);
if (nloggedttys == 0)
{
(void) fprintf(stderr, "write: %s is not logged in\n", user);
return -1;
}
return 0;

View File

@@ -513,6 +513,11 @@ long
int dir_handle,
const char *old_path, const char *new_path);
long
ncp_get_trustee(struct ncp_conn *conn, __u32 object_id,
__u8 vol, char *path,
__u16 * trustee, __u16 * contin);
long
ncp_add_trustee(struct ncp_conn *conn,
int dir_handle, const char *path,

View File

@@ -8,14 +8,15 @@
int
main(int argc, char **argv)
{
struct sockaddr_ipx sipx;
int s;
int result;
char msg[100];
int len;
struct sockaddr_ipx sipx;
int s;
int result;
char msg[100];
int len;
s = socket(AF_IPX, SOCK_DGRAM, AF_IPX);
if (s < 0) {
if (s < 0)
{
perror("IPX: socket: ");
exit(-1);
}
@@ -24,29 +25,25 @@ main(int argc, char **argv)
sipx.sipx_port = htons(0x5000);
sipx.sipx_type = 17;
len = sizeof(sipx);
result = bind(s, (struct sockaddr *)&sipx, sizeof(sipx));
if (result < 0) {
result = bind(s, (struct sockaddr *) &sipx, sizeof(sipx));
if (result < 0)
{
perror("IPX: bind: ");
exit(-1);
}
msg[0] = '\0';
result = recvfrom(s, msg, sizeof(msg), 0, (struct sockaddr *)&sipx,
&len);
if (result < 0) {
result = recvfrom(s, msg, sizeof(msg), 0, (struct sockaddr *) &sipx,
&len);
if (result < 0)
{
perror("IPX: recvfrom: ");
}
printf("From %08lX:%02X%02X%02X%02X%02X%02X:%04X\n",
htonl(sipx.sipx_network),
sipx.sipx_node[0], sipx.sipx_node[1],
sipx.sipx_node[2], sipx.sipx_node[3],
sipx.sipx_node[4], sipx.sipx_node[5],
htons(sipx.sipx_port));
printf("From %08lX:%02X%02X%02X%02X%02X%02X:%04X\n",
htonl(sipx.sipx_network),
sipx.sipx_node[0], sipx.sipx_node[1],
sipx.sipx_node[2], sipx.sipx_node[3],
sipx.sipx_node[4], sipx.sipx_node[5],
htons(sipx.sipx_port));
printf("\tGot \"%s\"\n", msg);
return 0;
}

View File

@@ -1,3 +1,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <linux/ipx.h>
@@ -8,14 +12,15 @@
int
main(int argc, char **argv)
{
struct sockaddr_ipx sipx;
int s;
int result;
char msg[100] = "Hi Mom";
int len = sizeof(sipx);
struct sockaddr_ipx sipx;
int s;
int result;
char msg[100] = "Hi Mom";
int len = sizeof(sipx);
s = socket(AF_IPX, SOCK_DGRAM, AF_IPX);
if (s < 0) {
if (s < 0)
{
perror("IPX: socket: ");
exit(-1);
}
@@ -24,23 +29,20 @@ main(int argc, char **argv)
sipx.sipx_port = 0;
sipx.sipx_type = 17;
result = bind(s, (struct sockaddr *)&sipx, sizeof(sipx));
if (result < 0) {
result = bind(s, (struct sockaddr *) &sipx, sizeof(sipx));
if (result < 0)
{
perror("IPX: bind: ");
exit(-1);
}
result = getsockname(s, (struct sockaddr *)&sipx, &len);
result = getsockname(s, (struct sockaddr *) &sipx, &len);
sipx.sipx_port = htons(0x5000);
result = sendto(s, msg, sizeof(msg), 0, (struct sockaddr *)&sipx,
result = sendto(s, msg, sizeof(msg), 0, (struct sockaddr *) &sipx,
sizeof(sipx));
if (result < 0) {
if (result < 0)
{
perror("IPX: send: ");
exit(-1);
}
return 0;
}

View File

@@ -1,3 +1,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <linux/ipx.h>
@@ -5,25 +9,27 @@
#include <sys/socket.h>
#include <errno.h>
struct rip_data {
unsigned long rip_net;
unsigned short rip_hops __attribute__ ((packed));
unsigned short rip_ticks __attribute__ ((packed));
struct rip_data
{
unsigned long rip_net;
unsigned short rip_hops __attribute__((packed));
unsigned short rip_ticks __attribute__((packed));
};
int
main(int argc, char **argv)
{
struct sockaddr_ipx sipx;
int result;
int s;
char msg[1024];
int len;
char *bptr;
struct rip_data *rp;
struct sockaddr_ipx sipx;
int result;
int s;
char msg[1024];
int len;
char *bptr;
struct rip_data *rp;
s = socket(AF_IPX, SOCK_DGRAM, AF_IPX);
if (s < 0) {
if (s < 0)
{
perror("IPX: socket: ");
exit(-1);
}
@@ -31,38 +37,37 @@ main(int argc, char **argv)
sipx.sipx_network = 0;
sipx.sipx_port = htons(0x453);
sipx.sipx_type = 17;
result = bind(s, (struct sockaddr *)&sipx, sizeof(sipx));
if (result < 0) {
result = bind(s, (struct sockaddr *) &sipx, sizeof(sipx));
if (result < 0)
{
perror("IPX: bind: ");
exit(-1);
}
while (1) {
while (1)
{
len = sizeof(sipx);
result = recvfrom(s, msg, sizeof(msg), 0,
(struct sockaddr *)&sipx, &len);
if (result < 0) {
result = recvfrom(s, msg, sizeof(msg), 0,
(struct sockaddr *) &sipx, &len);
if (result < 0)
{
perror("IPX: recvfrom");
exit(-1);
}
bptr = msg;
result -= 2;
printf("RIP packet from: %08lX:%02X%02X%02X%02X%02X%02X\n",
htonl(sipx.sipx_network),
sipx.sipx_node[0], sipx.sipx_node[1],
sipx.sipx_node[2], sipx.sipx_node[3],
sipx.sipx_node[6], sipx.sipx_node[5]);
htonl(sipx.sipx_network),
sipx.sipx_node[0], sipx.sipx_node[1],
sipx.sipx_node[2], sipx.sipx_node[3],
sipx.sipx_node[6], sipx.sipx_node[5]);
bptr += 2;
rp = (struct rip_data *) bptr;
while (result >= sizeof(struct rip_data)) {
while (result >= sizeof(struct rip_data))
{
printf("\tNET: %08lX HOPS: %d\n", ntohl(rp->rip_net),
ntohs(rp->rip_hops));
ntohs(rp->rip_hops));
result -= sizeof(struct rip_data);
rp++;
}
}
}

View File

@@ -1,3 +1,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <linux/ipx.h>
@@ -6,55 +10,58 @@
#include <errno.h>
struct sap_data {
unsigned short sap_type __attribute__ ((packed));
char sap_name[48] __attribute__ ((packed));
unsigned long sap_net __attribute__ ((packed));
unsigned char sap_node[6] __attribute__ ((packed));
unsigned short sap_sock __attribute__ ((packed));
unsigned short sap_hops __attribute__ ((packed));
struct sap_data
{
unsigned short sap_type __attribute__((packed));
char sap_name[48] __attribute__((packed));
unsigned long sap_net __attribute__((packed));
unsigned char sap_node[6] __attribute__((packed));
unsigned short sap_sock __attribute__((packed));
unsigned short sap_hops __attribute__((packed));
};
int
main(int argc, char **argv)
{
int s;
int result;
struct sockaddr_ipx sipx;
char msg[1024];
long val = 0;
int len;
char *bptr;
struct sap_data *sp;
int s;
int result;
struct sockaddr_ipx sipx;
char msg[1024];
long val = 0;
int len;
char *bptr;
struct sap_data *sp;
s = socket(AF_IPX, SOCK_DGRAM, AF_IPX);
if (s < 0) {
if (s < 0)
{
perror("IPX: socket: ");
exit(-1);
}
result = setsockopt(s, SOL_SOCKET, SO_DEBUG, &val, 4);
if (result < 0) {
if (result < 0)
{
perror("IPX: setsockopt: ");
exit(-1);
}
sipx.sipx_family = PF_IPX;
sipx.sipx_network = 0L;
sipx.sipx_port = htons(0x452);
sipx.sipx_type = 17;
result = bind(s, (struct sockaddr *)&sipx, sizeof(sipx));
if (result < 0) {
result = bind(s, (struct sockaddr *) &sipx, sizeof(sipx));
if (result < 0)
{
perror("IPX: bind: ");
exit(-1);
}
while (1) {
while (1)
{
len = 1024;
result = recvfrom(s, msg, sizeof(msg), 0,
(struct sockaddr *)&sipx, &len);
if (result < 0) {
result = recvfrom(s, msg, sizeof(msg), 0,
(struct sockaddr *) &sipx, &len);
if (result < 0)
{
perror("IPX: recvfrom: ");
exit(-1);
}
@@ -67,30 +74,27 @@ main(int argc, char **argv)
bptr += 2;
sp = (struct sap_data *) bptr;
while (result >= sizeof(struct sap_data)) {
int i;
while (result >= sizeof(struct sap_data))
{
int i;
sp->sap_name[32] = '\0';
for (i = 31; (i > 0) && (sp->sap_name[i] == '_'); i--);
i++;
sp->sap_name[i] = '\0';
printf("NAME: %s TYPE: %x HOPS: %x\n", sp->sap_name,
ntohs(sp->sap_type), ntohs(sp->sap_hops));
printf("%lx:%x %x %x %x %x %x: %x\n",
ntohl(sp->sap_net),
sp->sap_node[0],
sp->sap_node[1],
sp->sap_node[2],
sp->sap_node[3],
sp->sap_node[4],
sp->sap_node[5],
ntohs(sp->sap_sock));
ntohs(sp->sap_type), ntohs(sp->sap_hops));
printf("%lx:%x %x %x %x %x %x: %x\n",
ntohl(sp->sap_net),
sp->sap_node[0],
sp->sap_node[1],
sp->sap_node[2],
sp->sap_node[3],
sp->sap_node[4],
sp->sap_node[5],
ntohs(sp->sap_sock));
result -= sizeof(struct sap_data);
sp++;
}
}
}

View File

@@ -1,5 +1,5 @@
/* Copyright (c) 1995-1996 Caldera, Inc. All Rights Reserved.
*
* See file COPYING for details.
*/
@@ -14,20 +14,21 @@
#include <sys/ioctl.h>
#include <errno.h>
struct option options[] = {
{ "auto_primary", required_argument, NULL, 1 },
{ "auto_interface", required_argument, NULL, 2 },
{ "help", no_argument, NULL, 3},
{ NULL, 0, NULL, 0 }
struct option options[] =
{
{"auto_primary", required_argument, NULL, 1},
{"auto_interface", required_argument, NULL, 2},
{"help", no_argument, NULL, 3},
{NULL, 0, NULL, 0}
};
char *progname;
char *progname;
void
usage(void)
{
fprintf(stderr,
"Usage: %s --auto_primary=[on|off]\n\
fprintf(stderr,
"Usage: %s --auto_primary=[on|off]\n\
Usage: %s --auto_interface=[on|off]\n\
Usage: %s --help\n\
Usage: %s\n", progname, progname, progname, progname);
@@ -37,36 +38,38 @@ int
map_string_to_bool(char *optarg)
{
if ((strcasecmp(optarg, "ON") == 0) ||
(strcasecmp(optarg, "TRUE") == 0) ||
(strcasecmp(optarg, "SET") == 0) ||
(strcasecmp(optarg, "YES") == 0)) {
(strcasecmp(optarg, "TRUE") == 0) ||
(strcasecmp(optarg, "SET") == 0) ||
(strcasecmp(optarg, "YES") == 0))
{
return 1;
} else if ((strcasecmp(optarg, "OFF") == 0) ||
(strcasecmp(optarg, "FALSE") == 0) ||
(strcasecmp(optarg, "CLEAR") == 0) ||
(strcasecmp(optarg, "NO") == 0)) {
(strcasecmp(optarg, "FALSE") == 0) ||
(strcasecmp(optarg, "CLEAR") == 0) ||
(strcasecmp(optarg, "NO") == 0))
{
return 0;
}
}
return -1;
}
int
main(int argc, char **argv)
{
int s;
int result;
char errmsg[80];
char val;
int option_index = 0;
int got_auto_pri = 0;
int got_auto_itf = 0;
ipx_config_data data;
int s;
int result;
char errmsg[80];
char val;
int option_index = 0;
int got_auto_pri = 0;
int got_auto_itf = 0;
ipx_config_data data;
progname = argv[0];
s = socket(AF_IPX, SOCK_DGRAM, AF_IPX);
if (s < 0) {
if (s < 0)
{
int old_errno = errno;
sprintf(errmsg, "%s: socket", progname);
perror(errmsg);
@@ -77,41 +80,44 @@ main(int argc, char **argv)
}
exit(-1);
}
sprintf(errmsg, "%s: ioctl", progname);
while ((result = getopt_long(argc, argv, "", options,
&option_index)) != -1) {
switch (result) {
case 1:
while ((result = getopt_long(argc, argv, "", options,
&option_index)) != -1)
{
switch (result)
{
case 1:
if (got_auto_pri)
break;
got_auto_pri++;
val = map_string_to_bool(optarg);
if (val < 0) {
if (val < 0)
{
usage();
exit(-1);
}
result = ioctl(s, SIOCAIPXPRISLT, &val);
if (result < 0) {
if (result < 0)
{
perror(errmsg);
exit(-1);
}
break;
case 2:
if (got_auto_itf)
if (got_auto_itf)
break;
got_auto_itf++;
val = map_string_to_bool(optarg);
if (val < 0) {
if (val < 0)
{
usage();
exit(-1);
}
result = ioctl(s, SIOCAIPXITFCRT, &val);
if (result < 0) {
if (result < 0)
{
perror(errmsg);
exit(-1);
}
@@ -122,16 +128,17 @@ main(int argc, char **argv)
}
}
result = ioctl(s, SIOCIPXCFGDATA, &data);
if (result < 0) {
if (result < 0)
{
perror(errmsg);
exit(-1);
}
if (argc == 1) {
if (argc == 1)
{
fprintf(stdout, "Auto Primary Select is %s\n\
Auto Interface Create is %s\n",
Auto Interface Create is %s\n",
(data.ipxcfg_auto_select_primary) ? "ON" : "OFF",
(data.ipxcfg_auto_create_interfaces) ? "ON" : "OFF");
}
exit(0);
}

View File

@@ -1,5 +1,6 @@
/* Copyright (c) 1995-1996 Caldera, Inc. All Rights Reserved.
*
* See file COPYING for details.
*/
@@ -17,8 +18,8 @@
#include <sys/ioctl.h>
#include <errno.h>
static struct ifreq id;
static char *progname;
static struct ifreq id;
static char *progname;
void
usage(void)
@@ -30,17 +31,34 @@ Usage: %s check device frame_type\n", progname, progname, progname, progname);
exit(-1);
}
struct frame_type {
char *ft_name;
unsigned char ft_val;
} frame_types[] = {
{"802.2", IPX_FRAME_8022},
struct frame_type
{
char *ft_name;
unsigned char ft_val;
}
frame_types[] =
{
{
"802.2", IPX_FRAME_8022
}
,
#ifdef IPX_FRAME_TR_8022
{"802.2TR", IPX_FRAME_TR_8022},
{
"802.2TR", IPX_FRAME_TR_8022
}
,
#endif
{"802.3", IPX_FRAME_8023},
{"SNAP", IPX_FRAME_SNAP},
{"EtherII", IPX_FRAME_ETHERII}
{
"802.3", IPX_FRAME_8023
}
,
{
"SNAP", IPX_FRAME_SNAP
}
,
{
"EtherII", IPX_FRAME_ETHERII
}
};
#define NFTYPES (sizeof(frame_types)/sizeof(struct frame_type))
@@ -48,20 +66,21 @@ struct frame_type {
int
lookup_frame_type(char *frame)
{
int j;
int j;
for (j = 0; (j < NFTYPES) &&
(strcasecmp(frame_types[j].ft_name, frame));
j++)
for (j = 0; (j < NFTYPES) &&
(strcasecmp(frame_types[j].ft_name, frame));
j++)
;
if (j != NFTYPES)
return j;
fprintf(stderr, "%s: Frame type must be", progname);
for (j = 0; j < NFTYPES; j++) {
fprintf(stderr, "%s%s",
(j == NFTYPES-1) ? " or " : " ",
for (j = 0; j < NFTYPES; j++)
{
fprintf(stderr, "%s%s",
(j == NFTYPES - 1) ? " or " : " ",
frame_types[j].ft_name);
}
fprintf(stderr, ".\n");
@@ -71,44 +90,51 @@ lookup_frame_type(char *frame)
int
ipx_add_interface(int argc, char **argv)
{
struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)&id.ifr_addr;
int s;
int result;
unsigned long netnum;
char errmsg[80];
int i, fti = 0;
char c;
struct sockaddr_ipx *sipx = (struct sockaddr_ipx *) &id.ifr_addr;
int s;
int result;
unsigned long netnum;
char errmsg[80];
int i, fti = 0;
char c;
sipx->sipx_special = IPX_SPECIAL_NONE;
sipx->sipx_network = 0L;
sipx->sipx_type = IPX_FRAME_NONE;
while ((c = getopt(argc, argv, "p")) > 0) {
switch (c) {
case 'p': sipx->sipx_special = IPX_PRIMARY; break;
while ((c = getopt(argc, argv, "p")) > 0)
{
switch (c)
{
case 'p':
sipx->sipx_special = IPX_PRIMARY;
break;
}
}
if (((i = (argc - optind)) < 2) || (i > 3)) {
if (((i = (argc - optind)) < 2) || (i > 3))
{
usage();
}
for (i = optind; i < argc; i++) {
switch (i-optind) {
for (i = optind; i < argc; i++)
{
switch (i - optind)
{
case 0: /* Physical Device - Required */
strcpy(id.ifr_name, argv[i]);
break;
case 1: /* Frame Type - Required */
case 1: /* Frame Type - Required */
fti = lookup_frame_type(argv[i]);
if (fti < 0)
exit(-1);
sipx->sipx_type = frame_types[fti].ft_val;
break;
case 2: /* Network Number - Optional */
netnum = strtoul(argv[i], (char **)NULL, 16);
if (netnum == 0xffffffffL) {
fprintf(stderr,
"%s: Inappropriate network number %08lX\n",
case 2: /* Network Number - Optional */
netnum = strtoul(argv[i], (char **) NULL, 16);
if (netnum == 0xffffffffL)
{
fprintf(stderr,
"%s: Inappropriate network number %08lX\n",
progname, netnum);
exit(-1);
}
@@ -116,9 +142,10 @@ ipx_add_interface(int argc, char **argv)
break;
}
}
s = socket(AF_IPX, SOCK_DGRAM, AF_IPX);
if (s < 0) {
if (s < 0)
{
int old_errno = errno;
sprintf(errmsg, "%s: socket", progname);
perror(errmsg);
@@ -129,18 +156,21 @@ ipx_add_interface(int argc, char **argv)
}
exit(-1);
}
i = 0;
sipx->sipx_family = AF_IPX;
sipx->sipx_action = IPX_CRTITF;
do {
do
{
result = ioctl(s, SIOCSIFADDR, &id);
i++;
} while ((i < 5) && (result < 0) && (errno == EAGAIN));
}
while ((i < 5) && (result < 0) && (errno == EAGAIN));
if (result == 0) exit(0);
switch (errno) {
if (result == 0)
exit(0);
switch (errno)
{
case EEXIST:
fprintf(stderr, "%s: Primary network already selected.\n",
progname);
@@ -166,7 +196,7 @@ ipx_add_interface(int argc, char **argv)
id.ifr_name);
break;
case EAGAIN:
fprintf(stderr,
fprintf(stderr,
"%s: Insufficient memory to create interface.\n",
progname);
break;
@@ -181,61 +211,67 @@ ipx_add_interface(int argc, char **argv)
int
ipx_delall_interface(int argc, char **argv)
{
struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)&id.ifr_addr;
int s;
int result;
char errmsg[80];
char buffer[80];
char device[20];
char frame_type[20];
int fti;
FILE *fp;
struct sockaddr_ipx *sipx = (struct sockaddr_ipx *) &id.ifr_addr;
int s;
int result;
char errmsg[80];
char buffer[80];
char device[20];
char frame_type[20];
int fti;
FILE *fp;
s = socket(AF_IPX, SOCK_DGRAM, AF_IPX);
if (s < 0) {
if (s < 0)
{
sprintf(errmsg, "%s: socket", progname);
perror(errmsg);
exit(-1);
}
fp = fopen("/proc/net/ipx_interface", "r");
if (fp == NULL) {
fprintf(stderr,
if (fp == NULL)
{
fprintf(stderr,
"%s: Unable to open \"/proc/net/ipx_interface.\"\n",
progname);
exit(-1);
}
fgets(buffer, 80, fp);
while (fscanf(fp, "%s %s %s %s %s", buffer, buffer, buffer,
device, frame_type) == 5) {
device, frame_type) == 5)
{
sipx->sipx_network = 0L;
if (strcasecmp(device, "Internal") == 0) {
if (strcasecmp(device, "Internal") == 0)
{
sipx->sipx_special = IPX_INTERNAL;
} else {
} else
{
sipx->sipx_special = IPX_SPECIAL_NONE;
strcpy(id.ifr_name, device);
fti = lookup_frame_type(frame_type);
if (fti < 0) continue;
if (fti < 0)
continue;
sipx->sipx_type = frame_types[fti].ft_val;
}
sipx->sipx_action = IPX_DLTITF;
sipx->sipx_family = AF_IPX;
result = ioctl(s, SIOCSIFADDR, &id);
if (result == 0) continue;
switch (errno) {
if (result == 0)
continue;
switch (errno)
{
case EPROTONOSUPPORT:
fprintf(stderr, "%s: Invalid frame type (%s).\n",
progname, frame_type);
break;
case ENODEV:
fprintf(stderr, "%s: No such device (%s).\n",
fprintf(stderr, "%s: No such device (%s).\n",
progname, device);
break;
case EINVAL:
fprintf(stderr, "%s: No such IPX interface %s %s.\n",
fprintf(stderr, "%s: No such IPX interface %s %s.\n",
progname, device, frame_type);
break;
default:
@@ -251,16 +287,16 @@ ipx_delall_interface(int argc, char **argv)
int
ipx_del_interface(int argc, char **argv)
{
struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)&id.ifr_addr;
int s;
int result;
char errmsg[80];
int fti;
if (argc != 3) {
struct sockaddr_ipx *sipx = (struct sockaddr_ipx *) &id.ifr_addr;
int s;
int result;
char errmsg[80];
int fti;
if (argc != 3)
{
usage();
}
sipx->sipx_network = 0L;
sipx->sipx_special = IPX_SPECIAL_NONE;
strcpy(id.ifr_name, argv[1]);
@@ -270,7 +306,8 @@ ipx_del_interface(int argc, char **argv)
sipx->sipx_type = frame_types[fti].ft_val;
s = socket(AF_IPX, SOCK_DGRAM, AF_IPX);
if (s < 0) {
if (s < 0)
{
sprintf(errmsg, "%s: socket", progname);
perror(errmsg);
exit(-1);
@@ -278,9 +315,11 @@ ipx_del_interface(int argc, char **argv)
sipx->sipx_action = IPX_DLTITF;
sipx->sipx_family = AF_IPX;
result = ioctl(s, SIOCSIFADDR, &id);
if (result == 0) exit(0);
if (result == 0)
exit(0);
switch (errno) {
switch (errno)
{
case EPROTONOSUPPORT:
fprintf(stderr, "%s: Invalid frame type (%s).\n",
progname, frame_types[fti].ft_name);
@@ -304,16 +343,16 @@ ipx_del_interface(int argc, char **argv)
int
ipx_check_interface(int argc, char **argv)
{
struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)&id.ifr_addr;
int s;
int result;
char errmsg[80];
int fti;
if (argc != 3) {
struct sockaddr_ipx *sipx = (struct sockaddr_ipx *) &id.ifr_addr;
int s;
int result;
char errmsg[80];
int fti;
if (argc != 3)
{
usage();
}
sipx->sipx_network = 0L;
strcpy(id.ifr_name, argv[1]);
fti = lookup_frame_type(argv[2]);
@@ -322,25 +361,27 @@ ipx_check_interface(int argc, char **argv)
sipx->sipx_type = frame_types[fti].ft_val;
s = socket(AF_IPX, SOCK_DGRAM, AF_IPX);
if (s < 0) {
if (s < 0)
{
sprintf(errmsg, "%s: socket", progname);
perror(errmsg);
exit(-1);
}
sipx->sipx_family = AF_IPX;
result = ioctl(s, SIOCGIFADDR, &id);
if (result == 0) {
if (result == 0)
{
printf(
"IPX Address for (%s, %s) is %08lX:%02X%02X%02X%02X%02X%02X.\n",
argv[1], frame_types[fti].ft_name,
htonl(sipx->sipx_network), sipx->sipx_node[0],
sipx->sipx_node[1], sipx->sipx_node[2],
sipx->sipx_node[3], sipx->sipx_node[4],
sipx->sipx_node[5]);
"IPX Address for (%s, %s) is %08lX:%02X%02X%02X%02X%02X%02X.\n",
argv[1], frame_types[fti].ft_name,
htonl(sipx->sipx_network), sipx->sipx_node[0],
sipx->sipx_node[1], sipx->sipx_node[2],
sipx->sipx_node[3], sipx->sipx_node[4],
sipx->sipx_node[5]);
exit(0);
}
switch (errno) {
switch (errno)
{
case EPROTONOSUPPORT:
fprintf(stderr, "%s: Invalid frame type (%s).\n",
progname, frame_types[fti].ft_name);
@@ -364,31 +405,35 @@ ipx_check_interface(int argc, char **argv)
int
main(int argc, char **argv)
{
int i;
int i;
progname = argv[0];
if (argc < 2) {
if (argc < 2)
{
usage();
exit(-1);
}
if (strncasecmp(argv[1], "add", 3) == 0) {
for (i = 1; i < (argc-1); i++)
argv[i] = argv[i+1];
ipx_add_interface(argc-1, argv);
} else if (strncasecmp(argv[1], "delall", 6) == 0) {
for (i = 1; i < (argc-1); i++)
argv[i] = argv[i+1];
ipx_delall_interface(argc-1, argv);
} else if (strncasecmp(argv[1], "del", 3) == 0) {
for (i = 1; i < (argc-1); i++)
argv[i] = argv[i+1];
ipx_del_interface(argc-1, argv);
} else if (strncasecmp(argv[1], "check", 5) == 0) {
for (i = 1; i < (argc-1); i++)
argv[i] = argv[i+1];
ipx_check_interface(argc-1, argv);
}
if (strncasecmp(argv[1], "add", 3) == 0)
{
for (i = 1; i < (argc - 1); i++)
argv[i] = argv[i + 1];
ipx_add_interface(argc - 1, argv);
} else if (strncasecmp(argv[1], "delall", 6) == 0)
{
for (i = 1; i < (argc - 1); i++)
argv[i] = argv[i + 1];
ipx_delall_interface(argc - 1, argv);
} else if (strncasecmp(argv[1], "del", 3) == 0)
{
for (i = 1; i < (argc - 1); i++)
argv[i] = argv[i + 1];
ipx_del_interface(argc - 1, argv);
} else if (strncasecmp(argv[1], "check", 5) == 0)
{
for (i = 1; i < (argc - 1); i++)
argv[i] = argv[i + 1];
ipx_check_interface(argc - 1, argv);
}
usage();
return 0;
}

View File

@@ -1,5 +1,5 @@
/* Copyright (c) 1995-1996 Caldera, Inc. All Rights Reserved.
*
* See file COPYING for details.
*/
@@ -15,8 +15,8 @@
#include <sys/socket.h>
#include <sys/ioctl.h>
static struct ifreq id;
static char *progname;
static struct ifreq id;
static char *progname;
void
usage(void)
@@ -29,12 +29,15 @@ Usage: %s del\n", progname, progname);
int
map_char_to_val(char dig)
{
char digit = tolower(dig);
if ((digit >= '0') && (digit <= '9')) {
char digit = tolower(dig);
if ((digit >= '0') && (digit <= '9'))
{
return digit - '0';
} else if ((digit >= 'a') && (digit <= 'f')) {
} else if ((digit >= 'a') && (digit <= 'f'))
{
return (10 + (digit - 'a'));
} else {
} else
{
return 0;
}
}
@@ -42,80 +45,85 @@ map_char_to_val(char dig)
int
ipx_add_internal_net(int argc, char **argv)
{
struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)&id.ifr_addr;
int s;
int result;
unsigned long netnum;
char errmsg[80];
int nodelen;
char *node;
char tmpnode[13];
unsigned char *tout;
char *tin;
int i;
if (argc != 3) {
struct sockaddr_ipx *sipx = (struct sockaddr_ipx *) &id.ifr_addr;
int s;
int result;
unsigned long netnum;
char errmsg[80];
int nodelen;
char *node;
char tmpnode[13];
unsigned char *tout;
char *tin;
int i;
if (argc != 3)
{
usage();
}
netnum = strtoul(argv[1], (char **)NULL, 16);
if ((netnum == 0L) || (netnum == 0xffffffffL)) {
fprintf(stderr, "%s: Inappropriate network number %08lX\n",
netnum = strtoul(argv[1], (char **) NULL, 16);
if ((netnum == 0L) || (netnum == 0xffffffffL))
{
fprintf(stderr, "%s: Inappropriate network number %08lX\n",
progname, netnum);
exit(-1);
}
node = argv[2];
nodelen = strlen(node);
if (nodelen > 12) {
if (nodelen > 12)
{
fprintf(stderr, "%s: Node length is too long (> 12).\n", progname);
exit(-1);
}
for (i = 0; (i < nodelen) && isxdigit(node[i]); i++)
for (i = 0; (i < nodelen) && isxdigit(node[i]); i++)
;
if (i < nodelen) {
if (i < nodelen)
{
fprintf(stderr, "%s: Invalid value in node, must be hex digits.\n",
progname);
exit(-1);
}
strcpy(tmpnode, "000000000000");
memcpy(&(tmpnode[12-nodelen]), node, nodelen);
for (tin = tmpnode, tout = sipx->sipx_node; *tin != '\0'; tin += 2, tout++) {
memcpy(&(tmpnode[12 - nodelen]), node, nodelen);
for (tin = tmpnode, tout = sipx->sipx_node; *tin != '\0'; tin += 2, tout++)
{
*tout = (unsigned char) map_char_to_val(*tin);
*tout <<= 4;
*tout |= (unsigned char) map_char_to_val(*(tin+1));
*tout |= (unsigned char) map_char_to_val(*(tin + 1));
}
if ((memcmp(sipx->sipx_node, "\0\0\0\0\0\0\0\0", IPX_NODE_LEN) == 0) ||
(memcmp(sipx->sipx_node, "\377\377\377\377\377\377", IPX_NODE_LEN) == 0)){
(memcmp(sipx->sipx_node, "\377\377\377\377\377\377", IPX_NODE_LEN) == 0))
{
fprintf(stderr, "%s: Node is invalid.\n", progname);
exit(-1);
}
sipx->sipx_network = htonl(netnum);
sipx->sipx_type = IPX_FRAME_NONE;
sipx->sipx_special = IPX_INTERNAL;
s = socket(AF_IPX, SOCK_DGRAM, AF_IPX);
if (s < 0) {
if (s < 0)
{
sprintf(errmsg, "%s: socket", progname);
perror(errmsg);
exit(-1);
}
sipx->sipx_family = AF_IPX;
sipx->sipx_action = IPX_CRTITF;
i = 0;
do {
do
{
result = ioctl(s, SIOCSIFADDR, &id);
i++;
} while ((i < 5) && (result < 0) && (errno == EAGAIN));
}
while ((i < 5) && (result < 0) && (errno == EAGAIN));
if (result == 0) exit(0);
switch (errno) {
if (result == 0)
exit(0);
switch (errno)
{
case EEXIST:
fprintf(stderr, "%s: Primary network already selected.\n",
progname);
@@ -125,7 +133,7 @@ ipx_add_internal_net(int argc, char **argv)
progname, htonl(sipx->sipx_network));
break;
case EAGAIN:
fprintf(stderr,
fprintf(stderr,
"%s: Insufficient memory to create internal net.\n",
progname);
break;
@@ -140,19 +148,20 @@ ipx_add_internal_net(int argc, char **argv)
int
ipx_del_internal_net(int argc, char **argv)
{
struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)&id.ifr_addr;
int s;
int result;
char errmsg[80];
if (argc != 1) {
struct sockaddr_ipx *sipx = (struct sockaddr_ipx *) &id.ifr_addr;
int s;
int result;
char errmsg[80];
if (argc != 1)
{
usage();
}
sipx->sipx_network = 0L;
sipx->sipx_special = IPX_INTERNAL;
s = socket(AF_IPX, SOCK_DGRAM, AF_IPX);
if (s < 0) {
if (s < 0)
{
sprintf(errmsg, "%s: socket", progname);
perror(errmsg);
exit(-1);
@@ -160,9 +169,11 @@ ipx_del_internal_net(int argc, char **argv)
sipx->sipx_family = AF_IPX;
sipx->sipx_action = IPX_DLTITF;
result = ioctl(s, SIOCSIFADDR, &id);
if (result == 0) exit(0);
if (result == 0)
exit(0);
switch (errno) {
switch (errno)
{
case ENOENT:
fprintf(stderr, "%s: No internal network configured.\n", progname);
break;
@@ -177,24 +188,25 @@ ipx_del_internal_net(int argc, char **argv)
int
main(int argc, char **argv)
{
int i;
int i;
progname = argv[0];
if (argc < 2) {
if (argc < 2)
{
usage();
exit(-1);
}
if (strncasecmp(argv[1], "add", 3) == 0) {
for (i = 1; i < (argc-1); i++)
argv[i] = argv[i+1];
ipx_add_internal_net(argc-1, argv);
} else if (strncasecmp(argv[1], "del", 3) == 0) {
for (i = 1; i < (argc-1); i++)
argv[i] = argv[i+1];
ipx_del_internal_net(argc-1, argv);
if (strncasecmp(argv[1], "add", 3) == 0)
{
for (i = 1; i < (argc - 1); i++)
argv[i] = argv[i + 1];
ipx_add_internal_net(argc - 1, argv);
} else if (strncasecmp(argv[1], "del", 3) == 0)
{
for (i = 1; i < (argc - 1); i++)
argv[i] = argv[i + 1];
ipx_del_internal_net(argc - 1, argv);
}
usage();
return 0;
}

View File

@@ -1,5 +1,6 @@
/* Copyright (c) 1995-1996 Caldera, Inc. All Rights Reserved.
*
* See file COPYING for details.
*/
@@ -16,18 +17,21 @@
#include <sys/ioctl.h>
#include <linux/route.h>
static struct rtentry rd;
static char *progname;
static struct rtentry rd;
static char *progname;
int
map_char_to_val(char dig)
{
char digit = tolower(dig);
if ((digit >= '0') && (digit <= '9')) {
char digit = tolower(dig);
if ((digit >= '0') && (digit <= '9'))
{
return digit - '0';
} else if ((digit >= 'a') && (digit <= 'f')) {
} else if ((digit >= 'a') && (digit <= 'f'))
{
return (10 + (digit - 'a'));
} else {
} else
{
return 0;
}
}
@@ -35,8 +39,8 @@ map_char_to_val(char dig)
void
usage(void)
{
fprintf(stderr,
"Usage: %s add network(hex) router_network(hex) router_node(hex)\n\
fprintf(stderr,
"Usage: %s add network(hex) router_network(hex) router_node(hex)\n\
Usage: %s del network(hex)\n", progname, progname);
exit(-1);
}
@@ -45,27 +49,28 @@ int
ipx_add_route(int argc, char **argv)
{
/* Router */
struct sockaddr_ipx *sr = (struct sockaddr_ipx *)&rd.rt_gateway;
struct sockaddr_ipx *sr = (struct sockaddr_ipx *) &rd.rt_gateway;
/* Target */
struct sockaddr_ipx *st = (struct sockaddr_ipx *)&rd.rt_dst;
int s;
int result;
int nodelen;
int i;
unsigned long netnum;
char errmsg[80];
char *node;
char *tin;
char tmpnode[13];
unsigned char *tout;
struct sockaddr_ipx *st = (struct sockaddr_ipx *) &rd.rt_dst;
int s;
int result;
int nodelen;
int i;
unsigned long netnum;
char errmsg[80];
char *node;
char *tin;
char tmpnode[13];
unsigned char *tout;
if (argc != 4)
usage();
/* Network Number */
netnum = strtoul(argv[1], (char **)NULL, 16);
if ((netnum == 0xffffffffL) || (netnum == 0L)) {
fprintf(stderr, "%s: Inappropriate network number %08lX\n",
netnum = strtoul(argv[1], (char **) NULL, 16);
if ((netnum == 0xffffffffL) || (netnum == 0L))
{
fprintf(stderr, "%s: Inappropriate network number %08lX\n",
progname, netnum);
exit(-1);
}
@@ -73,63 +78,69 @@ ipx_add_route(int argc, char **argv)
st->sipx_network = htonl(netnum);
/* Router Network Number */
netnum = strtoul(argv[2], (char **)NULL, 16);
if ((netnum == 0xffffffffL) || (netnum == 0L)) {
fprintf(stderr, "%s: Inappropriate network number %08lX\n",
netnum = strtoul(argv[2], (char **) NULL, 16);
if ((netnum == 0xffffffffL) || (netnum == 0L))
{
fprintf(stderr, "%s: Inappropriate network number %08lX\n",
progname, netnum);
exit(-1);
}
sr->sipx_network = htonl(netnum);
/* Router Node */
node = argv[3];
nodelen = strlen(node);
if (nodelen > 12) {
fprintf(stderr, "%s: Node length is too long (> 12).\n",
if (nodelen > 12)
{
fprintf(stderr, "%s: Node length is too long (> 12).\n",
progname);
exit(-1);
}
for (i = 0; (i < nodelen) && isxdigit(node[i]); i++)
for (i = 0; (i < nodelen) && isxdigit(node[i]); i++)
;
if (i < nodelen) {
if (i < nodelen)
{
fprintf(stderr, "%s: Invalid value in node, must be hex digits.\n",
progname);
exit(-1);
}
strcpy(tmpnode, "000000000000");
memcpy(&(tmpnode[12-nodelen]), node, nodelen);
for (tin = tmpnode, tout = sr->sipx_node; *tin != '\0'; tin += 2, tout++) {
memcpy(&(tmpnode[12 - nodelen]), node, nodelen);
for (tin = tmpnode, tout = sr->sipx_node; *tin != '\0'; tin += 2, tout++)
{
*tout = (unsigned char) map_char_to_val(*tin);
*tout <<= 4;
*tout |= (unsigned char) map_char_to_val(*(tin+1));
*tout |= (unsigned char) map_char_to_val(*(tin + 1));
}
if ((memcmp(sr->sipx_node, "\0\0\0\0\0\0\0\0", IPX_NODE_LEN) == 0) ||
(memcmp(sr->sipx_node, "\377\377\377\377\377\377", IPX_NODE_LEN) == 0)){
(memcmp(sr->sipx_node, "\377\377\377\377\377\377", IPX_NODE_LEN) == 0))
{
fprintf(stderr, "%s: Node (%s) is invalid.\n", progname, tmpnode);
exit(-1);
}
s = socket(AF_IPX, SOCK_DGRAM, AF_IPX);
if (s < 0) {
if (s < 0)
{
sprintf(errmsg, "%s: socket", progname);
perror(errmsg);
exit(-1);
}
sr->sipx_family = st->sipx_family = AF_IPX;
i = 0;
do {
do
{
result = ioctl(s, SIOCADDRT, &rd);
i++;
} while ((i < 5) && (result < 0) && (errno == EAGAIN));
}
while ((i < 5) && (result < 0) && (errno == EAGAIN));
if (result == 0) exit(0);
if (result == 0)
exit(0);
switch (errno) {
switch (errno)
{
case ENETUNREACH:
fprintf(stderr, "%s: Router network (%08lX) not reachable.\n",
progname, htonl(sr->sipx_network));
@@ -146,23 +157,24 @@ int
ipx_del_route(int argc, char **argv)
{
/* Router */
struct sockaddr_ipx *sr = (struct sockaddr_ipx *)&rd.rt_gateway;
struct sockaddr_ipx *sr = (struct sockaddr_ipx *) &rd.rt_gateway;
/* Target */
struct sockaddr_ipx *st = (struct sockaddr_ipx *)&rd.rt_dst;
int s;
int result;
unsigned long netnum;
char errmsg[80];
if (argc != 2) {
struct sockaddr_ipx *st = (struct sockaddr_ipx *) &rd.rt_dst;
int s;
int result;
unsigned long netnum;
char errmsg[80];
if (argc != 2)
{
usage();
}
rd.rt_flags = RTF_GATEWAY;
/* Network Number */
netnum = strtoul(argv[1], (char **)NULL, 16);
if ((netnum == 0xffffffffL) || (netnum == 0L)) {
fprintf(stderr, "%s: Inappropriate network number %08lX.\n",
netnum = strtoul(argv[1], (char **) NULL, 16);
if ((netnum == 0xffffffffL) || (netnum == 0L))
{
fprintf(stderr, "%s: Inappropriate network number %08lX.\n",
progname, netnum);
exit(-1);
}
@@ -170,15 +182,18 @@ ipx_del_route(int argc, char **argv)
st->sipx_family = sr->sipx_family = AF_IPX;
s = socket(AF_IPX, SOCK_DGRAM, AF_IPX);
if (s < 0) {
if (s < 0)
{
sprintf(errmsg, "%s: socket", progname);
perror(errmsg);
exit(-1);
}
result = ioctl(s, SIOCDELRT, &rd);
if (result == 0) exit(0);
if (result == 0)
exit(0);
switch (errno) {
switch (errno)
{
case ENOENT:
fprintf(stderr, "%s: Route not found for network %08lX.\n",
progname, netnum);
@@ -198,22 +213,24 @@ ipx_del_route(int argc, char **argv)
int
main(int argc, char **argv)
{
int i;
int i;
progname = argv[0];
if (argc < 2) {
if (argc < 2)
{
usage();
exit(-1);
}
if (strncasecmp(argv[1], "add", 3) == 0) {
for (i = 1; i < (argc-1); i++)
argv[i] = argv[i+1];
ipx_add_route(argc-1, argv);
} else if (strncasecmp(argv[1], "del", 3) == 0) {
for (i = 1; i < (argc-1); i++)
argv[i] = argv[i+1];
ipx_del_route(argc-1, argv);
if (strncasecmp(argv[1], "add", 3) == 0)
{
for (i = 1; i < (argc - 1); i++)
argv[i] = argv[i + 1];
ipx_add_route(argc - 1, argv);
} else if (strncasecmp(argv[1], "del", 3) == 0)
{
for (i = 1; i < (argc - 1); i++)
argv[i] = argv[i + 1];
ipx_del_route(argc - 1, argv);
}
usage();
return 0;

View File

@@ -1,7 +1,7 @@
/* ipxdump.c */
/* ipxdump.c */
/* Copyright 1996 Volker Lendecke, Goettingen, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -37,29 +37,29 @@
struct ipx_address
{
unsigned long net;
unsigned char node[IPX_NODE_LEN];
unsigned char node[IPX_NODE_LEN];
unsigned short sock;
};
struct ipx_packet
{
unsigned short ipx_checksum;
unsigned short ipx_checksum;
#define IPX_NO_CHECKSUM 0xFFFF
unsigned short ipx_pktsize;
unsigned char ipx_tctrl;
unsigned char ipx_type;
unsigned short ipx_pktsize;
unsigned char ipx_tctrl;
unsigned char ipx_type;
#define IPX_TYPE_UNKNOWN 0x00
#define IPX_TYPE_RIP 0x01 /* may also be 0 */
#define IPX_TYPE_SAP 0x04 /* may also be 0 */
#define IPX_TYPE_SPX 0x05 /* Not yet implemented */
#define IPX_TYPE_NCP 0x11 /* $lots for docs on this (SPIT) */
#define IPX_TYPE_PPROP 0x14 /* complicated flood fill brdcast [Not supported] */
struct ipx_address ipx_dest __attribute__ ((packed));
struct ipx_address ipx_source __attribute__ ((packed));
struct ipx_address ipx_dest __attribute__((packed));
struct ipx_address ipx_source __attribute__((packed));
};
void handle_frame (unsigned char *buf, int length, struct sockaddr *saddr);
void handle_frame(unsigned char *buf, int length, struct sockaddr *saddr);
void handle_ipx(char *frame, unsigned char *buf);
static int filter = 0;
@@ -73,7 +73,7 @@ int_handler()
}
void
main (int argc, char *argv[])
main(int argc, char *argv[])
{
int sd;
struct ifreq ifr, oldifr;
@@ -94,63 +94,59 @@ main (int argc, char *argv[])
}
filter = 1;
}
if ((sd = socket (AF_INET, SOCK_PACKET, htons (ETH_P_ALL))) < 0)
if ((sd = socket(AF_INET, SOCK_PACKET, htons(ETH_P_ALL))) < 0)
{
perror ("Can't get socket");
perror("Can't get socket");
fprintf(stderr, "You must run %s as root\n", argv[0]);
exit (1);
exit(1);
}
/* SET PROMISC */
strcpy (oldifr.ifr_name, device);
if (ioctl (sd, SIOCGIFFLAGS, &oldifr) < 0)
strcpy(oldifr.ifr_name, device);
if (ioctl(sd, SIOCGIFFLAGS, &oldifr) < 0)
{
close (sd);
perror ("Can't get flags");
exit (2);
close(sd);
perror("Can't get flags");
exit(2);
}
/* This should be rewritten to cooperate with other net tools */
ifr = oldifr;
ifr.ifr_flags |= IFF_PROMISC;
if (ioctl (sd, SIOCSIFFLAGS, &ifr) < 0)
if (ioctl(sd, SIOCSIFFLAGS, &ifr) < 0)
{
close (sd);
perror ("Can't set flags");
exit (3);
close(sd);
perror("Can't set flags");
exit(3);
}
while ( exit_request == 0 )
while (exit_request == 0)
{
/* This is the main data-gathering loop; keep it small
and fast */
sizeaddr = sizeof(saddr);
length = recvfrom (sd, buf, sizeof(buf), 0,
&saddr, &sizeaddr);
if (length < 0 ) continue;
handle_frame (buf, length, &saddr);
length = recvfrom(sd, buf, sizeof(buf), 0,
&saddr, &sizeaddr);
if (length < 0)
continue;
handle_frame(buf, length, &saddr);
}
/* This should be rewritten to cooperate with other net tools */
if (ioctl (sd, SIOCSIFFLAGS, &oldifr) < 0)
if (ioctl(sd, SIOCSIFFLAGS, &oldifr) < 0)
{
close (sd);
perror ("Can't set flags");
exit (4);
close(sd);
perror("Can't set flags");
exit(4);
}
close (sd);
exit (0);
close(sd);
exit(0);
}
void
handle_ipx (char *frame, unsigned char *buf)
handle_ipx(char *frame, unsigned char *buf)
{
int i;
struct ipx_packet *h = (struct ipx_packet *)buf;
struct ipx_packet *h = (struct ipx_packet *) buf;
struct sockaddr_ipx s_addr;
struct sockaddr_ipx d_addr;
int length = ntohs(h->ipx_pktsize);
@@ -161,16 +157,16 @@ handle_ipx (char *frame, unsigned char *buf)
memcpy(s_addr.sipx_node, h->ipx_source.node, sizeof(s_addr.sipx_node));
s_addr.sipx_port = h->ipx_source.sock;
s_addr.sipx_network = h->ipx_source.net;
s_addr.sipx_network = h->ipx_source.net;
memcpy(d_addr.sipx_node, h->ipx_dest.node, sizeof(d_addr.sipx_node));
d_addr.sipx_port = h->ipx_dest.sock;
d_addr.sipx_network = h->ipx_dest.net;
d_addr.sipx_network = h->ipx_dest.net;
if (filter != 0)
{
if ( (memcmp(filter_node, s_addr.sipx_node,
sizeof(filter_node)) != 0)
if ((memcmp(filter_node, s_addr.sipx_node,
sizeof(filter_node)) != 0)
&& (memcmp(filter_node, d_addr.sipx_node,
sizeof(filter_node)) != 0))
{
@@ -178,7 +174,6 @@ handle_ipx (char *frame, unsigned char *buf)
return;
}
}
printf("%s ", frame);
for (i = 0; i < length; i++)
@@ -193,9 +188,9 @@ handle_ipx (char *frame, unsigned char *buf)
}
void
handle_other (unsigned char *buf, int length, struct sockaddr *saddr)
handle_other(unsigned char *buf, int length, struct sockaddr *saddr)
{
struct ethhdr *eth = (struct ethhdr *)buf;
struct ethhdr *eth = (struct ethhdr *) buf;
unsigned char *p = &(buf[sizeof(struct ethhdr)]);
if (ntohs(eth->h_proto) < 1536)
@@ -206,34 +201,32 @@ handle_other (unsigned char *buf, int length, struct sockaddr *saddr)
* which isnt a used 802.2 SSAP/DSAP. This won't work
* for fault tolerant netware but does for the rest.
*/
if (*(unsigned short *)p == 0xffff)
if (*(unsigned short *) p == 0xffff)
{
handle_ipx("802.3", p);
return;
}
if ( (*(unsigned short *)p == htons(0xe0e0))
if ((*(unsigned short *) p == htons(0xe0e0))
&& (p[2] == 0x03))
{
handle_ipx("802.2", p+3);
handle_ipx("802.2", p + 3);
return;
}
if (memcmp(p, "\252\252\003\000\000\000\201\067", 8) == 0)
{
handle_ipx("snap", p+8);
handle_ipx("snap", p + 8);
return;
}
}
}
void
handle_frame (unsigned char *buf, int length, struct sockaddr *saddr)
handle_frame(unsigned char *buf, int length, struct sockaddr *saddr)
{
/* Ethernet packet type ID field */
unsigned short packet_type = ((struct ethhdr *)buf)->h_proto;
switch( packet_type )
unsigned short packet_type = ((struct ethhdr *) buf)->h_proto;
switch (packet_type)
{
case __constant_ntohs(ETH_P_IPX):
handle_ipx("EtherII", &(buf[sizeof(struct ethhdr)]));

File diff suppressed because it is too large Load Diff

View File

@@ -1,97 +1,101 @@
/*
IPX support library - general functions
IPX support library - general functions
Copyright (C) 1994, 1995 Ales Dryak <e-mail: A.Dryak@sh.cvut.cz>
Copyright (C) 1996, Volker Lendecke <lendecke@namu01.gwdg.de>
Copyright (C) 1994, 1995 Ales Dryak <e-mail: A.Dryak@sh.cvut.cz>
Copyright (C) 1996, Volker Lendecke <lendecke@namu01.gwdg.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
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 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 for more details.
You should have received a copy of the GNU General Public License
along with this program; 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
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
*/
#include <string.h>
#include <netinet/in.h>
#include "ipxutil.h"
void
ipx_fprint_node(FILE *file, IPXNode node)
ipx_fprint_node(FILE * file, IPXNode node)
{
fprintf(file,"%02X%02X%02X%02X%02X%02X",
(unsigned char)node[0],
(unsigned char)node[1],
(unsigned char)node[2],
(unsigned char)node[3],
(unsigned char)node[4],
(unsigned char)node[5]
);
fprintf(file, "%02X%02X%02X%02X%02X%02X",
(unsigned char) node[0],
(unsigned char) node[1],
(unsigned char) node[2],
(unsigned char) node[3],
(unsigned char) node[4],
(unsigned char) node[5]
);
}
void
ipx_fprint_network(FILE *file, IPXNet net)
ipx_fprint_network(FILE * file, IPXNet net)
{
fprintf(file,"%08lX",net);
fprintf(file, "%08lX", net);
}
void
ipx_fprint_port(FILE *file, IPXPort port)
ipx_fprint_port(FILE * file, IPXPort port)
{
fprintf(file,"%04X",port);
fprintf(file, "%04X", port);
}
void
ipx_fprint_saddr(FILE *file, struct sockaddr_ipx *sipx)
ipx_fprint_saddr(FILE * file, struct sockaddr_ipx *sipx)
{
ipx_fprint_network(file,ntohl(sipx->sipx_network));
fprintf(file,":");
ipx_fprint_node(file,sipx->sipx_node);
fprintf(file,":");
ipx_fprint_port(file,ntohs(sipx->sipx_port));
ipx_fprint_network(file, ntohl(sipx->sipx_network));
fprintf(file, ":");
ipx_fprint_node(file, sipx->sipx_node);
fprintf(file, ":");
ipx_fprint_port(file, ntohs(sipx->sipx_port));
}
void
ipx_print_node(IPXNode node)
{
ipx_fprint_node(stdout,node);
ipx_fprint_node(stdout, node);
}
void
ipx_print_network(IPXNet net)
{
ipx_fprint_network(stdout,net);
ipx_fprint_network(stdout, net);
}
void
ipx_print_port(IPXPort port)
{
ipx_fprint_port(stdout,port);
ipx_fprint_port(stdout, port);
}
void
ipx_print_saddr(struct sockaddr_ipx *sipx)
{
ipx_fprint_saddr(stdout,sipx);
ipx_fprint_saddr(stdout, sipx);
}
void
ipx_assign_node(IPXNode dest, IPXNode src)
{
memcpy(dest,src,sizeof(IPXNode));
memcpy(dest, src, sizeof(IPXNode));
}
int
ipx_node_equal(IPXNode n1, IPXNode n2)
{
return memcmp(n1,n2,sizeof(IPXNode))==0;
return memcmp(n1, n2, sizeof(IPXNode)) == 0;
}
int
@@ -106,8 +110,7 @@ ipx_sscanf_node(char *buf, IPXNode node)
{
return -1;
}
for (i=0; i<6; i++)
for (i = 0; i < 6; i++)
{
node[i] = n[i];
}
@@ -115,7 +118,7 @@ ipx_sscanf_node(char *buf, IPXNode node)
}
int
ipx_sscanf_net(char *buf, IPXNet *target)
ipx_sscanf_net(char *buf, IPXNet * target)
{
if (sscanf(buf, "%8lX", target) == 1)
{
@@ -124,6 +127,8 @@ ipx_sscanf_net(char *buf, IPXNet *target)
return -1;
}
IPXNode ipx_this_node={0,0,0,0,0,0};
IPXNode ipx_broadcast_node={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
char ipx_err_string[IPX_MAX_ERROR+1]="no error detected";
IPXNode ipx_this_node =
{0, 0, 0, 0, 0, 0};
IPXNode ipx_broadcast_node =
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
char ipx_err_string[IPX_MAX_ERROR + 1] = "no error detected";

View File

@@ -1,25 +1,25 @@
/*
IPX support library
IPX support library
Copyright (C) 1994, 1995 Ales Dryak <e-mail: A.Dryak@sh.cvut.cz>
Copyright (C) 1996, Volker Lendecke <lendecke@namu01.gwdg.de>
Copyright (C) 1994, 1995 Ales Dryak <e-mail: A.Dryak@sh.cvut.cz>
Copyright (C) 1996, Volker Lendecke <lendecke@namu01.gwdg.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
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 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 for more details.
You should have received a copy of the GNU General Public License
along with this program; 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
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
*/
#ifndef __IPXUTIL_H__
#define __IPXUTIL_H__
@@ -44,22 +44,22 @@ typedef unsigned short int tick_t;
void ipx_print_node(IPXNode node);
void ipx_print_network(IPXNet net);
void ipx_print_port(IPXPort port);
void ipx_print_saddr(struct sockaddr_ipx* sipx);
void ipx_print_saddr(struct sockaddr_ipx *sipx);
void ipx_fprint_node(FILE* file,IPXNode node);
void ipx_fprint_network(FILE* file,IPXNet net);
void ipx_fprint_port(FILE* file,IPXPort port);
void ipx_fprint_saddr(FILE* file,struct sockaddr_ipx* sipx);
void ipx_fprint_node(FILE * file, IPXNode node);
void ipx_fprint_network(FILE * file, IPXNet net);
void ipx_fprint_port(FILE * file, IPXPort port);
void ipx_fprint_saddr(FILE * file, struct sockaddr_ipx *sipx);
int ipx_sscanf_node(char *buf, IPXNode node);
int ipx_sscanf_net(char *buf, IPXNet *target);
int ipx_sscanf_net(char *buf, IPXNet * target);
void ipx_assign_node(IPXNode dest,IPXNode src);
int ipx_node_equal(IPXNode n1,IPXNode n2);
void ipx_assign_node(IPXNode dest, IPXNode src);
int ipx_node_equal(IPXNode n1, IPXNode n2);
extern IPXNode ipx_this_node;
extern IPXNode ipx_broadcast_node;
extern char ipx_err_string[IPX_MAX_ERROR+1];
extern char ipx_err_string[IPX_MAX_ERROR + 1];
#endif

View File

@@ -18,28 +18,30 @@
#define NCP_REQUEST (0x2222)
#define NCP_DEALLOC_SLOT_REQUEST (0x5555)
struct ncp_request_header {
__u16 type __attribute__ ((packed));
__u8 sequence __attribute__ ((packed));
__u8 conn_low __attribute__ ((packed));
__u8 task __attribute__ ((packed));
__u8 conn_high __attribute__ ((packed));
__u8 function __attribute__ ((packed));
__u8 data[0] __attribute__ ((packed));
struct ncp_request_header
{
__u16 type __attribute__((packed));
__u8 sequence __attribute__((packed));
__u8 conn_low __attribute__((packed));
__u8 task __attribute__((packed));
__u8 conn_high __attribute__((packed));
__u8 function __attribute__((packed));
__u8 data[0] __attribute__((packed));
};
#define NCP_REPLY (0x3333)
#define NCP_POSITIVE_ACK (0x9999)
struct ncp_reply_header {
__u16 type __attribute__ ((packed));
__u8 sequence __attribute__ ((packed));
__u8 conn_low __attribute__ ((packed));
__u8 task __attribute__ ((packed));
__u8 conn_high __attribute__ ((packed));
__u8 completion_code __attribute__ ((packed));
__u8 connection_state __attribute__ ((packed));
__u8 data[0] __attribute__ ((packed));
struct ncp_reply_header
{
__u16 type __attribute__((packed));
__u8 sequence __attribute__((packed));
__u8 conn_low __attribute__((packed));
__u8 task __attribute__((packed));
__u8 conn_high __attribute__((packed));
__u8 completion_code __attribute__((packed));
__u8 connection_state __attribute__((packed));
__u8 data[0] __attribute__((packed));
};
@@ -48,45 +50,50 @@ struct ncp_reply_header {
#define NCP_BINDERY_PQUEUE (0x0003)
#define NCP_BINDERY_FSERVER (0x0004)
#define NCP_BINDERY_NAME_LEN (48)
struct ncp_bindery_object {
__u32 object_id;
__u16 object_type;
__u8 object_name[NCP_BINDERY_NAME_LEN];
__u8 object_flags;
__u8 object_security;
__u8 object_has_prop;
struct ncp_bindery_object
{
__u32 object_id;
__u16 object_type;
__u8 object_name[NCP_BINDERY_NAME_LEN];
__u8 object_flags;
__u8 object_security;
__u8 object_has_prop;
};
struct nw_property {
__u8 value[128];
__u8 more_flag;
__u8 property_flag;
struct nw_property
{
__u8 value[128];
__u8 more_flag;
__u8 property_flag;
};
struct prop_net_address {
__u32 network __attribute__ ((packed));
__u8 node[IPX_NODE_LEN] __attribute__ ((packed));
__u16 port __attribute__ ((packed));
struct prop_net_address
{
__u32 network __attribute__((packed));
__u8 node[IPX_NODE_LEN] __attribute__((packed));
__u16 port __attribute__((packed));
};
#define NCP_VOLNAME_LEN (16)
#define NCP_NUMBER_OF_VOLUMES (64)
struct ncp_volume_info {
__u32 total_blocks;
__u32 free_blocks;
__u32 purgeable_blocks;
__u32 not_yet_purgeable_blocks;
__u32 total_dir_entries;
__u32 available_dir_entries;
__u8 sectors_per_block;
char volume_name[NCP_VOLNAME_LEN+1];
struct ncp_volume_info
{
__u32 total_blocks;
__u32 free_blocks;
__u32 purgeable_blocks;
__u32 not_yet_purgeable_blocks;
__u32 total_dir_entries;
__u32 available_dir_entries;
__u8 sectors_per_block;
char volume_name[NCP_VOLNAME_LEN + 1];
};
struct ncp_filesearch_info {
__u8 volume_number;
__u16 directory_id;
__u16 sequence_no;
__u8 access_rights;
struct ncp_filesearch_info
{
__u8 volume_number;
__u16 directory_id;
__u16 sequence_no;
__u8 access_rights;
};
#define NCP_MAX_FILENAME 14
@@ -104,16 +111,17 @@ struct ncp_filesearch_info {
#define AR_EXCLUSIVE (0x20)
#define NCP_FILE_ID_LEN 6
struct ncp_file_info {
__u8 file_id[NCP_FILE_ID_LEN];
char file_name[NCP_MAX_FILENAME+1];
__u8 file_attributes;
__u8 file_mode;
__u32 file_length;
__u16 creation_date;
__u16 access_date;
__u16 update_date;
__u16 update_time;
struct ncp_file_info
{
__u8 file_id[NCP_FILE_ID_LEN];
char file_name[NCP_MAX_FILENAME + 1];
__u8 file_attributes;
__u8 file_mode;
__u32 file_length;
__u16 creation_date;
__u16 access_date;
__u16 update_date;
__u16 update_time;
};
/* Defines for Name Spaces */
@@ -165,32 +173,32 @@ struct ncp_file_info {
struct nw_info_struct
{
__u32 spaceAlloc __attribute__ ((packed));
__u32 attributes __attribute__ ((packed));
__u16 flags __attribute__ ((packed));
__u32 dataStreamSize __attribute__ ((packed));
__u32 totalStreamSize __attribute__ ((packed));
__u16 numberOfStreams __attribute__ ((packed));
__u16 creationTime __attribute__ ((packed));
__u16 creationDate __attribute__ ((packed));
__u32 creatorID __attribute__ ((packed));
__u16 modifyTime __attribute__ ((packed));
__u16 modifyDate __attribute__ ((packed));
__u32 modifierID __attribute__ ((packed));
__u16 lastAccessDate __attribute__ ((packed));
__u16 archiveTime __attribute__ ((packed));
__u16 archiveDate __attribute__ ((packed));
__u32 archiverID __attribute__ ((packed));
__u16 inheritedRightsMask __attribute__ ((packed));
__u32 dirEntNum __attribute__ ((packed));
__u32 DosDirNum __attribute__ ((packed));
__u32 volNumber __attribute__ ((packed));
__u32 EADataSize __attribute__ ((packed));
__u32 EAKeyCount __attribute__ ((packed));
__u32 EAKeySize __attribute__ ((packed));
__u32 NSCreator __attribute__ ((packed));
__u8 nameLen __attribute__ ((packed));
__u8 entryName[256] __attribute__ ((packed));
__u32 spaceAlloc __attribute__((packed));
__u32 attributes __attribute__((packed));
__u16 flags __attribute__((packed));
__u32 dataStreamSize __attribute__((packed));
__u32 totalStreamSize __attribute__((packed));
__u16 numberOfStreams __attribute__((packed));
__u16 creationTime __attribute__((packed));
__u16 creationDate __attribute__((packed));
__u32 creatorID __attribute__((packed));
__u16 modifyTime __attribute__((packed));
__u16 modifyDate __attribute__((packed));
__u32 modifierID __attribute__((packed));
__u16 lastAccessDate __attribute__((packed));
__u16 archiveTime __attribute__((packed));
__u16 archiveDate __attribute__((packed));
__u32 archiverID __attribute__((packed));
__u16 inheritedRightsMask __attribute__((packed));
__u32 dirEntNum __attribute__((packed));
__u32 DosDirNum __attribute__((packed));
__u32 volNumber __attribute__((packed));
__u32 EADataSize __attribute__((packed));
__u32 EAKeyCount __attribute__((packed));
__u32 EAKeySize __attribute__((packed));
__u32 NSCreator __attribute__((packed));
__u8 nameLen __attribute__((packed));
__u8 entryName[256] __attribute__((packed));
};
/* modify mask - use with MODIFY_DOS_INFO structure */
@@ -210,62 +218,66 @@ struct nw_info_struct
struct nw_modify_dos_info
{
__u32 attributes __attribute__ ((packed));
__u16 creationDate __attribute__ ((packed));
__u16 creationTime __attribute__ ((packed));
__u32 creatorID __attribute__ ((packed));
__u16 modifyDate __attribute__ ((packed));
__u16 modifyTime __attribute__ ((packed));
__u32 modifierID __attribute__ ((packed));
__u16 archiveDate __attribute__ ((packed));
__u16 archiveTime __attribute__ ((packed));
__u32 archiverID __attribute__ ((packed));
__u16 lastAccessDate __attribute__ ((packed));
__u16 inheritanceGrantMask __attribute__ ((packed));
__u16 inheritanceRevokeMask __attribute__ ((packed));
__u32 maximumSpace __attribute__ ((packed));
__u32 attributes __attribute__((packed));
__u16 creationDate __attribute__((packed));
__u16 creationTime __attribute__((packed));
__u32 creatorID __attribute__((packed));
__u16 modifyDate __attribute__((packed));
__u16 modifyTime __attribute__((packed));
__u32 modifierID __attribute__((packed));
__u16 archiveDate __attribute__((packed));
__u16 archiveTime __attribute__((packed));
__u32 archiverID __attribute__((packed));
__u16 lastAccessDate __attribute__((packed));
__u16 inheritanceGrantMask __attribute__((packed));
__u16 inheritanceRevokeMask __attribute__((packed));
__u32 maximumSpace __attribute__((packed));
};
struct nw_file_info {
struct nw_file_info
{
struct nw_info_struct i;
int opened;
int access;
__u32 server_file_handle __attribute__ ((packed));
__u8 open_create_action __attribute__ ((packed));
__u8 file_handle[6] __attribute__ ((packed));
int opened;
int access;
__u32 server_file_handle __attribute__((packed));
__u8 open_create_action __attribute__((packed));
__u8 file_handle[6] __attribute__((packed));
};
struct nw_search_sequence {
__u8 volNumber __attribute__ ((packed));
__u32 dirBase __attribute__ ((packed));
__u32 sequence __attribute__ ((packed));
struct nw_search_sequence
{
__u8 volNumber __attribute__((packed));
__u32 dirBase __attribute__((packed));
__u32 sequence __attribute__((packed));
};
struct nw_queue_job_entry {
__u16 InUse __attribute__ ((packed));
__u32 prev __attribute__ ((packed));
__u32 next __attribute__ ((packed));
__u32 ClientStation __attribute__ ((packed));
__u32 ClientTask __attribute__ ((packed));
__u32 ClientObjectID __attribute__ ((packed));
__u32 TargetServerID __attribute__ ((packed));
__u8 TargetExecTime[6] __attribute__ ((packed));
__u8 JobEntryTime[6] __attribute__ ((packed));
__u32 JobNumber __attribute__ ((packed));
__u16 JobType __attribute__ ((packed));
__u16 JobPosition __attribute__ ((packed));
__u16 JobControlFlags __attribute__ ((packed));
__u8 FileNameLen __attribute__ ((packed));
char JobFileName[13] __attribute__ ((packed));
__u32 JobFileHandle __attribute__ ((packed));
__u32 ServerStation __attribute__ ((packed));
__u32 ServerTaskNumber __attribute__ ((packed));
__u32 ServerObjectID __attribute__ ((packed));
char JobTextDescription[50] __attribute__ ((packed));
char ClientRecordArea[152] __attribute__ ((packed));
struct nw_queue_job_entry
{
__u16 InUse __attribute__((packed));
__u32 prev __attribute__((packed));
__u32 next __attribute__((packed));
__u32 ClientStation __attribute__((packed));
__u32 ClientTask __attribute__((packed));
__u32 ClientObjectID __attribute__((packed));
__u32 TargetServerID __attribute__((packed));
__u8 TargetExecTime[6] __attribute__((packed));
__u8 JobEntryTime[6] __attribute__((packed));
__u32 JobNumber __attribute__((packed));
__u16 JobType __attribute__((packed));
__u16 JobPosition __attribute__((packed));
__u16 JobControlFlags __attribute__((packed));
__u8 FileNameLen __attribute__((packed));
char JobFileName[13] __attribute__((packed));
__u32 JobFileHandle __attribute__((packed));
__u32 ServerStation __attribute__((packed));
__u32 ServerTaskNumber __attribute__((packed));
__u32 ServerObjectID __attribute__((packed));
char JobTextDescription[50] __attribute__((packed));
char ClientRecordArea[152] __attribute__((packed));
};
struct queue_job {
struct queue_job
{
struct nw_queue_job_entry j;
__u8 file_handle[6];
};
@@ -285,20 +297,21 @@ struct queue_job {
#define EXPAND_TABS 0x4000
#define PRINT_BANNER 0x8000
struct print_job_record {
__u8 Version __attribute__ ((packed));
__u8 TabSize __attribute__ ((packed));
__u16 Copies __attribute__ ((packed));
__u16 CtrlFlags __attribute__ ((packed));
__u16 Lines __attribute__ ((packed));
__u16 Rows __attribute__ ((packed));
char FormName[16] __attribute__ ((packed));
__u8 Reserved[6] __attribute__ ((packed));
char BannerName[13] __attribute__ ((packed));
char FnameBanner[13] __attribute__ ((packed));
char FnameHeader[14] __attribute__ ((packed));
char Path[80] __attribute__ ((packed));
struct print_job_record
{
__u8 Version __attribute__((packed));
__u8 TabSize __attribute__((packed));
__u16 Copies __attribute__((packed));
__u16 CtrlFlags __attribute__((packed));
__u16 Lines __attribute__((packed));
__u16 Rows __attribute__((packed));
char FormName[16] __attribute__((packed));
__u8 Reserved[6] __attribute__((packed));
char BannerName[13] __attribute__((packed));
char FnameBanner[13] __attribute__((packed));
char FnameHeader[14] __attribute__((packed));
char Path[80] __attribute__((packed));
};
#endif /* _LINUX_NCP_H */
#endif /* _LINUX_NCP_H */

View File

@@ -20,23 +20,25 @@
* ioctl commands
*/
struct ncp_ioctl_request {
unsigned int function;
unsigned int size;
char *data;
struct ncp_ioctl_request
{
unsigned int function;
unsigned int size;
char *data;
};
struct ncp_fs_info {
int version;
struct ncp_fs_info
{
int version;
struct sockaddr_ipx addr;
uid_t mounted_uid;
int connection; /* Connection number the server assigned us */
int buffer_size; /* The negotiated buffer size, to be
uid_t mounted_uid;
int connection; /* Connection number the server assigned us */
int buffer_size; /* The negotiated buffer size, to be
used for read/write requests! */
int volume_number;
__u32 directory_id;
};
int volume_number;
__u32 directory_id;
};
#define NCP_IOC_NCPREQUEST _IOR('n', 1, struct ncp_ioctl_request)
#define NCP_IOC_GETMOUNTUID _IOW('n', 2, uid_t)
@@ -84,24 +86,24 @@ extern int ncp_current_malloced;
static inline void *
ncp_kmalloc(unsigned int size, int priority)
{
ncp_malloced += 1;
ncp_current_malloced += 1;
return kmalloc(size, priority);
ncp_malloced += 1;
ncp_current_malloced += 1;
return kmalloc(size, priority);
}
static inline void
ncp_kfree_s(void *obj, int size)
{
ncp_current_malloced -= 1;
kfree_s(obj, size);
ncp_current_malloced -= 1;
kfree_s(obj, size);
}
#else /* DEBUG_NCP_MALLOC */
#else /* DEBUG_NCP_MALLOC */
#define ncp_kmalloc(s,p) kmalloc(s,p)
#define ncp_kfree_s(o,s) kfree_s(o,s)
#endif /* DEBUG_NCP_MALLOC */
#endif /* DEBUG_NCP_MALLOC */
#if DEBUG_NCP > 0
#define DPRINTK(format, args...) printk(format , ## args)
@@ -125,25 +127,25 @@ extern struct inode_operations ncp_dir_inode_operations;
void ncp_free_inode_info(struct ncp_inode_info *i);
void ncp_free_all_inodes(struct ncp_server *server);
void ncp_init_root(struct ncp_server *server);
int ncp_conn_logged_in(struct ncp_server *server);
int ncp_stat_root(struct ncp_server *server);
int ncp_conn_logged_in(struct ncp_server *server);
int ncp_stat_root(struct ncp_server *server);
void ncp_init_dir_cache(void);
void ncp_invalid_dir_cache(struct inode *ino);
struct ncp_inode_info *ncp_find_inode(struct inode *inode);
ino_t ncp_info_ino(struct ncp_server *server, struct ncp_inode_info *info);
void ncp_invalidate_all_inodes(struct ncp_server *server);
void ncp_free_dir_cache(void);
int ncp_date_dos2unix(__u16 time, __u16 date);
void ncp_date_unix2dos(int unix_date, __u16 *time, __u16 *date);
int ncp_date_dos2unix(__u16 time, __u16 date);
void ncp_date_unix2dos(int unix_date, __u16 * time, __u16 * date);
/* linux/fs/ncpfs/ioctl.c */
int ncp_ioctl (struct inode * inode, struct file * filp,
unsigned int cmd, unsigned long arg);
int ncp_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
/* linux/fs/ncpfs/inode.c */
struct super_block *ncp_read_super(struct super_block *sb,
void *raw_data, int silent);
void *raw_data, int silent);
void ncp_invalidate_connection(struct ncp_server *server);
int ncp_conn_is_valid(struct ncp_server *server);
@@ -157,8 +159,8 @@ void ncp_lock_server(struct ncp_server *server);
void ncp_unlock_server(struct ncp_server *server);
/* linux/fs/ncpfs/mmap.c */
int ncp_mmap(struct inode * inode, struct file * file, struct vm_area_struct * vma);
int ncp_mmap(struct inode *inode, struct file *file, struct vm_area_struct *vma);
#endif /* __KERNEL__ */
#endif /* __KERNEL__ */
#endif /* _LINUX_NCP_FS_H */
#endif /* _LINUX_NCP_FS_H */

View File

@@ -12,22 +12,24 @@
#ifdef __KERNEL__
enum ncp_inode_state {
NCP_INODE_VALID = 19, /* Inode currently in use */
NCP_INODE_LOOKED_UP, /* directly before iget */
NCP_INODE_CACHED, /* in a path to an inode which is in use */
NCP_INODE_INVALID
enum ncp_inode_state
{
NCP_INODE_VALID = 19, /* Inode currently in use */
NCP_INODE_LOOKED_UP, /* directly before iget */
NCP_INODE_CACHED, /* in a path to an inode which is in use */
NCP_INODE_INVALID
};
/*
* ncp fs inode data (in memory only)
*/
struct ncp_inode_info {
enum ncp_inode_state state;
int nused; /* for directories:
number of references in memory */
struct ncp_inode_info *dir;
struct ncp_inode_info *next, *prev;
struct ncp_inode_info
{
enum ncp_inode_state state;
int nused; /* for directories:
number of references in memory */
struct ncp_inode_info *dir;
struct ncp_inode_info *next, *prev;
struct inode *inode;
struct nw_file_info finfo;
};

View File

@@ -15,11 +15,12 @@
#define NCP_DEFAULT_BUFSIZE 1024
struct ncp_server {
struct ncp_server
{
struct ncp_mount_data m; /* Nearly all of the mount data is of
interest for us later, so we store
it completely. */
struct ncp_mount_data m; /* Nearly all of the mount data is of
interest for us later, so we store
it completely. */
__u8 name_space[NCP_NUMBER_OF_VOLUMES];
@@ -30,32 +31,32 @@ struct ncp_server {
old one for checking purposes and
to reset it on unmounting. */
u8 sequence;
u8 task;
u16 connection; /* Remote connection number */
u8 sequence;
u8 task;
u16 connection; /* Remote connection number */
u8 completion; /* Status message from server */
u8 conn_status; /* Bit 4 = 1 ==> Server going down, no
u8 completion; /* Status message from server */
u8 conn_status; /* Bit 4 = 1 ==> Server going down, no
requests allowed anymore.
Bit 0 = 1 ==> Server is down. */
int buffer_size; /* Negotiated bufsize */
int buffer_size; /* Negotiated bufsize */
int reply_size; /* Size of last reply */
int reply_size; /* Size of last reply */
int packet_size;
int packet_size;
unsigned char *packet; /* Here we prepare requests and
receive replies */
int lock; /* To prevent mismatch in protocols. */
int lock; /* To prevent mismatch in protocols. */
struct wait_queue *wait;
int current_size; /* for packet preparation */
int has_subfunction;
int ncp_reply_size;
int current_size; /* for packet preparation */
int has_subfunction;
int ncp_reply_size;
struct ncp_inode_info root;
char root_path; /* '\0' */
struct ncp_inode_info root;
char root_path; /* '\0' */
};
static inline int
@@ -70,6 +71,6 @@ ncp_invalidate_conn(struct ncp_server *server)
server->conn_status |= 0x01;
}
#endif /* __KERNEL__ */
#endif /* __KERNEL__ */
#endif

View File

@@ -22,28 +22,29 @@
#define NCP_MOUNT_SOFT 0x0001
#define NCP_MOUNT_INTR 0x0002
struct ncp_mount_data {
struct ncp_mount_data
{
int version;
unsigned int ncp_fd; /* The socket to the ncp port */
unsigned int wdog_fd; /* Watchdog packets come here */
unsigned int message_fd; /* Message notifications come here */
uid_t mounted_uid; /* Who may umount() this filesystem? */
unsigned int message_fd; /* Message notifications come here */
uid_t mounted_uid; /* Who may umount() this filesystem? */
struct sockaddr_ipx serv_addr;
unsigned char server_name[NCP_BINDERY_NAME_LEN];
unsigned char mount_point[PATH_MAX+1];
unsigned char mounted_vol[NCP_VOLNAME_LEN+1];
unsigned char mount_point[PATH_MAX + 1];
unsigned char mounted_vol[NCP_VOLNAME_LEN + 1];
unsigned int time_out; /* How long should I wait after
sending a NCP request? */
unsigned int retry_count; /* And how often should I retry? */
unsigned int retry_count; /* And how often should I retry? */
unsigned int flags;
uid_t uid;
gid_t gid;
mode_t file_mode;
mode_t dir_mode;
uid_t uid;
gid_t gid;
mode_t file_mode;
mode_t dir_mode;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -25,12 +25,13 @@
#include "ncplib_kernel.h"
#include <linux/malloc.h>
static inline int min(int a, int b)
static inline int
min(int a, int b)
{
return a<b ? a : b;
return a < b ? a : b;
}
static int
static int
ncp_fsync(struct inode *inode, struct file *file)
{
return 0;
@@ -39,23 +40,22 @@ ncp_fsync(struct inode *inode, struct file *file)
int
ncp_make_open(struct inode *i, int right)
{
struct nw_file_info *finfo;
struct nw_file_info *finfo;
if (i == NULL)
if (i == NULL)
{
printk("ncp_make_open: got NULL inode\n");
return -EINVAL;
}
printk("ncp_make_open: got NULL inode\n");
return -EINVAL;
}
finfo = NCP_FINFO(i);
finfo = NCP_FINFO(i);
DPRINTK("ncp_make_open: dirent->opened = %d\n", finfo->opened);
DPRINTK("ncp_make_open: dirent->opened = %d\n", finfo->opened);
lock_super(i->i_sb);
if (finfo->opened == 0)
if (finfo->opened == 0)
{
finfo->access = -1;
/* tries max. rights */
/* tries max. rights */
if (ncp_open_create_file_or_subdir(NCP_SERVER(i),
NULL, NULL,
OC_MODE_OPEN, 0,
@@ -63,38 +63,36 @@ ncp_make_open(struct inode *i, int right)
finfo) == 0)
{
finfo->access = O_RDWR;
}
else if (ncp_open_create_file_or_subdir(NCP_SERVER(i),
NULL, NULL,
OC_MODE_OPEN, 0,
AR_READ,
finfo) == 0)
} else if (ncp_open_create_file_or_subdir(NCP_SERVER(i),
NULL, NULL,
OC_MODE_OPEN, 0,
AR_READ,
finfo) == 0)
{
finfo->access = O_RDONLY;
}
}
}
unlock_super(i->i_sb);
if ( ((right == O_RDONLY) && ( (finfo->access == O_RDONLY)
|| (finfo->access == O_RDWR)))
|| ((right == O_WRONLY) && ( (finfo->access == O_WRONLY)
|| (finfo->access == O_RDWR)))
|| ((right == O_RDWR) && (finfo->access == O_RDWR)))
return 0;
if (((right == O_RDONLY) && ((finfo->access == O_RDONLY)
|| (finfo->access == O_RDWR)))
|| ((right == O_WRONLY) && ((finfo->access == O_WRONLY)
|| (finfo->access == O_RDWR)))
|| ((right == O_RDWR) && (finfo->access == O_RDWR)))
return 0;
return -EACCES;
return -EACCES;
}
static int
static int
ncp_file_read(struct inode *inode, struct file *file, char *buf, int count)
{
int bufsize, already_read;
off_t pos;
int errno;
int errno;
DPRINTK("ncp_file_read: enter %s\n", NCP_ISTRUCT(inode)->entryName);
DPRINTK("ncp_file_read: enter %s\n", NCP_ISTRUCT(inode)->entryName);
if (inode == NULL)
{
DPRINTK("ncp_file_read: inode = NULL\n");
@@ -104,37 +102,32 @@ ncp_file_read(struct inode *inode, struct file *file, char *buf, int count)
{
return -EIO;
}
if (!S_ISREG(inode->i_mode))
{
DPRINTK("ncp_file_read: read from non-file, mode %07o\n",
inode->i_mode);
inode->i_mode);
return -EINVAL;
}
pos = file->f_pos;
if (pos + count > inode->i_size)
{
count = inode->i_size - pos;
}
if (count <= 0)
{
return 0;
}
if ((errno = ncp_make_open(inode, O_RDONLY)) != 0)
if ((errno = ncp_make_open(inode, O_RDONLY)) != 0)
{
return errno;
return errno;
}
bufsize = NCP_SERVER(inode)->buffer_size;
already_read = 0;
already_read = 0;
/* First read in as much as possible for each bufsize. */
while (already_read < count)
while (already_read < count)
{
int read_this_time;
int to_read = min(bufsize - (pos % bufsize),
@@ -143,41 +136,39 @@ ncp_file_read(struct inode *inode, struct file *file, char *buf, int count)
if (ncp_read(NCP_SERVER(inode), NCP_FINFO(inode)->file_handle,
pos, to_read, buf, &read_this_time) != 0)
{
return -EIO; /* This is not exact, i know.. */
return -EIO; /* This is not exact, i know.. */
}
pos += read_this_time;
buf += read_this_time;
already_read += read_this_time;
already_read += read_this_time;
if (read_this_time < to_read)
{
break;
break;
}
}
file->f_pos = pos;
file->f_pos = pos;
if (!IS_RDONLY(inode))
{
inode->i_atime = CURRENT_TIME;
}
inode->i_dirt = 1;
DPRINTK("ncp_file_read: exit %s\n", NCP_ISTRUCT(inode)->entryName);
DPRINTK("ncp_file_read: exit %s\n", NCP_ISTRUCT(inode)->entryName);
return already_read;
return already_read;
}
static int
static int
ncp_file_write(struct inode *inode, struct file *file, char *buf,
int count)
{
int bufsize, already_written;
off_t pos;
int errno;
off_t pos;
int errno;
if (inode == NULL)
{
DPRINTK("ncp_file_write: inode = NULL\n");
@@ -187,38 +178,33 @@ ncp_file_write(struct inode *inode, struct file *file, char *buf,
{
return -EIO;
}
if (!S_ISREG(inode->i_mode))
{
DPRINTK("ncp_file_write: write to non-file, mode %07o\n",
inode->i_mode);
inode->i_mode);
return -EINVAL;
}
DPRINTK("ncp_file_write: enter %s\n", NCP_ISTRUCT(inode)->entryName);
DPRINTK("ncp_file_write: enter %s\n", NCP_ISTRUCT(inode)->entryName);
if (count <= 0)
{
return 0;
}
if ((errno = ncp_make_open(inode, O_RDWR)) != 0)
if ((errno = ncp_make_open(inode, O_RDWR)) != 0)
{
return errno;
return errno;
}
pos = file->f_pos;
if (file->f_flags & O_APPEND)
{
pos = inode->i_size;
}
bufsize = NCP_SERVER(inode)->buffer_size;
already_written = 0;
already_written = 0;
while (already_written < count)
while (already_written < count)
{
int written_this_time;
int to_write = min(bufsize - (pos % bufsize),
@@ -228,8 +214,7 @@ ncp_file_write(struct inode *inode, struct file *file, char *buf,
pos, to_write, buf, &written_this_time) != 0)
{
return -EIO;
}
}
pos += written_this_time;
buf += written_this_time;
already_written += written_this_time;
@@ -245,18 +230,18 @@ ncp_file_write(struct inode *inode, struct file *file, char *buf,
file->f_pos = pos;
if (pos > inode->i_size)
if (pos > inode->i_size)
{
inode->i_size = pos;
inode->i_size = pos;
ncp_invalid_dir_cache(NCP_INOP(inode)->dir->inode);
}
DPRINTK("ncp_file_write: exit %s\n", NCP_ISTRUCT(inode)->entryName);
}
DPRINTK("ncp_file_write: exit %s\n", NCP_ISTRUCT(inode)->entryName);
return already_written;
}
static struct file_operations ncp_file_operations = {
static struct file_operations ncp_file_operations =
{
NULL, /* lseek - default */
ncp_file_read, /* read */
ncp_file_write, /* write */
@@ -264,12 +249,13 @@ static struct file_operations ncp_file_operations = {
NULL, /* select - default */
ncp_ioctl, /* ioctl */
ncp_mmap, /* mmap */
NULL, /* open */
NULL, /* release */
NULL, /* open */
NULL, /* release */
ncp_fsync, /* fsync */
};
struct inode_operations ncp_file_inode_operations = {
struct inode_operations ncp_file_inode_operations =
{
&ncp_file_operations, /* default file operations */
NULL, /* create */
NULL, /* lookup */

View File

@@ -37,8 +37,9 @@ static void ncp_put_super(struct super_block *);
static void ncp_statfs(struct super_block *sb, struct statfs *stat);
static int ncp_notify_change(struct inode *inode, struct iattr *attr);
static struct super_operations ncp_sops = {
ncp_read_inode, /* read inode */
static struct super_operations ncp_sops =
{
ncp_read_inode, /* read inode */
ncp_notify_change, /* notify change */
NULL, /* write inode */
ncp_put_inode, /* put inode */
@@ -55,13 +56,13 @@ static struct super_operations ncp_sops = {
static void
ncp_read_inode(struct inode *inode)
{
/* Our task should be extremely simple here. We only have to
look up the infomation somebody else (ncp_iget) put into
the inode tree. The address of this information is the
inode->i_ino. Just to make sure everything went well, we
check it's there. */
/* Our task should be extremely simple here. We only have to
look up the infomation somebody else (ncp_iget) put into
the inode tree. The address of this information is the
inode->i_ino. Just to make sure everything went well, we
check it's there. */
struct ncp_inode_info *inode_info = ncp_find_inode(inode);
struct ncp_inode_info *inode_info = ncp_find_inode(inode);
if (inode_info == NULL)
{
@@ -70,41 +71,38 @@ ncp_read_inode(struct inode *inode)
printk("ncp_read_inode: inode info not found\n");
return;
}
inode_info->state = NCP_INODE_VALID;
inode_info->state = NCP_INODE_VALID;
NCP_INOP(inode) = inode_info;
NCP_INOP(inode) = inode_info;
inode_info->inode = inode;
if (NCP_ISTRUCT(inode)->attributes & aDIR)
if (NCP_ISTRUCT(inode)->attributes & aDIR)
{
inode->i_mode = NCP_SERVER(inode)->m.dir_mode;
inode->i_mode = NCP_SERVER(inode)->m.dir_mode;
/* for directories dataStreamSize seems to be some
Object ID ??? */
inode->i_size = 512;
}
else
} else
{
inode->i_mode = NCP_SERVER(inode)->m.file_mode;
inode->i_mode = NCP_SERVER(inode)->m.file_mode;
inode->i_size = NCP_ISTRUCT(inode)->dataStreamSize;
}
DDPRINTK("ncp_read_inode: inode->i_mode = %u\n", inode->i_mode);
DDPRINTK("ncp_read_inode: inode->i_mode = %u\n", inode->i_mode);
inode->i_nlink = 1;
inode->i_uid = NCP_SERVER(inode)->m.uid;
inode->i_gid = NCP_SERVER(inode)->m.gid;
inode->i_blksize = 512;
inode->i_rdev = 0;
inode->i_nlink = 1;
inode->i_uid = NCP_SERVER(inode)->m.uid;
inode->i_gid = NCP_SERVER(inode)->m.gid;
inode->i_blksize = 512;
inode->i_rdev = 0;
if ((inode->i_blksize != 0) && (inode->i_size != 0))
if ((inode->i_blksize != 0) && (inode->i_size != 0))
{
inode->i_blocks =
(inode->i_size - 1) / inode->i_blksize + 1;
}
else
inode->i_blocks =
(inode->i_size - 1) / inode->i_blksize + 1;
} else
{
inode->i_blocks = 0;
inode->i_blocks = 0;
}
inode->i_mtime = ncp_date_dos2unix(NCP_ISTRUCT(inode)->modifyTime,
@@ -114,48 +112,44 @@ ncp_read_inode(struct inode *inode)
inode->i_atime = ncp_date_dos2unix(0,
NCP_ISTRUCT(inode)->lastAccessDate);
if (S_ISREG(inode->i_mode))
if (S_ISREG(inode->i_mode))
{
inode->i_op = &ncp_file_inode_operations;
}
else if (S_ISDIR(inode->i_mode))
inode->i_op = &ncp_file_inode_operations;
} else if (S_ISDIR(inode->i_mode))
{
inode->i_op = &ncp_dir_inode_operations;
}
else
inode->i_op = &ncp_dir_inode_operations;
} else
{
inode->i_op = NULL;
inode->i_op = NULL;
}
}
static void
ncp_put_inode(struct inode *inode)
{
struct nw_file_info *finfo = NCP_FINFO(inode);
struct nw_file_info *finfo = NCP_FINFO(inode);
struct super_block *sb = inode->i_sb;
lock_super(sb);
if (finfo->opened != 0)
if (finfo->opened != 0)
{
if (ncp_close_file(NCP_SERVER(inode), finfo->file_handle)!=0)
if (ncp_close_file(NCP_SERVER(inode), finfo->file_handle) != 0)
{
/* We can't do anything but complain. */
printk("ncp_put_inode: could not close\n");
}
}
/* We can't do anything but complain. */
printk("ncp_put_inode: could not close\n");
}
}
DDPRINTK("ncp_put_inode: put %s\n",
finfo->i.entryName);
finfo->i.entryName);
ncp_free_inode_info(NCP_INOP(inode));
ncp_free_inode_info(NCP_INOP(inode));
if (S_ISDIR(inode->i_mode))
if (S_ISDIR(inode->i_mode))
{
DDPRINTK("ncp_put_inode: put directory %ld\n",
DDPRINTK("ncp_put_inode: put directory %ld\n",
inode->i_ino);
ncp_invalid_dir_cache(inode);
}
ncp_invalid_dir_cache(inode);
}
clear_inode(inode);
unlock_super(sb);
}
@@ -164,7 +158,7 @@ struct super_block *
ncp_read_super(struct super_block *sb, void *raw_data, int silent)
{
struct ncp_mount_data *data = (struct ncp_mount_data *) raw_data;
struct ncp_server *server;
struct ncp_server *server;
struct file *ncp_filp;
struct file *wdog_filp;
dev_t dev = sb->s_dev;
@@ -176,17 +170,15 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent)
sb->s_dev = 0;
return NULL;
}
if (data->version != NCP_MOUNT_VERSION)
{
printk("ncp warning: mount version %s than kernel\n",
(data->version < NCP_MOUNT_VERSION) ?
"older" : "newer");
"older" : "newer");
sb->s_dev = 0;
return NULL;
}
if ( (data->ncp_fd >= NR_OPEN)
if ((data->ncp_fd >= NR_OPEN)
|| ((ncp_filp = current->files->fd[data->ncp_fd]) == NULL)
|| (!S_ISSOCK(ncp_filp->f_inode->i_mode)))
{
@@ -194,8 +186,7 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent)
sb->s_dev = 0;
return NULL;
}
if ( (data->wdog_fd >= NR_OPEN)
if ((data->wdog_fd >= NR_OPEN)
|| ((wdog_filp = current->files->fd[data->wdog_fd]) == NULL)
|| (!S_ISSOCK(wdog_filp->f_inode->i_mode)))
{
@@ -203,46 +194,44 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent)
sb->s_dev = 0;
return NULL;
}
/* We must malloc our own super-block info */
server = (struct ncp_server *) ncp_kmalloc(sizeof(struct ncp_server),
GFP_KERNEL);
/* We must malloc our own super-block info */
server = (struct ncp_server *)ncp_kmalloc(sizeof(struct ncp_server),
GFP_KERNEL);
if (server == NULL)
if (server == NULL)
{
printk("ncp_read_super: could not alloc ncp_server\n");
return NULL;
}
printk("ncp_read_super: could not alloc ncp_server\n");
return NULL;
}
ncp_filp->f_count += 1;
wdog_filp->f_count += 1;
lock_super(sb);
NCP_SBP(sb) = server;
sb->s_blocksize = 1024; /* Eh... Is this correct? */
NCP_SBP(sb) = server;
sb->s_blocksize = 1024; /* Eh... Is this correct? */
sb->s_blocksize_bits = 10;
sb->s_magic = NCP_SUPER_MAGIC;
sb->s_dev = dev;
sb->s_op = &ncp_sops;
server->ncp_filp = ncp_filp;
server->wdog_filp = wdog_filp;
server->lock = 0;
server->wait = NULL;
server->packet = NULL;
server->ncp_filp = ncp_filp;
server->wdog_filp = wdog_filp;
server->lock = 0;
server->wait = NULL;
server->packet = NULL;
server->buffer_size = 0;
server->conn_status = 0;
server->m = *data;
server->m = *data;
server->m.file_mode = (server->m.file_mode &
(S_IRWXU|S_IRWXG|S_IRWXO)) | S_IFREG;
server->m.dir_mode = (server->m.dir_mode &
(S_IRWXU|S_IRWXG|S_IRWXO)) | S_IFDIR;
(S_IRWXU | S_IRWXG | S_IRWXO)) | S_IFREG;
server->m.dir_mode = (server->m.dir_mode &
(S_IRWXU | S_IRWXG | S_IRWXO)) | S_IFDIR;
server->packet_size = NCP_PACKET_SIZE;
server->packet = ncp_kmalloc(NCP_PACKET_SIZE, GFP_KERNEL);
server->packet = ncp_kmalloc(NCP_PACKET_SIZE, GFP_KERNEL);
if (server->packet == NULL)
{
@@ -251,12 +240,11 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent)
unlock_super(sb);
goto fail;
}
ncp_init_root(server);
ncp_init_root(server);
/*
* Make the connection to the server
*/
/*
* Make the connection to the server
*/
if (ncp_catch_watchdog(server) != 0)
{
@@ -265,7 +253,6 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent)
unlock_super(sb);
goto fail;
}
ncp_lock_server(server);
error = ncp_connect(server);
ncp_unlock_server(server);
@@ -275,21 +262,19 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent)
{
sb->s_dev = 0;
printk("ncp_read_super: Failed connection, bailing out "
"(error = %d).\n", -error);
ncp_kfree_s(server->packet, server->packet_size);
"(error = %d).\n", -error);
ncp_kfree_s(server->packet, server->packet_size);
ncp_dont_catch_watchdog(server);
goto fail;
goto fail;
}
DPRINTK("ncp_read_super: NCP_SBP(sb) = %x\n", (int)NCP_SBP(sb));
DPRINTK("ncp_read_super: NCP_SBP(sb) = %x\n", (int) NCP_SBP(sb));
if (!(sb->s_mounted = iget(sb, ncp_info_ino(server, &(server->root)))))
{
sb->s_dev = 0;
printk("ncp_read_super: get root inode failed\n");
goto disconnect;
goto disconnect;
}
if (ncp_negotiate_buffersize(server, NCP_DEFAULT_BUFSIZE,
&(server->buffer_size)) != 0)
{
@@ -297,34 +282,33 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent)
printk("ncp_read_super: could not get bufsize\n");
goto disconnect;
}
DPRINTK("ncpfs: bufsize = %d\n", server->buffer_size);
MOD_INC_USE_COUNT;
MOD_INC_USE_COUNT;
return sb;
disconnect:
disconnect:
ncp_lock_server(server);
ncp_disconnect(server);
ncp_unlock_server(server);
ncp_kfree_s(server->packet, server->packet_size);
ncp_dont_catch_watchdog(server);
fail:
fail:
ncp_filp->f_count -= 1;
wdog_filp->f_count -= 1;
ncp_kfree_s(NCP_SBP(sb), sizeof(struct ncp_server));
return NULL;
ncp_kfree_s(NCP_SBP(sb), sizeof(struct ncp_server));
return NULL;
}
static void
ncp_put_super(struct super_block *sb)
{
struct ncp_server *server = NCP_SBP(sb);
struct ncp_server *server = NCP_SBP(sb);
lock_super(sb);
ncp_lock_server(server);
ncp_disconnect(server);
ncp_disconnect(server);
ncp_unlock_server(server);
close_fp(server->ncp_filp);
@@ -332,29 +316,29 @@ ncp_put_super(struct super_block *sb)
ncp_dont_catch_watchdog(server);
close_fp(server->wdog_filp);
ncp_free_all_inodes(server);
ncp_free_all_inodes(server);
ncp_kfree_s(server->packet, server->packet_size);
ncp_kfree_s(server->packet, server->packet_size);
sb->s_dev = 0;
ncp_kfree_s(NCP_SBP(sb), sizeof(struct ncp_server));
ncp_kfree_s(NCP_SBP(sb), sizeof(struct ncp_server));
NCP_SBP(sb) = NULL;
unlock_super(sb);
MOD_DEC_USE_COUNT;
MOD_DEC_USE_COUNT;
}
static void
static void
ncp_statfs(struct super_block *sb, struct statfs *stat)
{
struct statfs tmp;
/* We cannot say how much disk space is left on a mounted
NetWare Server, because free space is distributed over
volumes, and the current user might have disk quotas. So
free space is not that simple to determine. Our decision
here is to err conservatively. */
NetWare Server, because free space is distributed over
volumes, and the current user might have disk quotas. So
free space is not that simple to determine. Our decision
here is to err conservatively. */
tmp.f_type = NCP_SUPER_MAGIC;
tmp.f_bsize = 512;
@@ -378,17 +362,16 @@ ncp_notify_change(struct inode *inode, struct iattr *attr)
{
return -EIO;
}
if ((result = inode_change_ok(inode, attr)) < 0)
return result;
if (((attr->ia_valid & ATTR_UID) &&
if (((attr->ia_valid & ATTR_UID) &&
(attr->ia_uid != NCP_SERVER(inode)->m.uid)))
return -EPERM;
if (((attr->ia_valid & ATTR_GID) &&
if (((attr->ia_valid & ATTR_GID) &&
(attr->ia_uid != NCP_SERVER(inode)->m.gid)))
return -EPERM;
return -EPERM;
if (((attr->ia_valid & ATTR_MODE) &&
(attr->ia_mode &
@@ -400,18 +383,16 @@ ncp_notify_change(struct inode *inode, struct iattr *attr)
if ((attr->ia_valid & ATTR_CTIME) != 0)
{
info_mask |= (DM_CREATE_TIME|DM_CREATE_DATE);
info_mask |= (DM_CREATE_TIME | DM_CREATE_DATE);
ncp_date_unix2dos(attr->ia_ctime,
&(info.creationTime), &(info.creationDate));
}
if ((attr->ia_valid & ATTR_MTIME) != 0)
{
info_mask |= (DM_MODIFY_TIME|DM_MODIFY_DATE);
info_mask |= (DM_MODIFY_TIME | DM_MODIFY_DATE);
ncp_date_unix2dos(attr->ia_mtime,
&(info.modifyTime), &(info.modifyDate));
}
if ((attr->ia_valid & ATTR_ATIME) != 0)
{
__u16 dummy;
@@ -419,7 +400,6 @@ ncp_notify_change(struct inode *inode, struct iattr *attr)
ncp_date_unix2dos(attr->ia_ctime,
&(dummy), &(info.lastAccessDate));
}
if (info_mask != 0)
{
if ((result =
@@ -430,19 +410,18 @@ ncp_notify_change(struct inode *inode, struct iattr *attr)
{
result = -EACCES;
if (info_mask == (DM_CREATE_TIME|DM_CREATE_DATE))
if (info_mask == (DM_CREATE_TIME | DM_CREATE_DATE))
{
/* NetWare seems not to allow this. I
do not know why. So, just tell the
user everything went fine. This is
a terrible hack, but I do not know
how to do this correctly. */
do not know why. So, just tell the
user everything went fine. This is
a terrible hack, but I do not know
how to do this correctly. */
result = 0;
}
}
}
if ((attr->ia_valid & ATTR_SIZE) != 0)
if ((attr->ia_valid & ATTR_SIZE) != 0)
{
int written;
@@ -453,7 +432,6 @@ ncp_notify_change(struct inode *inode, struct iattr *attr)
{
return -EACCES;
}
ncp_write(NCP_SERVER(inode), NCP_FINFO(inode)->file_handle,
attr->ia_size, 0, "", &written);
@@ -465,12 +443,11 @@ ncp_notify_change(struct inode *inode, struct iattr *attr)
result = 0;
}
ncp_invalid_dir_cache(NCP_INOP(inode)->dir->inode);
ncp_invalid_dir_cache(NCP_INOP(inode)->dir->inode);
return result;
}
#ifdef DEBUG_NCP_MALLOC
int ncp_malloced;
int ncp_current_malloced;
@@ -480,35 +457,36 @@ int ncp_current_malloced;
char kernel_version[] = UTS_RELEASE;
static struct file_system_type ncp_fs_type = {
ncp_read_super, "ncpfs", 0, NULL
};
static struct file_system_type ncp_fs_type =
{
ncp_read_super, "ncpfs", 0, NULL
};
int
init_module( void)
init_module(void)
{
DPRINTK("ncpfs: init_module called\n");
DPRINTK("ncpfs: init_module called\n");
#ifdef DEBUG_NCP_MALLOC
ncp_malloced = 0;
ncp_current_malloced = 0;
ncp_malloced = 0;
ncp_current_malloced = 0;
#endif
ncp_init_dir_cache();
register_filesystem(&ncp_fs_type);
ncp_init_dir_cache();
register_filesystem(&ncp_fs_type);
printk("ncpfs version %s loaded\n", NCPFS_VERSION);
return 0;
return 0;
}
void
cleanup_module(void)
{
DPRINTK("ncpfs: cleanup_module called\n");
ncp_free_dir_cache();
unregister_filesystem(&ncp_fs_type);
DPRINTK("ncpfs: cleanup_module called\n");
ncp_free_dir_cache();
unregister_filesystem(&ncp_fs_type);
#ifdef DEBUG_NCP_MALLOC
printk("ncp_malloced: %d\n", ncp_malloced);
printk("ncp_current_malloced: %d\n", ncp_current_malloced);
printk("ncp_malloced: %d\n", ncp_malloced);
printk("ncp_current_malloced: %d\n", ncp_current_malloced);
#endif
}

View File

@@ -21,8 +21,8 @@
#include <linux/ncp.h>
int
ncp_ioctl (struct inode * inode, struct file * filp,
unsigned int cmd, unsigned long arg)
ncp_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
int result;
struct ncp_ioctl_request request;
@@ -34,56 +34,54 @@ ncp_ioctl (struct inode * inode, struct file * filp,
* Take this out in 2.1.0 development series.
* <mec@duracef.shout.net> 12 Mar 1996
*/
switch(cmd) {
case _IOR('n', 1, unsigned char *):
cmd = NCP_IOC_NCPREQUEST;
break;
switch (cmd)
{
case _IOR('n', 1, unsigned char *):
cmd = NCP_IOC_NCPREQUEST;
break;
case _IOR('u', 1, uid_t):
cmd = NCP_IOC_GETMOUNTUID;
break;
cmd = NCP_IOC_GETMOUNTUID;
break;
case _IO('l', 1):
cmd = NCP_IOC_CONN_LOGGED_IN;
break;
case _IOWR('i', 1, unsigned char *):
cmd = NCP_IOC_GET_FS_INFO;
break;
cmd = NCP_IOC_CONN_LOGGED_IN;
break;
case _IOWR('i', 1, unsigned char *):
cmd = NCP_IOC_GET_FS_INFO;
break;
}
switch(cmd) {
switch (cmd)
{
case NCP_IOC_NCPREQUEST:
if ( (permission(inode, MAY_WRITE) != 0)
if ((permission(inode, MAY_WRITE) != 0)
&& (current->uid != server->m.mounted_uid))
{
return -EACCES;
}
if ((result = verify_area(VERIFY_READ, (char *)arg,
if ((result = verify_area(VERIFY_READ, (char *) arg,
sizeof(request))) != 0)
{
return result;
}
memcpy_fromfs(&request, (struct ncp_ioctl_request *)arg,
memcpy_fromfs(&request, (struct ncp_ioctl_request *) arg,
sizeof(request));
if ( (request.function > 255)
if ((request.function > 255)
|| (request.size >
NCP_PACKET_SIZE - sizeof(struct ncp_request_header)))
{
return -EINVAL;
}
if ((result = verify_area(VERIFY_WRITE, (char *)request.data,
if ((result = verify_area(VERIFY_WRITE, (char *) request.data,
NCP_PACKET_SIZE)) != 0)
{
return result;
}
ncp_lock_server(server);
/* FIXME: We hack around in the server's structures
here to be able to use ncp_request */
here to be able to use ncp_request */
server->has_subfunction = 0;
server->current_size = request.size;
@@ -101,29 +99,26 @@ ncp_ioctl (struct inode * inode, struct file * filp,
case NCP_IOC_CONN_LOGGED_IN:
if ( (permission(inode, MAY_WRITE) != 0)
if ((permission(inode, MAY_WRITE) != 0)
&& (current->uid != server->m.mounted_uid))
{
return -EACCES;
}
return ncp_conn_logged_in(server);
case NCP_IOC_GET_FS_INFO:
if ( (permission(inode, MAY_WRITE) != 0)
if ((permission(inode, MAY_WRITE) != 0)
&& (current->uid != server->m.mounted_uid))
{
return -EACCES;
}
if ((result = verify_area(VERIFY_WRITE, (char *)arg,
if ((result = verify_area(VERIFY_WRITE, (char *) arg,
sizeof(info))) != 0)
{
return result;
}
memcpy_fromfs(&info, (struct ncp_fs_info *)arg,
memcpy_fromfs(&info, (struct ncp_fs_info *) arg,
sizeof(info));
if (info.version != NCP_GET_FS_INFO_VERSION)
@@ -131,36 +126,34 @@ ncp_ioctl (struct inode * inode, struct file * filp,
DPRINTK("info.version invalid: %d\n", info.version);
return -EINVAL;
}
info.addr = server->m.serv_addr;
info.addr = server->m.serv_addr;
info.mounted_uid = server->m.mounted_uid;
info.connection = server->connection;
info.connection = server->connection;
info.buffer_size = server->buffer_size;
info.volume_number = NCP_ISTRUCT(inode)->volNumber;
info.directory_id = NCP_ISTRUCT(inode)->DosDirNum;
info.directory_id = NCP_ISTRUCT(inode)->DosDirNum;
memcpy_tofs((struct ncp_fs_info *)arg, &info, sizeof(info));
return 0;
memcpy_tofs((struct ncp_fs_info *) arg, &info, sizeof(info));
return 0;
case NCP_IOC_GETMOUNTUID:
case NCP_IOC_GETMOUNTUID:
if ( (permission(inode, MAY_READ) != 0)
if ((permission(inode, MAY_READ) != 0)
&& (current->uid != server->m.mounted_uid))
{
return -EACCES;
}
if ((result = verify_area(VERIFY_WRITE, (uid_t*) arg,
sizeof(uid_t))) != 0)
if ((result = verify_area(VERIFY_WRITE, (uid_t *) arg,
sizeof(uid_t))) != 0)
{
return result;
}
put_fs_word(server->m.mounted_uid, (uid_t*) arg);
return 0;
return result;
}
put_fs_word(server->m.mounted_uid, (uid_t *) arg);
return 0;
default:
return -EINVAL;
}
return -EINVAL;
}

View File

@@ -27,19 +27,20 @@
#include <asm/segment.h>
#include <asm/system.h>
static inline int min(int a, int b)
static inline int
min(int a, int b)
{
return a<b ? a : b;
return a < b ? a : b;
}
/*
* Fill in the supplied page for mmap
*/
static unsigned long
ncp_file_mmap_nopage(struct vm_area_struct * area,
static unsigned long
ncp_file_mmap_nopage(struct vm_area_struct *area,
unsigned long address, unsigned long page, int no_share)
{
struct inode * inode = area->vm_inode;
struct inode *inode = area->vm_inode;
unsigned int clear;
unsigned long tmp;
int bufsize;
@@ -54,19 +55,17 @@ ncp_file_mmap_nopage(struct vm_area_struct * area,
{
clear = address + PAGE_SIZE - area->vm_end;
}
/* what we can read in one go */
/* what we can read in one go */
bufsize = NCP_SERVER(inode)->buffer_size;
fs = get_fs();
set_fs(get_ds());
if (ncp_make_open(inode, O_RDONLY) < 0)
if (ncp_make_open(inode, O_RDONLY) < 0)
{
clear = PAGE_SIZE;
} else
{
clear = PAGE_SIZE;
}
else
{
int already_read = 0;
int count = PAGE_SIZE - clear;
int to_read;
@@ -78,8 +77,7 @@ ncp_file_mmap_nopage(struct vm_area_struct * area,
if ((pos % bufsize) != 0)
{
to_read = bufsize - (pos % bufsize);
}
else
} else
{
to_read = bufsize;
}
@@ -89,12 +87,11 @@ ncp_file_mmap_nopage(struct vm_area_struct * area,
if (ncp_read(NCP_SERVER(inode),
NCP_FINFO(inode)->file_handle,
pos, to_read,
(char *)(page + already_read),
(char *) (page + already_read),
&read_this_time) != 0)
{
read_this_time = 0;
read_this_time = 0;
}
pos += read_this_time;
already_read += read_this_time;
@@ -104,18 +101,20 @@ ncp_file_mmap_nopage(struct vm_area_struct * area,
}
}
}
}
set_fs(fs);
tmp = page + PAGE_SIZE;
while (clear--) {
*(char *)--tmp = 0;
while (clear--)
{
*(char *) --tmp = 0;
}
return page;
}
struct vm_operations_struct ncp_file_mmap = {
struct vm_operations_struct ncp_file_mmap =
{
NULL, /* open */
NULL, /* close */
NULL, /* unmap */
@@ -131,25 +130,24 @@ struct vm_operations_struct ncp_file_mmap = {
/* This is used for a general mmap of a ncp file */
int
ncp_mmap(struct inode * inode, struct file * file, struct vm_area_struct * vma)
ncp_mmap(struct inode *inode, struct file *file, struct vm_area_struct *vma)
{
DPRINTK("ncp_mmap: called\n");
DPRINTK("ncp_mmap: called\n");
if (!ncp_conn_valid(NCP_SERVER(inode)))
{
return -EIO;
}
/* only PAGE_COW or read-only supported now */
if (vma->vm_flags & VM_SHARED)
/* only PAGE_COW or read-only supported now */
if (vma->vm_flags & VM_SHARED)
return -EINVAL;
if (!inode->i_sb || !S_ISREG(inode->i_mode))
return -EACCES;
if (!IS_RDONLY(inode)) {
if (!IS_RDONLY(inode))
{
inode->i_atime = CURRENT_TIME;
inode->i_dirt = 1;
}
vma->vm_inode = inode;
inode->i_count++;
vma->vm_ops = &ncp_file_mmap;

View File

@@ -1,3 +1,4 @@
#include <linux/config.h>
#ifdef MODULE
#include <linux/module.h>
@@ -6,13 +7,14 @@
#include "ncplib_kernel.h"
typedef __u8 byte;
typedef __u8 byte;
typedef __u16 word;
typedef __u32 dword;
static inline int min(int a, int b)
static inline int
min(int a, int b)
{
return a<b ? a : b;
return a < b ? a : b;
}
static void
@@ -28,7 +30,7 @@ static void
ncp_add_byte(struct ncp_server *server, byte x)
{
assert_server_locked(server);
*(byte *)(&(server->packet[server->current_size])) = x;
*(byte *) (&(server->packet[server->current_size])) = x;
server->current_size += 1;
return;
}
@@ -37,7 +39,7 @@ static void
ncp_add_word(struct ncp_server *server, word x)
{
assert_server_locked(server);
*(word *)(&(server->packet[server->current_size])) = x;
*(word *) (&(server->packet[server->current_size])) = x;
server->current_size += 2;
return;
}
@@ -46,7 +48,7 @@ static void
ncp_add_dword(struct ncp_server *server, dword x)
{
assert_server_locked(server);
*(dword *)(&(server->packet[server->current_size])) = x;
*(dword *) (&(server->packet[server->current_size])) = x;
server->current_size += 4;
return;
}
@@ -97,7 +99,7 @@ static void
ncp_init_request_s(struct ncp_server *server, int subfunction)
{
ncp_init_request(server);
ncp_add_word(server, 0); /* preliminary size */
ncp_add_word(server, 0); /* preliminary size */
ncp_add_byte(server, subfunction);
@@ -113,19 +115,19 @@ ncp_reply_data(struct ncp_server *server, int offset)
static byte
ncp_reply_byte(struct ncp_server *server, int offset)
{
return *(byte *)(ncp_reply_data(server, offset));
return *(byte *) (ncp_reply_data(server, offset));
}
static word
ncp_reply_word(struct ncp_server *server, int offset)
{
return *(word *)(ncp_reply_data(server, offset));
return *(word *) (ncp_reply_data(server, offset));
}
static dword
ncp_reply_dword(struct ncp_server *server, int offset)
{
return *(dword *)(ncp_reply_data(server, offset));
return *(dword *) (ncp_reply_data(server, offset));
}
int
@@ -136,14 +138,13 @@ ncp_negotiate_buffersize(struct ncp_server *server,
ncp_init_request(server);
ncp_add_word(server, htons(size));
if ((result = ncp_request(server, 33)) != 0)
{
ncp_unlock_server(server);
return result;
}
*target =min(ntohs(ncp_reply_word(server, 0)), size);
*target = min(ntohs(ncp_reply_word(server, 0)), size);
ncp_unlock_server(server);
return 0;
@@ -164,9 +165,8 @@ ncp_get_volume_info_with_number(struct ncp_server *server, int n,
ncp_unlock_server(server);
return result;
}
target->total_blocks = ncp_reply_dword(server, 0);
target->free_blocks = ncp_reply_dword(server, 4);
target->free_blocks = ncp_reply_dword(server, 4);
target->purgeable_blocks = ncp_reply_dword(server, 8);
target->not_yet_purgeable_blocks = ncp_reply_dword(server, 12);
target->total_dir_entries = ncp_reply_dword(server, 16);
@@ -182,7 +182,6 @@ ncp_get_volume_info_with_number(struct ncp_server *server, int n,
ncp_unlock_server(server);
return -EIO;
}
memcpy(&(target->volume_name), ncp_reply_data(server, 30), len);
ncp_unlock_server(server);
return 0;
@@ -202,7 +201,6 @@ ncp_close_file(struct ncp_server *server, const char *file_id)
ncp_unlock_server(server);
return result;
}
ncp_unlock_server(server);
return 0;
}
@@ -217,18 +215,16 @@ ncp_add_handle_path(struct ncp_server *server,
ncp_add_dword(server, dir_base);
if (have_dir_base != 0)
{
ncp_add_byte(server, 1); /* dir_base */
}
else
ncp_add_byte(server, 1); /* dir_base */
} else
{
ncp_add_byte(server, 0xff); /* no handle */
ncp_add_byte(server, 0xff); /* no handle */
}
if (path != NULL)
{
ncp_add_byte(server, 1); /* 1 component */
ncp_add_byte(server, 1); /* 1 component */
ncp_add_pstring(server, path);
}
else
} else
{
ncp_add_byte(server, 0);
}
@@ -243,7 +239,7 @@ ncp_extract_file_info(void *structure, struct nw_info_struct *target)
memcpy(target, structure, info_struct_size);
name_len = structure + info_struct_size;
target->nameLen = *name_len;
strncpy(target->entryName, name_len+1, *name_len);
strncpy(target->entryName, name_len + 1, *name_len);
target->entryName[*name_len] = '\0';
return;
}
@@ -251,7 +247,7 @@ ncp_extract_file_info(void *structure, struct nw_info_struct *target)
int
ncp_obtain_info(struct ncp_server *server,
__u8 vol_num, __u32 dir_base,
char *path, /* At most 1 component */
char *path, /* At most 1 component */
struct nw_info_struct *target)
{
int result;
@@ -260,12 +256,11 @@ ncp_obtain_info(struct ncp_server *server,
{
return -EINVAL;
}
ncp_init_request(server);
ncp_add_byte(server, 6); /* subfunction */
ncp_add_byte(server, 6); /* subfunction */
ncp_add_byte(server, server->name_space[vol_num]);
ncp_add_byte(server, server->name_space[vol_num]);
ncp_add_word(server, 0xff); /* get all */
ncp_add_word(server, 0xff); /* get all */
ncp_add_dword(server, RIM_ALL);
ncp_add_handle_path(server, vol_num, dir_base, 1, path);
@@ -274,7 +269,6 @@ ncp_obtain_info(struct ncp_server *server,
ncp_unlock_server(server);
return result;
}
ncp_extract_file_info(ncp_reply_data(server, 0), target);
ncp_unlock_server(server);
return 0;
@@ -288,7 +282,7 @@ ncp_has_os2_namespace(struct ncp_server *server, __u8 volume)
__u16 no_namespaces;
ncp_init_request(server);
ncp_add_byte(server, 24); /* Subfunction: Get Name Spaces Loaded */
ncp_add_byte(server, 24); /* Subfunction: Get Name Spaces Loaded */
ncp_add_word(server, 0);
ncp_add_byte(server, volume);
@@ -297,13 +291,12 @@ ncp_has_os2_namespace(struct ncp_server *server, __u8 volume)
ncp_unlock_server(server);
return 0;
}
no_namespaces = ncp_reply_word(server, 0);
namespace = ncp_reply_data(server, 2);
while (no_namespaces > 0)
{
DPRINTK("get_namespaces: found %d on %d\n", *namespace,volume);
DPRINTK("get_namespaces: found %d on %d\n", *namespace, volume);
if (*namespace == 4)
{
@@ -329,16 +322,16 @@ ncp_lookup_volume(struct ncp_server *server,
DPRINTK("ncp_lookup_volume: looking up vol %s\n", volname);
ncp_init_request(server);
ncp_add_byte(server, 22); /* Subfunction: Generate dir handle */
ncp_add_byte(server, 0); /* DOS namespace */
ncp_add_byte(server, 0); /* reserved */
ncp_add_byte(server, 0); /* reserved */
ncp_add_byte(server, 0); /* reserved */
ncp_add_byte(server, 22); /* Subfunction: Generate dir handle */
ncp_add_byte(server, 0); /* DOS namespace */
ncp_add_byte(server, 0); /* reserved */
ncp_add_byte(server, 0); /* reserved */
ncp_add_byte(server, 0); /* reserved */
ncp_add_byte(server, 0); /* faked volume number */
ncp_add_dword(server, 0); /* faked dir_base */
ncp_add_byte(server, 0xff); /* Don't have a dir_base */
ncp_add_byte(server, 1); /* 1 path component */
ncp_add_byte(server, 0); /* faked volume number */
ncp_add_dword(server, 0); /* faked dir_base */
ncp_add_byte(server, 0xff); /* Don't have a dir_base */
ncp_add_byte(server, 1); /* 1 path component */
ncp_add_pstring(server, volname);
if ((result = ncp_request(server, 87)) != 0)
@@ -346,13 +339,12 @@ ncp_lookup_volume(struct ncp_server *server,
ncp_unlock_server(server);
return result;
}
memset(target, 0, sizeof(*target));
target->DosDirNum = target->dirEntNum = ncp_reply_dword(server, 4);
target->volNumber = volnum = ncp_reply_byte(server, 8);
ncp_unlock_server(server);
server->name_space[volnum] = ncp_has_os2_namespace(server,volnum)?4:0;
server->name_space[volnum] = ncp_has_os2_namespace(server, volnum) ? 4 : 0;
DPRINTK("lookup_vol: namespace[%d] = %d\n",
volnum, server->name_space[volnum]);
@@ -372,10 +364,10 @@ ncp_modify_file_or_subdir_dos_info(struct ncp_server *server,
int result;
ncp_init_request(server);
ncp_add_byte(server, 7); /* subfunction */
ncp_add_byte(server, 7); /* subfunction */
ncp_add_byte(server, server->name_space[file->volNumber]);
ncp_add_byte(server, 0); /* reserved */
ncp_add_word(server, 0x8006); /* search attribs: all */
ncp_add_byte(server, 0); /* reserved */
ncp_add_word(server, 0x8006); /* search attribs: all */
ncp_add_dword(server, info_mask);
ncp_add_mem(server, info, sizeof(*info));
@@ -387,7 +379,6 @@ ncp_modify_file_or_subdir_dos_info(struct ncp_server *server,
ncp_unlock_server(server);
return result;
}
ncp_unlock_server(server);
return 0;
}
@@ -399,30 +390,29 @@ ncp_del_file_or_subdir(struct ncp_server *server,
int result;
ncp_init_request(server);
ncp_add_byte(server, 8); /* subfunction */
ncp_add_byte(server, 8); /* subfunction */
ncp_add_byte(server, server->name_space[dir->volNumber]);
ncp_add_byte(server, 0); /* reserved */
ncp_add_word(server, 0x8006); /* search attribs: all */
ncp_add_byte(server, 0); /* reserved */
ncp_add_word(server, 0x8006); /* search attribs: all */
ncp_add_handle_path(server, dir->volNumber,
dir->dirEntNum, 1, name);
if ((result = ncp_request(server, 87)) != 0)
{
ncp_unlock_server(server);
return result;
}
ncp_unlock_server(server);
return 0;
}
static inline void
ConvertToNWfromDWORD ( __u32 sfd , __u8 ret[6] )
ConvertToNWfromDWORD(__u32 sfd, __u8 ret[6])
{
__u16 *dest = (__u16 *) ret;
memcpy(&(dest[1]), &sfd, 4);
dest[0] = dest[1] + 1;
return;
__u16 *dest = (__u16 *) ret;
memcpy(&(dest[1]), &sfd, 4);
dest[0] = dest[1] + 1;
return;
}
/* If both dir and name are NULL, then in target there's already a
@@ -441,11 +431,10 @@ ncp_open_create_file_or_subdir(struct ncp_server *server,
if ((create_attributes & aDIR) != 0)
{
search_attribs |= 0x8000;
}
search_attribs |= 0x8000;
}
ncp_init_request(server);
ncp_add_byte(server, 1); /* subfunction */
ncp_add_byte(server, 1); /* subfunction */
ncp_add_byte(server, server->name_space[volume]);
ncp_add_byte(server, open_create_mode);
ncp_add_word(server, search_attribs);
@@ -458,19 +447,17 @@ ncp_open_create_file_or_subdir(struct ncp_server *server,
if (dir != NULL)
{
ncp_add_handle_path(server, volume, dir->dirEntNum, 1, name);
}
else
} else
{
ncp_add_handle_path(server, volume, target->i.dirEntNum,
1, NULL);
}
}
if ((result = ncp_request(server, 87)) != 0)
{
ncp_unlock_server(server);
return result;
}
target->opened = 1;
target->server_file_handle = ncp_reply_dword(server, 0);
target->open_create_action = ncp_reply_byte(server, 4);
@@ -480,13 +467,12 @@ ncp_open_create_file_or_subdir(struct ncp_server *server,
/* in target there's a new finfo to fill */
ncp_extract_file_info(ncp_reply_data(server, 5), &(target->i));
}
ConvertToNWfromDWORD(target->server_file_handle, target->file_handle);
ncp_unlock_server(server);
return 0;
}
int
ncp_initialize_search(struct ncp_server *server,
@@ -496,23 +482,22 @@ ncp_initialize_search(struct ncp_server *server,
int result;
ncp_init_request(server);
ncp_add_byte(server, 2); /* subfunction */
ncp_add_byte(server, 2); /* subfunction */
ncp_add_byte(server, server->name_space[dir->volNumber]);
ncp_add_byte(server, 0); /* reserved */
ncp_add_byte(server, 0); /* reserved */
ncp_add_handle_path(server, dir->volNumber, dir->dirEntNum, 1, NULL);
if ((result = ncp_request(server, 87)) != 0)
{
ncp_unlock_server(server);
return result;
}
memcpy(target, ncp_reply_data(server, 0), sizeof(*target));
ncp_unlock_server(server);
return 0;
}
/* Search for everything */
int
ncp_search_for_file_or_subdir(struct ncp_server *server,
@@ -522,22 +507,21 @@ ncp_search_for_file_or_subdir(struct ncp_server *server,
int result;
ncp_init_request(server);
ncp_add_byte(server, 3); /* subfunction */
ncp_add_byte(server, 3); /* subfunction */
ncp_add_byte(server, server->name_space[seq->volNumber]);
ncp_add_byte(server, 0); /* data stream (???) */
ncp_add_word(server, 0xffff); /* Search attribs */
ncp_add_dword(server, RIM_ALL); /* return info mask */
ncp_add_byte(server, 0); /* data stream (???) */
ncp_add_word(server, 0xffff); /* Search attribs */
ncp_add_dword(server, RIM_ALL); /* return info mask */
ncp_add_mem(server, seq, 9);
ncp_add_byte(server, 2); /* 2 byte pattern */
ncp_add_byte(server, 0xff); /* following is a wildcard */
ncp_add_byte(server, 2); /* 2 byte pattern */
ncp_add_byte(server, 0xff); /* following is a wildcard */
ncp_add_byte(server, '*');
if ((result = ncp_request(server, 87)) != 0)
{
ncp_unlock_server(server);
return result;
}
memcpy(seq, ncp_reply_data(server, 0), sizeof(*seq));
ncp_extract_file_info(ncp_reply_data(server, 10), target);
@@ -552,27 +536,27 @@ ncp_ren_or_mov_file_or_subdir(struct ncp_server *server,
{
int result;
if ( (old_dir == NULL) || (old_name == NULL)
if ((old_dir == NULL) || (old_name == NULL)
|| (new_dir == NULL) || (new_name == NULL))
return -EINVAL;
ncp_init_request(server);
ncp_add_byte(server, 4); /* subfunction */
ncp_add_byte(server, 4); /* subfunction */
ncp_add_byte(server, server->name_space[old_dir->volNumber]);
ncp_add_byte(server, 1); /* rename flag */
ncp_add_word(server, 0x8006); /* search attributes */
ncp_add_byte(server, 1); /* rename flag */
ncp_add_word(server, 0x8006); /* search attributes */
/* source Handle Path */
ncp_add_byte(server, old_dir->volNumber);
ncp_add_dword(server, old_dir->dirEntNum);
ncp_add_byte(server, 1);
ncp_add_byte(server, 1); /* 1 source component */
ncp_add_byte(server, 1); /* 1 source component */
/* dest Handle Path */
ncp_add_byte(server, new_dir->volNumber);
ncp_add_dword(server, new_dir->dirEntNum);
ncp_add_byte(server, 1);
ncp_add_byte(server, 1); /* 1 destination component */
ncp_add_byte(server, 1); /* 1 destination component */
/* source path string */
ncp_add_pstring(server, old_name);
@@ -583,7 +567,7 @@ ncp_ren_or_mov_file_or_subdir(struct ncp_server *server,
ncp_unlock_server(server);
return result;
}
/* We have to transfer to/from user space */
int
@@ -604,10 +588,9 @@ ncp_read(struct ncp_server *server, const char *file_id,
ncp_unlock_server(server);
return result;
}
*bytes_read = ntohs(ncp_reply_word(server, 0));
memcpy_tofs(target, ncp_reply_data(server, 2+(offset&1)), *bytes_read);
memcpy_tofs(target, ncp_reply_data(server, 2 + (offset & 1)), *bytes_read);
ncp_unlock_server(server);
return 0;
@@ -632,10 +615,8 @@ ncp_write(struct ncp_server *server, const char *file_id,
ncp_unlock_server(server);
return result;
}
*bytes_written = to_write;
ncp_unlock_server(server);
return 0;
}

View File

@@ -1,3 +1,4 @@
#ifndef _NCPLIB_H
#define _NCPLIB_H
@@ -16,147 +17,147 @@
#include <linux/ncp.h>
int
ncp_negotiate_buffersize(struct ncp_server *server, int size,
int *target);
ncp_negotiate_buffersize(struct ncp_server *server, int size,
int *target);
int
ncp_get_encryption_key(struct ncp_server *server,
char *target);
ncp_get_encryption_key(struct ncp_server *server,
char *target);
int
ncp_get_bindery_object_id(struct ncp_server *server,
int object_type, char *object_name,
struct ncp_bindery_object *target);
ncp_get_bindery_object_id(struct ncp_server *server,
int object_type, char *object_name,
struct ncp_bindery_object *target);
int
ncp_login_encrypted(struct ncp_server *server,
struct ncp_bindery_object *object,
unsigned char *key,
unsigned char *passwd);
ncp_login_encrypted(struct ncp_server *server,
struct ncp_bindery_object *object,
unsigned char *key,
unsigned char *passwd);
int
ncp_login_user(struct ncp_server *server,
unsigned char *username,
unsigned char *password);
ncp_login_user(struct ncp_server *server,
unsigned char *username,
unsigned char *password);
int
ncp_get_volume_info_with_number(struct ncp_server *server, int n,
struct ncp_volume_info *target);
ncp_get_volume_info_with_number(struct ncp_server *server, int n,
struct ncp_volume_info *target);
int
ncp_get_volume_number(struct ncp_server *server, const char *name,
int *target);
ncp_get_volume_number(struct ncp_server *server, const char *name,
int *target);
int
ncp_file_search_init(struct ncp_server *server,
int dir_handle, const char *path,
struct ncp_filesearch_info *target);
ncp_file_search_init(struct ncp_server *server,
int dir_handle, const char *path,
struct ncp_filesearch_info *target);
int
ncp_file_search_continue(struct ncp_server *server,
struct ncp_filesearch_info *fsinfo,
int attributes, const char *path,
struct ncp_file_info *target);
ncp_file_search_continue(struct ncp_server *server,
struct ncp_filesearch_info *fsinfo,
int attributes, const char *path,
struct ncp_file_info *target);
int
ncp_get_finfo(struct ncp_server *server,
int dir_handle, const char *path, const char *name,
struct ncp_file_info *target);
ncp_get_finfo(struct ncp_server *server,
int dir_handle, const char *path, const char *name,
struct ncp_file_info *target);
int
ncp_open_file(struct ncp_server *server,
int dir_handle, const char *path,
int attr, int access,
struct ncp_file_info *target);
int
ncp_close_file(struct ncp_server *server, const char *file_id);
int
ncp_create_newfile(struct ncp_server *server,
int dir_handle, const char *path,
int attr,
struct ncp_file_info *target);
int
ncp_create_file(struct ncp_server *server,
int dir_handle, const char *path,
int attr,
struct ncp_file_info *target);
int
ncp_erase_file(struct ncp_server *server,
ncp_open_file(struct ncp_server *server,
int dir_handle, const char *path,
int attr);
int attr, int access,
struct ncp_file_info *target);
int
ncp_close_file(struct ncp_server *server, const char *file_id);
int
ncp_rename_file(struct ncp_server *server,
int old_handle, const char *old_path,
int attr,
int new_handle, const char *new_path);
ncp_create_newfile(struct ncp_server *server,
int dir_handle, const char *path,
int attr,
struct ncp_file_info *target);
int
ncp_create_directory(struct ncp_server *server,
int dir_handle, const char *path,
int inherit_mask);
ncp_create_file(struct ncp_server *server,
int dir_handle, const char *path,
int attr,
struct ncp_file_info *target);
int
ncp_delete_directory(struct ncp_server *server,
int dir_handle, const char *path);
ncp_erase_file(struct ncp_server *server,
int dir_handle, const char *path,
int attr);
int
ncp_rename_directory(struct ncp_server *server,
int dir_handle,
const char *old_path, const char *new_path);
ncp_rename_file(struct ncp_server *server,
int old_handle, const char *old_path,
int attr,
int new_handle, const char *new_path);
int
ncp_read(struct ncp_server *server, const char *file_id,
__u32 offset, __u16 to_read,
char *target, int *bytes_read);
ncp_create_directory(struct ncp_server *server,
int dir_handle, const char *path,
int inherit_mask);
int
ncp_write(struct ncp_server *server, const char *file_id,
__u32 offset, __u16 to_write,
const char *source, int *bytes_written);
ncp_delete_directory(struct ncp_server *server,
int dir_handle, const char *path);
int
ncp_obtain_info(struct ncp_server *server,
__u8 vol_num, __u32 dir_base,
char *path, /* At most 1 component */
struct nw_info_struct *target);
ncp_rename_directory(struct ncp_server *server,
int dir_handle,
const char *old_path, const char *new_path);
int
ncp_lookup_volume(struct ncp_server *server,
char *volname,
struct nw_info_struct *target);
ncp_read(struct ncp_server *server, const char *file_id,
__u32 offset, __u16 to_read,
char *target, int *bytes_read);
int
ncp_write(struct ncp_server *server, const char *file_id,
__u32 offset, __u16 to_write,
const char *source, int *bytes_written);
int
ncp_obtain_info(struct ncp_server *server,
__u8 vol_num, __u32 dir_base,
char *path, /* At most 1 component */
struct nw_info_struct *target);
int
ncp_lookup_volume(struct ncp_server *server,
char *volname,
struct nw_info_struct *target);
int
ncp_modify_file_or_subdir_dos_info(struct ncp_server *server,
struct nw_info_struct *file,
__u32 info_mask,
struct nw_modify_dos_info *info);
ncp_modify_file_or_subdir_dos_info(struct ncp_server *server,
struct nw_info_struct *file,
__u32 info_mask,
struct nw_modify_dos_info *info);
int
ncp_del_file_or_subdir(struct ncp_server *server,
struct nw_info_struct *dir, char *name);
ncp_del_file_or_subdir(struct ncp_server *server,
struct nw_info_struct *dir, char *name);
int
ncp_open_create_file_or_subdir(struct ncp_server *server,
struct nw_info_struct *dir, char *name,
int open_create_mode,
__u32 create_attributes,
int desired_acc_rights,
struct nw_file_info *target);
ncp_open_create_file_or_subdir(struct ncp_server *server,
struct nw_info_struct *dir, char *name,
int open_create_mode,
__u32 create_attributes,
int desired_acc_rights,
struct nw_file_info *target);
int
ncp_initialize_search(struct ncp_server *server,
struct nw_info_struct *dir,
struct nw_search_sequence *target);
ncp_initialize_search(struct ncp_server *server,
struct nw_info_struct *dir,
struct nw_search_sequence *target);
int
ncp_search_for_file_or_subdir(struct ncp_server *server,
struct nw_search_sequence *seq,
struct nw_info_struct *target);
ncp_search_for_file_or_subdir(struct ncp_server *server,
struct nw_search_sequence *seq,
struct nw_info_struct *target);
int
ncp_ren_or_mov_file_or_subdir(struct ncp_server *server,
struct nw_info_struct *old_dir, char *old_name,
struct nw_info_struct *new_dir, char *new_name);
ncp_ren_or_mov_file_or_subdir(struct ncp_server *server,
struct nw_info_struct *old_dir, char *old_name,
struct nw_info_struct *new_dir, char *new_name);
#endif /* _NCPLIB_H */
#endif /* _NCPLIB_H */

View File

@@ -49,41 +49,40 @@ ncp_wdog_data_ready(struct sock *sk, int len)
fs = get_fs();
set_fs(get_ds());
result = sock->ops->recvfrom(sock, (void *)packet_buf, 2, 1, 0,
(struct sockaddr *)&sender,
result = sock->ops->recvfrom(sock, (void *) packet_buf, 2, 1, 0,
(struct sockaddr *) &sender,
&addr_len);
if ( (result != 2)
if ((result != 2)
|| (packet_buf[1] != '?')
/* How to check connection number here? */
/* How to check connection number here? */
)
{
/* Error, throw away the complete packet */
sock->ops->recvfrom(sock, (void *)packet_buf, 2, 1, 0,
(struct sockaddr *)&sender,
sock->ops->recvfrom(sock, (void *) packet_buf, 2, 1, 0,
(struct sockaddr *) &sender,
&addr_len);
printk("ncpfs: got strange packet on watchdog "
"socket\n");
}
else
} else
{
int result;
DDPRINTK("ncpfs: got watchdog from:\n");
DDPRINTK("ncpfs: %08lX:%02X%02X%02X%02X%02X%02X:%04X,"
" conn:%02X,type:%c\n",
htonl(sender.sipx_network),
sender.sipx_node[0], sender.sipx_node[1],
sender.sipx_node[2], sender.sipx_node[3],
sender.sipx_node[4], sender.sipx_node[5],
ntohs(sender.sipx_port),
packet_buf[0], packet_buf[1]);
" conn:%02X,type:%c\n",
htonl(sender.sipx_network),
sender.sipx_node[0], sender.sipx_node[1],
sender.sipx_node[2], sender.sipx_node[3],
sender.sipx_node[4], sender.sipx_node[5],
ntohs(sender.sipx_port),
packet_buf[0], packet_buf[1]);
packet_buf[1] = 'Y';
result = sock->ops->sendto(sock, (void *)packet_buf,
result = sock->ops->sendto(sock, (void *) packet_buf,
2, 1, 0,
(struct sockaddr *)&sender,
(struct sockaddr *) &sender,
sizeof(sender));
DDPRINTK("send result: %d\n", result);
}
@@ -95,109 +94,100 @@ ncp_wdog_data_ready(struct sock *sk, int len)
int
ncp_catch_watchdog(struct ncp_server *server)
{
struct file *file;
struct inode *inode;
struct socket *sock;
struct sock *sk;
struct file *file;
struct inode *inode;
struct socket *sock;
struct sock *sk;
if ( (server == NULL)
|| ((file = server->wdog_filp) == NULL)
|| ((inode = file->f_inode) == NULL)
|| (!S_ISSOCK(inode->i_mode)))
if ((server == NULL)
|| ((file = server->wdog_filp) == NULL)
|| ((inode = file->f_inode) == NULL)
|| (!S_ISSOCK(inode->i_mode)))
{
printk("ncp_catch_watchdog: did not get valid server!\n");
server->data_ready = NULL;
return -EINVAL;
}
printk("ncp_catch_watchdog: did not get valid server!\n");
server->data_ready = NULL;
return -EINVAL;
}
sock = &(inode->u.socket_i);
sock = &(inode->u.socket_i);
if (sock->type != SOCK_DGRAM)
if (sock->type != SOCK_DGRAM)
{
printk("ncp_catch_watchdog: did not get SOCK_STREAM\n");
server->data_ready = NULL;
return -EINVAL;
}
printk("ncp_catch_watchdog: did not get SOCK_STREAM\n");
server->data_ready = NULL;
return -EINVAL;
}
sk = (struct sock *) (sock->data);
sk = (struct sock *)(sock->data);
if (sk == NULL)
if (sk == NULL)
{
printk("ncp_catch_watchdog: sk == NULL");
server->data_ready = NULL;
return -EINVAL;
}
printk("ncp_catch_watchdog: sk == NULL");
server->data_ready = NULL;
return -EINVAL;
}
DDPRINTK("ncp_catch_watchdog.: sk->d_r = %x, server->d_r = %x\n",
(unsigned int) (sk->data_ready),
(unsigned int) (server->data_ready));
DDPRINTK("ncp_catch_watchdog.: sk->d_r = %x, server->d_r = %x\n",
(unsigned int)(sk->data_ready),
(unsigned int)(server->data_ready));
if (sk->data_ready == ncp_wdog_data_ready)
if (sk->data_ready == ncp_wdog_data_ready)
{
printk("ncp_catch_watchdog: already done\n");
return -EINVAL;
}
server->data_ready = sk->data_ready;
sk->data_ready = ncp_wdog_data_ready;
return 0;
printk("ncp_catch_watchdog: already done\n");
return -EINVAL;
}
server->data_ready = sk->data_ready;
sk->data_ready = ncp_wdog_data_ready;
return 0;
}
int
ncp_dont_catch_watchdog(struct ncp_server *server)
{
struct file *file;
struct inode *inode;
struct socket *sock;
struct sock *sk;
struct file *file;
struct inode *inode;
struct socket *sock;
struct sock *sk;
if ( (server == NULL)
|| ((file = server->wdog_filp) == NULL)
|| ((inode = file->f_inode) == NULL)
|| (!S_ISSOCK(inode->i_mode)))
if ((server == NULL)
|| ((file = server->wdog_filp) == NULL)
|| ((inode = file->f_inode) == NULL)
|| (!S_ISSOCK(inode->i_mode)))
{
printk("ncp_dont_catch_watchdog: "
"did not get valid server!\n");
return -EINVAL;
}
printk("ncp_dont_catch_watchdog: "
"did not get valid server!\n");
return -EINVAL;
}
sock = &(inode->u.socket_i);
sock = &(inode->u.socket_i);
if (sock->type != SOCK_DGRAM)
if (sock->type != SOCK_DGRAM)
{
printk("ncp_dont_catch_watchdog: did not get SOCK_STREAM\n");
return -EINVAL;
}
printk("ncp_dont_catch_watchdog: did not get SOCK_STREAM\n");
return -EINVAL;
}
sk = (struct sock *) (sock->data);
sk = (struct sock *)(sock->data);
if (sk == NULL)
if (sk == NULL)
{
printk("ncp_dont_catch_watchdog: sk == NULL");
return -EINVAL;
}
if (server->data_ready == NULL)
printk("ncp_dont_catch_watchdog: sk == NULL");
return -EINVAL;
}
if (server->data_ready == NULL)
{
printk("ncp_dont_catch_watchdog: "
"server->data_ready == NULL\n");
return -EINVAL;
}
if (sk->data_ready != ncp_wdog_data_ready)
printk("ncp_dont_catch_watchdog: "
"server->data_ready == NULL\n");
return -EINVAL;
}
if (sk->data_ready != ncp_wdog_data_ready)
{
printk("ncp_dont_catch_watchdog: "
"sk->data_callback != ncp_data_callback\n");
return -EINVAL;
}
printk("ncp_dont_catch_watchdog: "
"sk->data_callback != ncp_data_callback\n");
return -EINVAL;
}
DDPRINTK("ncp_dont_catch_watchdog: sk->d_r = %x, server->d_r = %x\n",
(unsigned int) (sk->data_ready),
(unsigned int) (server->data_ready));
DDPRINTK("ncp_dont_catch_watchdog: sk->d_r = %x, server->d_r = %x\n",
(unsigned int)(sk->data_ready),
(unsigned int)(server->data_ready));
sk->data_ready = server->data_ready;
server->data_ready = NULL;
return 0;
sk->data_ready = server->data_ready;
server->data_ready = NULL;
return 0;
}
@@ -229,9 +219,9 @@ do_ncp_rpc_call(struct ncp_server *server, int size)
/* We have to check the result, so store the complete header */
struct ncp_request_header request =
*((struct ncp_request_header *)(server->packet));
*((struct ncp_request_header *) (server->packet));
struct ncp_reply_header reply;
struct ncp_reply_header reply;
file = server->ncp_filp;
@@ -251,32 +241,32 @@ do_ncp_rpc_call(struct ncp_server *server, int size)
old_mask = current->blocked;
current->blocked |= ~(_S(SIGKILL)
#if 0
| _S(SIGSTOP)
| _S(SIGSTOP)
#endif
| ((server->m.flags & NCP_MOUNT_INTR)
? ((current->sigaction[SIGINT - 1].sa_handler == SIG_DFL
? _S(SIGINT) : 0)
| (current->sigaction[SIGQUIT - 1].sa_handler == SIG_DFL
? _S(SIGQUIT) : 0))
: 0));
| ((server->m.flags & NCP_MOUNT_INTR)
? ((current->sigaction[SIGINT - 1].sa_handler == SIG_DFL
? _S(SIGINT) : 0)
| (current->sigaction[SIGQUIT - 1].sa_handler == SIG_DFL
? _S(SIGQUIT) : 0))
: 0));
fs = get_fs();
set_fs(get_ds());
for (n = 0, timeout = init_timeout; ; n++, timeout <<= 1)
for (n = 0, timeout = init_timeout;; n++, timeout <<= 1)
{
DDPRINTK("ncpfs: %08lX:%02X%02X%02X%02X%02X%02X:%04X\n",
htonl(server->m.serv_addr.sipx_network),
server->m.serv_addr.sipx_node[0],
server->m.serv_addr.sipx_node[1],
server->m.serv_addr.sipx_node[2],
server->m.serv_addr.sipx_node[3],
server->m.serv_addr.sipx_node[4],
server->m.serv_addr.sipx_node[5],
ntohs(server->m.serv_addr.sipx_port));
htonl(server->m.serv_addr.sipx_network),
server->m.serv_addr.sipx_node[0],
server->m.serv_addr.sipx_node[1],
server->m.serv_addr.sipx_node[2],
server->m.serv_addr.sipx_node[3],
server->m.serv_addr.sipx_node[4],
server->m.serv_addr.sipx_node[5],
ntohs(server->m.serv_addr.sipx_port));
DDPRINTK("ncpfs: req.typ: %04X, con: %d, "
"seq: %d",
request.type,
(request.conn_high << 8) + request.conn_low,
request.sequence);
"seq: %d",
request.type,
(request.conn_high << 8) + request.conn_low,
request.sequence);
DDPRINTK(" func: %d\n",
request.function);
@@ -289,11 +279,11 @@ do_ncp_rpc_call(struct ncp_server *server, int size)
printk("ncp_rpc_call: send error = %d\n", result);
break;
}
re_select:
re_select:
wait_table.nr = 0;
wait_table.entry = &entry;
current->state = TASK_INTERRUPTIBLE;
if ( !select(inode, file, SEL_IN, &wait_table)
if (!select(inode, file, SEL_IN, &wait_table)
&& !select(inode, file, SEL_IN, NULL))
{
if (timeout > max_timeout)
@@ -336,11 +326,9 @@ do_ncp_rpc_call(struct ncp_server *server, int size)
}
major_timeout_seen = 1;
continue;
}
else
} else
current->timeout = 0;
}
else if (wait_table.nr)
} else if (wait_table.nr)
remove_wait_queue(entry.wait_address, &entry.wait);
current->state = TASK_RUNNING;
addrlen = 0;
@@ -348,7 +336,7 @@ do_ncp_rpc_call(struct ncp_server *server, int size)
/* Get the header from the next packet using a peek, so keep it
* on the recv queue. If it is wrong, it will be some reply
* we don't now need, so discard it */
result = sock->ops->recvfrom(sock, (void *)&reply,
result = sock->ops->recvfrom(sock, (void *) &reply,
sizeof(reply), 1, MSG_PEEK,
NULL, &addrlen);
if (result < 0)
@@ -366,16 +354,16 @@ do_ncp_rpc_call(struct ncp_server *server, int size)
if (result != -ERESTARTSYS)
{
printk("ncp_rpc_call: recv error = %d\n",
-result);
-result);
}
break;
}
if ( (result == sizeof(reply))
if ((result == sizeof(reply))
&& (reply.type == NCP_POSITIVE_ACK))
{
/* Throw away the packet */
DPRINTK("ncp_rpc_call: got positive acknowledge\n");
sock->ops->recvfrom(sock, (void *)&reply,
sock->ops->recvfrom(sock, (void *) &reply,
sizeof(reply), 1, 0,
NULL, &addrlen);
n = 0;
@@ -383,20 +371,19 @@ do_ncp_rpc_call(struct ncp_server *server, int size)
acknowledge_seen = 1;
goto re_select;
}
DDPRINTK("ncpfs: rep.typ: %04X, con: %d, tsk: %d,"
"seq: %d\n",
reply.type,
(reply.conn_high << 8) + reply.conn_low,
reply.task,
reply.sequence);
if ( (result >= sizeof(reply))
&& (reply.type == NCP_REPLY)
&& ( (request.type == NCP_ALLOC_SLOT_REQUEST)
|| ( (reply.sequence == request.sequence)
&& (reply.conn_low == request.conn_low)
/* seem to get wrong task from NW311 && (reply.task == request.task)*/
"seq: %d\n",
reply.type,
(reply.conn_high << 8) + reply.conn_low,
reply.task,
reply.sequence);
if ((result >= sizeof(reply))
&& (reply.type == NCP_REPLY)
&& ((request.type == NCP_ALLOC_SLOT_REQUEST)
|| ((reply.sequence == request.sequence)
&& (reply.conn_low == request.conn_low)
/* seem to get wrong task from NW311 && (reply.task == request.task) */
&& (reply.conn_high == request.conn_high))))
{
if (major_timeout_seen)
@@ -407,7 +394,7 @@ do_ncp_rpc_call(struct ncp_server *server, int size)
* we have xid mismatch, so discard the packet and start
* again. What a hack! but I can't call recvfrom with
* a null buffer yet. */
sock->ops->recvfrom(sock, (void *)&reply, sizeof(reply), 1, 0,
sock->ops->recvfrom(sock, (void *) &reply, sizeof(reply), 1, 0,
NULL, &addrlen);
DPRINTK("ncp_rpc_call: reply mismatch\n");
@@ -417,20 +404,18 @@ do_ncp_rpc_call(struct ncp_server *server, int size)
* we have the correct reply, so read into the correct place and
* return it
*/
result = sock->ops->recvfrom(sock, (void *)start, server->packet_size,
result = sock->ops->recvfrom(sock, (void *) start, server->packet_size,
1, 0, NULL, &addrlen);
if (result < 0)
{
printk("NCP: notice message: result=%d\n", result);
}
else if (result < sizeof(struct ncp_reply_header))
} else if (result < sizeof(struct ncp_reply_header))
{
printk("NCP: just caught a too small read memory size..., "
"email to NET channel\n");
printk("NCP: result=%d,addrlen=%d\n", result, addrlen);
result = -EIO;
}
current->blocked = old_mask;
set_fs(fs);
return result;
@@ -449,7 +434,6 @@ ncp_do_request(struct ncp_server *server, int size)
printk("ncpfs: Server not locked!\n");
return -EIO;
}
return do_ncp_rpc_call(server, size);
}
@@ -460,38 +444,36 @@ int
ncp_request(struct ncp_server *server, int function)
{
struct ncp_request_header *h
= (struct ncp_request_header *)(server->packet);
= (struct ncp_request_header *) (server->packet);
struct ncp_reply_header *reply
= (struct ncp_reply_header *)(server->packet);
= (struct ncp_reply_header *) (server->packet);
int request_size = server->current_size
- sizeof(struct ncp_request_header);
- sizeof(struct ncp_request_header);
int result;
if (server->has_subfunction != 0)
{
*(__u16 *)&(h->data[0]) = request_size - 2;
*(__u16 *) & (h->data[0]) = request_size - 2;
}
h->type = NCP_REQUEST;
server->sequence += 1;
h->sequence = server->sequence;
h->conn_low = (server->connection) & 0xff;
h->sequence = server->sequence;
h->conn_low = (server->connection) & 0xff;
h->conn_high = ((server->connection) & 0xff00) >> 8;
h->task = (current->pid) & 0xff;
h->function = function;
h->task = (current->pid) & 0xff;
h->function = function;
if ((result = ncp_do_request(server, request_size + sizeof(*h))) < 0)
{
DPRINTK("ncp_request_error: %d\n", result);
return result;
}
server->completion = reply->completion_code;
server->completion = reply->completion_code;
server->conn_status = reply->connection_state;
server->reply_size = result;
server->reply_size = result;
server->ncp_reply_size = result - sizeof(struct ncp_reply_header);
result = reply->completion_code;
@@ -500,49 +482,48 @@ ncp_request(struct ncp_server *server, int function)
{
DPRINTK("ncp_completion_code: %x\n", result);
}
return result;
return result;
}
int
ncp_connect(struct ncp_server *server)
{
struct ncp_request_header *h
= (struct ncp_request_header *)(server->packet);
= (struct ncp_request_header *) (server->packet);
int result;
h->type = NCP_ALLOC_SLOT_REQUEST;
server->sequence = 0;
h->sequence = server->sequence;
h->conn_low = 0xff;
h->sequence = server->sequence;
h->conn_low = 0xff;
h->conn_high = 0xff;
h->task = (current->pid) & 0xff;
h->function = 0;
h->task = (current->pid) & 0xff;
h->function = 0;
if ((result = ncp_do_request(server, sizeof(*h))) < 0)
{
return result;
}
server->sequence = 0;
server->connection = h->conn_low + (h->conn_high * 256);
return 0;
}
int
ncp_disconnect(struct ncp_server *server)
{
struct ncp_request_header *h
= (struct ncp_request_header *)(server->packet);
= (struct ncp_request_header *) (server->packet);
h->type = NCP_DEALLOC_SLOT_REQUEST;
server->sequence += 1;
h->sequence = server->sequence;
h->conn_low = (server->connection) & 0xff;
h->sequence = server->sequence;
h->conn_low = (server->connection) & 0xff;
h->conn_high = ((server->connection) & 0xff00) >> 8;
h->task = (current->pid) & 0xff;
h->function = 0;
h->task = (current->pid) & 0xff;
h->function = 0;
return ncp_do_request(server, sizeof(*h));
}
@@ -557,7 +538,7 @@ ncp_lock_server(struct ncp_server *server)
DPRINTK("ncpfs: server locked!!!\n");
}
#endif
while (server->lock)
while (server->lock)
sleep_on(&server->wait);
server->lock = 1;
}
@@ -565,12 +546,10 @@ ncp_lock_server(struct ncp_server *server)
void
ncp_unlock_server(struct ncp_server *server)
{
if (server->lock != 1)
if (server->lock != 1)
{
printk("ncp_unlock_server: was not locked!\n");
}
server->lock = 0;
wake_up(&server->wait);
printk("ncp_unlock_server: was not locked!\n");
}
server->lock = 0;
wake_up(&server->wait);
}

View File

@@ -17,31 +17,34 @@
static void
#ifdef __STDC__
default_com_err_proc (const char *whoami, errcode_t code, const
char *fmt, va_list args)
default_com_err_proc(const char *whoami, errcode_t code, const
char *fmt, va_list args)
#else
default_com_err_proc (whoami, code, fmt, args)
const char *whoami;
errcode_t code;
const char *fmt;
va_list args;
default_com_err_proc(whoami, code, fmt, args)
const char *whoami;
errcode_t code;
const char *fmt;
va_list args;
#endif
{
if (whoami) {
fputs(whoami, stderr);
fputs(": ", stderr);
}
if (code) {
fputs(error_message(code), stderr);
fputs(" ", stderr);
}
if (fmt) {
vfprintf (stderr, fmt, args);
}
/* should do this only on a tty in raw mode */
putc('\r', stderr);
putc('\n', stderr);
fflush(stderr);
if (whoami)
{
fputs(whoami, stderr);
fputs(": ", stderr);
}
if (code)
{
fputs(error_message(code), stderr);
fputs(" ", stderr);
}
if (fmt)
{
vfprintf(stderr, fmt, args);
}
/* should do this only on a tty in raw mode */
putc('\r', stderr);
putc('\n', stderr);
fflush(stderr);
}
#ifdef __STDC__
@@ -53,62 +56,69 @@ typedef void (*errf) ();
errf com_err_hook = default_com_err_proc;
#ifdef __STDC__
void com_err_va (const char *whoami, errcode_t code, const char *fmt,
va_list args)
void
com_err_va(const char *whoami, errcode_t code, const char *fmt,
va_list args)
#else
void com_err_va (whoami, code, fmt, args)
const char *whoami;
errcode_t code;
const char *fmt;
va_list args;
void
com_err_va(whoami, code, fmt, args)
const char *whoami;
errcode_t code;
const char *fmt;
va_list args;
#endif
{
(*com_err_hook) (whoami, code, fmt, args);
(*com_err_hook) (whoami, code, fmt, args);
}
#ifndef VARARGS
void com_err (const char *whoami,
errcode_t code,
const char *fmt, ...)
void
com_err(const char *whoami,
errcode_t code,
const char *fmt,...)
{
#else
void com_err (va_alist)
va_dcl
void
com_err(va_alist)
va_dcl
{
const char *whoami, *fmt;
errcode_t code;
const char *whoami, *fmt;
errcode_t code;
#endif
va_list pvar;
va_list pvar;
if (!com_err_hook)
com_err_hook = default_com_err_proc;
if (!com_err_hook)
com_err_hook = default_com_err_proc;
#ifdef VARARGS
va_start (pvar);
whoami = va_arg (pvar, const char *);
code = va_arg (pvar, errcode_t);
fmt = va_arg (pvar, const char *);
va_start(pvar);
whoami = va_arg(pvar, const char *);
code = va_arg(pvar, errcode_t);
fmt = va_arg(pvar, const char *);
#else
va_start(pvar, fmt);
va_start(pvar, fmt);
#endif
com_err_va (whoami, code, fmt, pvar);
va_end(pvar);
com_err_va(whoami, code, fmt, pvar);
va_end(pvar);
}
errf set_com_err_hook (new_proc)
errf new_proc;
errf
set_com_err_hook(new_proc)
errf new_proc;
{
errf x = com_err_hook;
errf x = com_err_hook;
if (new_proc)
com_err_hook = new_proc;
else
if (new_proc)
com_err_hook = new_proc;
else
com_err_hook = default_com_err_proc;
return x;
}
errf
reset_com_err_hook()
{
errf x = com_err_hook;
com_err_hook = default_com_err_proc;
return x;
}
errf reset_com_err_hook () {
errf x = com_err_hook;
com_err_hook = default_com_err_proc;
return x;
return x;
}

View File

@@ -16,25 +16,25 @@ typedef long errcode_t;
#include <stdarg.h>
/* ANSI C -- use prototypes etc */
void com_err (const char *, long, const char *, ...);
void com_err_va (const char *whoami, errcode_t code, const char *fmt,
va_list args);
char const *error_message (long);
void com_err(const char *, long, const char *,...);
void com_err_va(const char *whoami, errcode_t code, const char *fmt,
va_list args);
char const *error_message(long);
extern void (*com_err_hook) (const char *, long, const char *, va_list);
void (*set_com_err_hook (void (*) (const char *, long, const char *, va_list)))
(const char *, long, const char *, va_list);
void (*reset_com_err_hook (void)) (const char *, long, const char *, va_list);
int init_error_table(const char * const *msgs, int base, int count);
void (*set_com_err_hook(void (*)(const char *, long, const char *, va_list)))
(const char *, long, const char *, va_list);
void (*reset_com_err_hook(void)) (const char *, long, const char *, va_list);
int init_error_table(const char *const *msgs, int base, int count);
#else
/* no prototypes */
void com_err ();
void com_err_va ();
char *error_message ();
void com_err();
void com_err_va();
char *error_message();
extern void (*com_err_hook) ();
void (*set_com_err_hook ()) ();
void (*reset_com_err_hook ()) ();
void (*set_com_err_hook()) ();
void (*reset_com_err_hook()) ();
int init_error_table();
#endif
#define __COM_ERR_H
#endif /* ! defined(__COM_ERR_H) */
#endif /* ! defined(__COM_ERR_H) */

View File

@@ -19,64 +19,72 @@
static char buffer[25];
struct et_list * _et_list = (struct et_list *) NULL;
struct et_list *_et_list = (struct et_list *) NULL;
#ifdef __STDC__
const char * error_message (errcode_t code)
const char *
error_message(errcode_t code)
#else
const char * error_message (code)
errcode_t code;
const char *
error_message(code)
errcode_t code;
#endif
{
int offset;
struct et_list *et;
int table_num;
int started = 0;
char *cp;
int offset;
struct et_list *et;
int table_num;
int started = 0;
char *cp;
offset = code & ((1<<ERRCODE_RANGE)-1);
table_num = code - offset;
if (!table_num) {
offset = code & ((1 << ERRCODE_RANGE) - 1);
table_num = code - offset;
if (!table_num)
{
#ifdef HAS_SYS_ERRLIST
if (offset < sys_nerr)
return(sys_errlist[offset]);
else
goto oops;
if (offset < sys_nerr)
return (sys_errlist[offset]);
else
goto oops;
#else
cp = strerror(offset);
if (cp)
return(cp);
else
goto oops;
cp = strerror(offset);
if (cp)
return (cp);
else
goto oops;
#endif
}
for (et = _et_list; et; et = et->next) {
if (et->table->base == table_num) {
/* This is the right table */
if (et->table->n_msgs <= offset)
goto oops;
return(et->table->msgs[offset]);
}
}
oops:
strcpy (buffer, "Unknown code ");
if (table_num) {
strcat (buffer, error_table_name (table_num));
strcat (buffer, " ");
}
for (cp = buffer; *cp; cp++)
;
if (offset >= 100) {
*cp++ = '0' + offset / 100;
offset %= 100;
started++;
}
if (started || offset >= 10) {
*cp++ = '0' + offset / 10;
offset %= 10;
}
*cp++ = '0' + offset;
*cp = '\0';
return(buffer);
for (et = _et_list; et; et = et->next)
{
if (et->table->base == table_num)
{
/* This is the right table */
if (et->table->n_msgs <= offset)
goto oops;
return (et->table->msgs[offset]);
}
}
oops:
strcpy(buffer, "Unknown code ");
if (table_num)
{
strcat(buffer, error_table_name(table_num));
strcat(buffer, " ");
}
for (cp = buffer; *cp; cp++)
;
if (offset >= 100)
{
*cp++ = '0' + offset / 100;
offset %= 100;
started++;
}
if (started || offset >= 10)
{
*cp++ = '0' + offset / 10;
offset %= 10;
}
*cp++ = '0' + offset;
*cp = '\0';
return (buffer);
}

View File

@@ -11,16 +11,18 @@
#define const
#endif
struct error_table {
char const * const * msgs;
long base;
int n_msgs;
struct error_table
{
char const *const *msgs;
long base;
int n_msgs;
};
struct et_list {
struct et_list *next;
const struct error_table *table;
struct et_list
{
struct et_list *next;
const struct error_table *table;
};
extern struct et_list * _et_list;
extern struct et_list *_et_list;
#define ERRCODE_RANGE 8 /* # of bits to shift table number */
#define BITS_PER_CHAR 6 /* # bits to shift per character in name */

View File

@@ -9,28 +9,30 @@
#include "internal.h"
static const char char_set[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
static char buf[6];
const char * error_table_name(num)
int num;
const char *
error_table_name(num)
int num;
{
int ch;
int i;
char *p;
int ch;
int i;
char *p;
/* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */
p = buf;
num >>= ERRCODE_RANGE;
/* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */
num &= 077777777;
/* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */
for (i = 4; i >= 0; i--) {
ch = (num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1);
if (ch != 0)
*p++ = char_set[ch-1];
}
*p = '\0';
return(buf);
/* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */
p = buf;
num >>= ERRCODE_RANGE;
/* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */
num &= 077777777;
/* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */
for (i = 4; i >= 0; i--)
{
ch = (num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1);
if (ch != 0)
*p++ = char_set[ch - 1];
}
*p = '\0';
return (buf);
}

View File

@@ -4,7 +4,7 @@
* $Locker: $
*
* Copyright 1986, 1987, 1988 by MIT Information Systems and
* the MIT Student Information Processing Board.
* the MIT Student Information Processing Board.
*
* For copyright info, see mit-sipb-copyright.h.
*/
@@ -23,36 +23,39 @@
#define const
#endif
struct foobar {
struct et_list etl;
struct error_table et;
struct foobar
{
struct et_list etl;
struct error_table et;
};
extern struct et_list * _et_list;
extern struct et_list *_et_list;
#ifdef __STDC__
int init_error_table(const char * const *msgs, int base, int count)
int
init_error_table(const char *const *msgs, int base, int count)
#else
int init_error_table(msgs, base, count)
const char * const * msgs;
int base;
int count;
int
init_error_table(msgs, base, count)
const char *const *msgs;
int base;
int count;
#endif
{
struct foobar * new_et;
struct foobar *new_et;
if (!base || !count || !msgs)
if (!base || !count || !msgs)
return 0;
new_et = (struct foobar *) malloc(sizeof(struct foobar));
if (!new_et)
return ENOMEM; /* oops */
new_et->etl.table = &new_et->et;
new_et->et.msgs = msgs;
new_et->et.base = base;
new_et->et.n_msgs = count;
new_et->etl.next = _et_list;
_et_list = &new_et->etl;
return 0;
new_et = (struct foobar *) malloc(sizeof(struct foobar));
if (!new_et)
return ENOMEM; /* oops */
new_et->etl.table = &new_et->et;
new_et->et.msgs = msgs;
new_et->et.base = base;
new_et->et.n_msgs= count;
new_et->etl.next = _et_list;
_et_list = &new_et->etl;
return 0;
}

View File

@@ -10,13 +10,13 @@
#include <errno.h>
#ifdef NEED_SYS_ERRLIST
extern char const * const sys_errlist[];
extern char const *const sys_errlist[];
extern const int sys_nerr;
#endif
/* AIX and Ultrix have standard conforming header files. */
#if !defined(ultrix) && !defined(_AIX)
#ifdef __STDC__
void perror (const char *);
void perror(const char *);
#endif
#endif

View File

@@ -1,19 +1,18 @@
/*
Copyright 1987, 1988 by the Student Information Processing Board
of the Massachusetts Institute of Technology
Copyright 1987, 1988 by the Student Information Processing Board
of the Massachusetts Institute of Technology
Permission to use, copy, modify, and distribute this software
and its documentation for any purpose and without fee is
hereby granted, provided that the above copyright notice
appear in all copies and that both that copyright notice and
this permission notice appear in supporting documentation,
and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
used in advertising or publicity pertaining to distribution
of the software without specific, written prior permission.
M.I.T. and the M.I.T. S.I.P.B. make no representations about
the suitability of this software for any purpose. It is
provided "as is" without express or implied warranty.
*/
Permission to use, copy, modify, and distribute this software
and its documentation for any purpose and without fee is
hereby granted, provided that the above copyright notice
appear in all copies and that both that copyright notice and
this permission notice appear in supporting documentation,
and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
used in advertising or publicity pertaining to distribution
of the software without specific, written prior permission.
M.I.T. and the M.I.T. S.I.P.B. make no representations about
the suitability of this software for any purpose. It is
provided "as is" without express or implied warranty.
*/

View File

@@ -2575,6 +2575,31 @@ ncp_delete_trustee(struct ncp_conn *conn,
return result;
}
long
ncp_get_trustee(struct ncp_conn *conn, __u32 object_id,
__u8 vol, char *path,
__u16 * trustee, __u16 * contin)
{
long result;
ncp_init_request_s(conn, 71);
ncp_add_byte(conn, vol);
ncp_add_word_hl(conn, *contin);
ncp_add_dword_hl(conn, object_id);
if ((result = ncp_request(conn, 23)) != 0)
{
ncp_unlock_conn(conn);
return result;
}
*contin = ncp_reply_word_hl(conn, 0);
*trustee = ncp_reply_byte(conn, 6);
strncpy(path, ncp_reply_data(conn, 8), ncp_reply_byte(conn, 7));
path[ncp_reply_byte(conn, 7)] = 0;
ncp_unlock_conn(conn);
return 0;
}
long
ncp_rename_directory(struct ncp_conn *conn,
int dir_handle,

View File

@@ -14,7 +14,7 @@ nprint \- NetWare print client
] [
.B -P
.I password
|
|
.B -n
] [
.B -C

View File

@@ -14,7 +14,7 @@ nwbocreate \- Create a NetWare Bindery Object
] [
.B -P
.I password
|
|
.B -n
] [
.B -C

View File

@@ -14,7 +14,7 @@ nwbols \- List NetWare Bindery Objects
] [
.B -P
.I password
|
|
.B -n
] [
.B -C

View File

@@ -14,7 +14,7 @@ nwboprops \- List properies of a NetWare Bindery Object
] [
.B -P
.I password
|
|
.B -n
] [
.B -C

View File

@@ -14,7 +14,7 @@ nwborm \- Remove a NetWare Bindery Object
] [
.B -P
.I password
|
|
.B -n
] [
.B -C

View File

@@ -14,7 +14,7 @@ nwbpadd \- Set the value of a NetWare Bindery Property
] [
.B -P
.I password
|
|
.B -n
] [
.B -C

View File

@@ -14,7 +14,7 @@ nwbpset \- Create a bindery property or set its value
] [
.B -P
.I password
|
|
.B -n
] [
.B -C

View File

@@ -14,7 +14,7 @@ nwfstime \- Display / Set a NetWare server's date and time
] [
.B -P
.I password
|
|
.B -n
] [
.B -C

View File

@@ -14,7 +14,7 @@ nwgrant \- Add Trustee Rights to a directory
] [
.B -P
.I password
|
|
.B -n
] [
.B -C

View File

@@ -14,7 +14,7 @@ nwrevoke \- Revoke a Trustee Right from a directory
] [
.B -P
.I password
|
|
.B -n
] [
.B -C

127
man/nwtrustee.1 Normal file
View File

@@ -0,0 +1,127 @@
.TH NWTRUSTEE 8 7/9/1996 nwtrustee nwtrustee
.SH NAME
nwtrustee \- List an object's trustee directory assignments
.SH SYNOPSIS
.B nwtrustee
[
.B -h
] [
.B -S
.I server
] [
.B -U
.I user name
] [
.B -P
.I password
|
.B -n
] [
.B -C
] [
.B -l
.I volume number
] [
.B -L
.I volume name
] [
.B -o
.I object id
] [
.B -O
.I object name
] [
.B -t
.I object type
] [
.B -v
]
.SH DESCRIPTION
.B nwtrustee
lists the trustee directory assignments a user has on a specific volume.
.B nwtrustee
looks up the file
.I $HOME/.nwclient
to find a file server, a user name and possibly a password. See
nwclient(5) for more information. Please note that the access
permissions of $HOME/.nwclient MUST be 600 for security reasons.
.SH OPTIONS
.B -h
.RS 3
.B -h
is used to print out a short help text.
.RE
.B -S
.I server
.RS 3
.B server
is the name of the server you want to use.
.RE
.B -U
.I user
.RS 3
.B user
is the user name to use for login.
.RE
.B -P
.I password
.RS 3
.B password
is the password to use for login. If neither
.B -n
nor
.B -P
are given, and the user has no open connection to the server, nwtrustee
prompts for a password.
.RE
.B -n
.RS 3
.B -n
should be given if no password is required for the login.
.RE
.B -C
.RS 3
By default, passwords are converted to uppercase before they are sent
to the server, because most servers require this. You can turn off
this conversion by
.B -C.
.RE
.B -o
.I object id
.RS 3
The bindery object id of the user whose assignments should be listed.
Alternatively, use -O object name.
.RE
.B -O
.I object name
.RS 3
The name of the user whose assignments should be listed.
.RE
.B -t
.I object type
.RS 3
The type of object whose assignments should be listed. This defaults to 1,
which means user. Another sensible value is 2, which means group.
.RE
.B -v
.RS 3
Verbose listing. Also list the specific rights that are assigned to the
user.
.RE
.SH AUTHORS
nwtrustee was written by Jacek Stepniewski <cunio@gazeta.pl>.
This manual page was written by Volker Lendecke.

View File

@@ -14,7 +14,7 @@ nwuserlist \- List Users logged in at a NetWare server
] [
.B -P
.I password
|
|
.B -n
] [
.B -C

View File

@@ -14,7 +14,7 @@ pserver \- NetWare print server
] [
.B -P
.I password
|
|
.B -n
] [
.B -C

View File

@@ -1,7 +1,7 @@
Begin3
Title: ncpfs
Version: 2.0.9
Entered-date: 16. February 1997
Version: 2.0.10
Entered-date: 23. February 1997
Description: With ncpfs you can mount volumes of your netware
server under Linux. You can also print to netware
print queues and spool netware print queues to the
@@ -13,7 +13,7 @@ Author: lendecke@namu01.Num.Math.Uni-Goettingen.de (Volker Lendecke)
Maintained-by: lendecke@namu01.Num.Math.Uni-Goettingen.de (Volker Lendecke)
Primary-site: ftp.gwdg.de:/pub/linux/misc/ncpfs
Alternate-site: sunsite.unc.edu:/pub/Linux/system/Filesystems/ncpfs
~156k ncpfs-2.0.9.tgz
~ 1k ncpfs-2.0.9.lsm
~158k ncpfs-2.0.10.tgz
~ 1k ncpfs-2.0.10.lsm
Copying-policy: GPL
End

View File

@@ -15,9 +15,9 @@
#include <linux/ipx.h>
#include <stdio.h>
typedef unsigned long IPXNet;
typedef unsigned long IPXNet;
typedef unsigned short IPXPort;
typedef unsigned char IPXNode[IPX_NODE_LEN];
typedef unsigned char IPXNode[IPX_NODE_LEN];
#define IPX_USER_PTYPE (0x00)
#define IPX_RIP_PTYPE (0x01)
@@ -33,30 +33,35 @@ typedef unsigned char IPXNode[IPX_NODE_LEN];
#define IPX_SAP_FILE_SERVER (0x0004)
struct sap_query {
unsigned short query_type; /* net order */
unsigned short server_type; /* net order */
struct sap_query
{
unsigned short query_type; /* net order */
unsigned short server_type; /* net order */
};
struct sap_server_ident {
unsigned short server_type __attribute__ ((packed));
char server_name[48] __attribute__ ((packed));
IPXNet server_network __attribute__ ((packed));
IPXNode server_node __attribute__ ((packed));
IPXPort server_port __attribute__ ((packed));
unsigned short intermediate_network __attribute__ ((packed));
struct sap_server_ident
{
unsigned short server_type __attribute__((packed));
char server_name[48] __attribute__((packed));
IPXNet server_network __attribute__((packed));
IPXNode server_node __attribute__((packed));
IPXPort server_port __attribute__((packed));
unsigned short intermediate_network __attribute__((packed));
};
#define IPX_RIP_REQUEST (0x1)
#define IPX_RIP_RESPONSE (0x2)
struct ipx_rip_packet {
__u16 operation __attribute__ ((packed));
struct ipx_rt_def {
__u32 network __attribute__ ((packed));
__u16 hops __attribute__ ((packed));
__u16 ticks __attribute__ ((packed));
} rt[1] __attribute__ ((packed));
struct ipx_rip_packet
{
__u16 operation __attribute__((packed));
struct ipx_rt_def
{
__u32 network __attribute__((packed));
__u16 hops __attribute__((packed));
__u16 ticks __attribute__((packed));
}
rt[1] __attribute__((packed));
};
#define IPX_BROADCAST_NODE ("\xff\xff\xff\xff\xff\xff")
@@ -68,26 +73,26 @@ struct ipx_rip_packet {
#endif
void
ipx_print_node(IPXNode node);
ipx_print_node(IPXNode node);
void
ipx_print_network(IPXNet net);
ipx_print_network(IPXNet net);
void
ipx_print_port(IPXPort port);
ipx_print_port(IPXPort port);
void
ipx_print_saddr(struct sockaddr_ipx* sipx);
ipx_print_saddr(struct sockaddr_ipx *sipx);
void
ipx_fprint_node(FILE *file, IPXNode node);
ipx_fprint_node(FILE * file, IPXNode node);
void
ipx_fprint_network(FILE *file, IPXNet net);
ipx_fprint_network(FILE * file, IPXNet net);
void
ipx_fprint_port(FILE *file, IPXPort port);
ipx_fprint_port(FILE * file, IPXPort port);
void
ipx_fprint_saddr(FILE *file, struct sockaddr_ipx* sipx);
ipx_fprint_saddr(FILE * file, struct sockaddr_ipx *sipx);
int
ipx_sscanf_node(char *buf, unsigned char node[IPX_NODE_LEN]);
ipx_sscanf_node(char *buf, unsigned char node[IPX_NODE_LEN]);
void
ipx_assign_node(IPXNode dest, IPXNode src);
ipx_assign_node(IPXNode dest, IPXNode src);
int
ipx_node_equal(IPXNode n1,IPXNode n2);
ipx_node_equal(IPXNode n1, IPXNode n2);
#endif /* _IPXLIB_H */
#endif /* _IPXLIB_H */

View File

@@ -9,7 +9,7 @@
#include "ncplib_err.h"
#include <sys/ioctl.h>
/* #include <sys/wait.h> *//* generates a warning here */
/* #include <sys/wait.h> *//* generates a warning here */
extern pid_t wait(int *);
#include <stdio.h>
#include <string.h>

View File

@@ -33,26 +33,26 @@ typedef __u32 dword;
#define BSET(buf,pos,val) (BVAL(buf,pos) = (val))
static inline word
WVAL_HL(__u8 *buf, int pos)
WVAL_HL(__u8 * buf, int pos)
{
return PVAL(buf,pos)<<8 | PVAL(buf, pos+1);
return PVAL(buf, pos) << 8 | PVAL(buf, pos + 1);
}
static inline dword
DVAL_HL(__u8 *buf, int pos)
DVAL_HL(__u8 * buf, int pos)
{
return WVAL_HL(buf, pos)<<16 | WVAL_HL(buf, pos+2);
return WVAL_HL(buf, pos) << 16 | WVAL_HL(buf, pos + 2);
}
static inline void
WSET_HL(__u8 *buf, int pos, word val)
WSET_HL(__u8 * buf, int pos, word val)
{
BSET(buf,pos,val>>8);
BSET(buf,pos+1, val & 0xff);
BSET(buf, pos, val >> 8);
BSET(buf, pos + 1, val & 0xff);
}
static inline void
DSET_HL(__u8 *buf, int pos, dword val)
DSET_HL(__u8 * buf, int pos, dword val)
{
WSET_HL(buf, pos, val >>16);
WSET_HL(buf, pos+2, val & 0xffff);
WSET_HL(buf, pos, val >> 16);
WSET_HL(buf, pos + 2, val & 0xffff);
}
@@ -61,68 +61,70 @@ DSET_HL(__u8 *buf, int pos, dword val)
#if defined(__i386__)
static inline word
WVAL_LH(__u8 *buf, int pos)
WVAL_LH(__u8 * buf, int pos)
{
return *((word *)(buf+pos));
return *((word *) (buf + pos));
}
static inline dword
DVAL_LH(__u8 *buf, int pos)
DVAL_LH(__u8 * buf, int pos)
{
return *((dword *)(buf+pos));
return *((dword *) (buf + pos));
}
static inline void
WSET_LH(__u8 *buf, int pos, word val)
WSET_LH(__u8 * buf, int pos, word val)
{
*((word *)(buf+pos)) = val;
*((word *) (buf + pos)) = val;
}
static inline void
DSET_LH(__u8 *buf, int pos, dword val)
DSET_LH(__u8 * buf, int pos, dword val)
{
*((dword *)(buf+pos)) = val;
*((dword *) (buf + pos)) = val;
}
#else
static inline word
WVAL_LH(__u8 *buf, int pos)
WVAL_LH(__u8 * buf, int pos)
{
return PVAL(buf,pos) | PVAL(buf, pos+1)<<8;
return PVAL(buf, pos) | PVAL(buf, pos + 1) << 8;
}
static inline dword
DVAL_LH(__u8 *buf, int pos)
DVAL_LH(__u8 * buf, int pos)
{
return WVAL_LH(buf, pos) | WVAL_LH(buf, pos+2) << 16;
return WVAL_LH(buf, pos) | WVAL_LH(buf, pos + 2) << 16;
}
static inline void
WSET_LH(__u8 *buf, int pos, word val)
WSET_LH(__u8 * buf, int pos, word val)
{
BSET(buf,pos,val & 0xff);
BSET(buf,pos+1, val >> 8);
BSET(buf, pos, val & 0xff);
BSET(buf, pos + 1, val >> 8);
}
static inline void
DSET_LH(__u8 *buf, int pos, dword val)
DSET_LH(__u8 * buf, int pos, dword val)
{
WSET_LH(buf, pos, val & 0xffff);
WSET_LH(buf, pos+2, val >> 16);
WSET_LH(buf, pos + 2, val >> 16);
}
#endif
void
str_upper(char *name);
str_upper(char *name);
enum connect_state {
enum connect_state
{
NOT_CONNECTED = 0,
CONN_PERMANENT,
CONN_TEMPORARY
};
struct ncp_conn {
struct ncp_conn
{
enum connect_state is_connected;
char server[NCP_BINDERY_NAME_LEN];
char user [NCP_BINDERY_NAME_LEN];
char user[NCP_BINDERY_NAME_LEN];
struct ncp_fs_info i;
@@ -150,7 +152,8 @@ struct ncp_conn {
char packet[NCP_PACKET_SIZE];
};
struct ncp_conn_spec {
struct ncp_conn_spec
{
char server[NCP_BINDERY_NAME_LEN];
char user[NCP_BINDERY_NAME_LEN];
uid_t uid;
@@ -158,7 +161,8 @@ struct ncp_conn_spec {
char password[NCP_BINDERY_NAME_LEN];
};
struct ncp_property_info {
struct ncp_property_info
{
__u8 property_name[16];
__u8 property_flags;
__u8 property_security;
@@ -173,46 +177,47 @@ struct ncp_property_info {
from the list. It was designed after the X Windows init
functions. */
struct ncp_conn *
ncp_initialize(int *argc, char **argv,
int login_necessary, long *err);
ncp_initialize(int *argc, char **argv,
int login_necessary, long *err);
/* You can login as another object by this procedure. As a first use
pserver comes to mind. */
struct ncp_conn *
ncp_initialize_as(int *argc, char **argv,
int login_necessary, int login_type, long *err);
ncp_initialize_as(int *argc, char **argv,
int login_necessary, int login_type, long *err);
/* Open a connection */
struct ncp_conn *
ncp_open(struct ncp_conn_spec *spec, long *err);
ncp_open(struct ncp_conn_spec *spec, long *err);
/* Open a connection on an existing mount point */
struct ncp_conn *
ncp_open_mount(const char *mount_point, long *err);
ncp_open_mount(const char *mount_point, long *err);
/* Find a permanent connection that fits the spec, return NULL if
* there is none. */
char *
ncp_find_permanent(const struct ncp_conn_spec *spec);
ncp_find_permanent(const struct ncp_conn_spec *spec);
/* Find the address of a file server */
struct sockaddr_ipx *
ncp_find_fileserver(char *server_name, long *err);
ncp_find_fileserver(char *server_name, long *err);
/* Find the address of a server */
struct sockaddr_ipx *
ncp_find_server(char **server_name, int type, long *err);
ncp_find_server(char **server_name, int type, long *err);
/* Detach from a permanent connection or destroy a temporary
connection */
long
ncp_close(struct ncp_conn *conn);
ncp_close(struct ncp_conn *conn);
/* like getmntent, get_ncp_conn_ent scans /etc/mtab for usable
connections */
struct ncp_conn_ent {
struct ncp_conn_ent
{
char server[NCP_BINDERY_NAME_LEN];
char user[NCP_BINDERY_NAME_LEN];
uid_t uid;
@@ -220,7 +225,7 @@ struct ncp_conn_ent {
};
struct ncp_conn_ent *
ncp_get_conn_ent(FILE *filep);
ncp_get_conn_ent(FILE * filep);
#define NWCLIENT (".nwclient")
#define NWC_NOPASSWORD ("-")
@@ -228,55 +233,57 @@ ncp_get_conn_ent(FILE *filep);
/* find an appropriate connection */
struct ncp_conn_spec *
ncp_find_conn_spec(const char *server, const char *user, const char *password,
int login_necessary, uid_t uid, long *err);
ncp_find_conn_spec(const char *server, const char *user, const char *password,
int login_necessary, uid_t uid, long *err);
long
ncp_get_encryption_key(struct ncp_conn *conn,
char *target);
ncp_get_encryption_key(struct ncp_conn *conn,
char *target);
struct ncp_station_addr {
__u32 NetWork __attribute__ ((packed));
__u8 Node[6] __attribute__ ((packed));
__u16 Socket __attribute__ ((packed));
struct ncp_station_addr
{
__u32 NetWork __attribute__((packed));
__u8 Node[6] __attribute__((packed));
__u16 Socket __attribute__((packed));
};
struct ncp_prop_login_control {
__u8 AccountExpireDate[3] __attribute__ ((packed));
__u8 Disabled __attribute__ ((packed));
__u8 PasswordExpireDate[3] __attribute__ ((packed));
__u8 GraceLogins __attribute__ ((packed));
__u16 PasswordExpireInterval __attribute__ ((packed));
__u8 MaxGraceLogins __attribute__ ((packed));
__u8 MinPasswordLength __attribute__ ((packed));
__u16 MaxConnections __attribute__ ((packed));
__u8 ConnectionTimeMask[42] __attribute__ ((packed));
__u8 LastLogin[6] __attribute__ ((packed));
__u8 RestrictionMask __attribute__ ((packed));
__u8 reserved __attribute__ ((packed));
__u32 MaxDiskUsage __attribute__ ((packed));
__u16 BadLoginCount __attribute__ ((packed));
__u32 BadLoginCountDown __attribute__ ((packed));
struct ncp_station_addr LastIntruder __attribute__ ((packed));
};
struct ncp_prop_login_control
{
__u8 AccountExpireDate[3] __attribute__((packed));
__u8 Disabled __attribute__((packed));
__u8 PasswordExpireDate[3] __attribute__((packed));
__u8 GraceLogins __attribute__((packed));
__u16 PasswordExpireInterval __attribute__((packed));
__u8 MaxGraceLogins __attribute__((packed));
__u8 MinPasswordLength __attribute__((packed));
__u16 MaxConnections __attribute__((packed));
__u8 ConnectionTimeMask[42] __attribute__((packed));
__u8 LastLogin[6] __attribute__((packed));
__u8 RestrictionMask __attribute__((packed));
__u8 reserved __attribute__((packed));
__u32 MaxDiskUsage __attribute__((packed));
__u16 BadLoginCount __attribute__((packed));
__u32 BadLoginCountDown __attribute__((packed));
struct ncp_station_addr LastIntruder __attribute__((packed));
};
long
ncp_read_property_value(struct ncp_conn *conn,
int object_type, const char *object_name,
int segment, const char *prop_name,
struct nw_property *target);
ncp_read_property_value(struct ncp_conn *conn,
int object_type, const char *object_name,
int segment, const char *prop_name,
struct nw_property *target);
#define NCP_GRACE_PERIOD (0xdf)
long
ncp_get_bindery_object_id(struct ncp_conn *conn,
__u16 object_type,
const char *object_name,
struct ncp_bindery_object *target);
ncp_get_bindery_object_id(struct ncp_conn *conn,
__u16 object_type,
const char *object_name,
struct ncp_bindery_object *target);
long
ncp_login_user(struct ncp_conn *conn,
const unsigned char *username,
const unsigned char *password);
ncp_login_user(struct ncp_conn *conn,
const unsigned char *username,
const unsigned char *password);
#endif /* _NCPLIB_H */
#endif /* _NCPLIB_H */

View File

@@ -26,7 +26,7 @@
#include <netdb.h>
#include <sys/stat.h>
#include <sys/types.h>
/* #include <sys/wait.h> *//* generates a warning here */
/* #include <sys/wait.h> *//* generates a warning here */
extern pid_t waitpid(pid_t, int *, int);
#include <sys/errno.h>
#include <sys/time.h>

View File

@@ -16,7 +16,7 @@
#include <netdb.h>
#include <sys/stat.h>
#include <sys/types.h>
/* #include <sys/wait.h> *//* generates a warning here */
/* #include <sys/wait.h> *//* generates a warning here */
extern pid_t waitpid(pid_t, int *, int);
#include <sys/errno.h>
#include <unistd.h>

View File

@@ -6,7 +6,7 @@ USERUTILS = slist pqlist nwfsinfo pserver nprint nsend ncopy nwpasswd
USERUTILS += nwbols nwbocreate nwborm nwboprops
USERUTILS += nwbpcreate nwbprm nwbpvalues nwbpadd nwbpset
USERUTILS += nwgrant nwrevoke nwuserlist nwrights nwauth
USERUTILS += nwfstime nwvolinfo
USERUTILS += nwfstime nwvolinfo nwtrustee
SBINUTILS = nwmsg
UTILS = $(USERUTILS) $(SBINUTILS) ncptest

View File

@@ -19,7 +19,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/ioctl.h>
/* #include <sys/wait.h> *//* generates a warning here */
/* #include <sys/wait.h> *//* generates a warning here */
extern pid_t waitpid(pid_t, int *, int);
#include <sys/errno.h>
#include <unistd.h>

View File

@@ -1,7 +1,7 @@
/*
* nwtrustee.c
*
* List Trustees
* List Trustees Directory Assignments of an object
*
* Copyright (C) 1996 by Volker Lendecke
*
@@ -36,7 +36,7 @@ help(void)
"-C Don't convert password to uppercase\n"
"\n"
"-l volumeid Volume id to be searched\n"
"-L volname Volume name insteed of id\n"
"-L volname Volume name instead of id\n"
"-o objectid Object id\n"
"-O objname Object name ( type must be specified )\n"
"-t type Object type\n"
@@ -44,7 +44,7 @@ help(void)
"\n");
}
int
int
fromhex(char c)
{
c -= '0';
@@ -152,8 +152,6 @@ main(int argc, char **argv)
printf("%X\n", trust);
}
}
ncp_close(conn);
return 0;
}