diff --git a/.downloads/ncpfs-2.0.10.tgz b/.downloads/ncpfs-2.0.10.tgz new file mode 100644 index 0000000..30784d8 Binary files /dev/null and b/.downloads/ncpfs-2.0.10.tgz differ diff --git a/Changes b/Changes index 3cd8536..9eedd3f 100644 --- a/Changes +++ b/Changes @@ -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 diff --git a/Makefile b/Makefile index 8cf8201..27a3a88 100644 --- a/Makefile +++ b/Makefile @@ -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); \ diff --git a/contrib/tknwmsg/nwmsg.c b/contrib/tknwmsg/nwmsg.c index 640b4b4..6f0c200 100644 --- a/contrib/tknwmsg/nwmsg.c +++ b/contrib/tknwmsg/nwmsg.c @@ -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; diff --git a/include/ncplib.h b/include/ncplib.h index a73c038..e0f2af7 100644 --- a/include/ncplib.h +++ b/include/ncplib.h @@ -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, diff --git a/ipx-1.0/Samples/ipxrcv.c b/ipx-1.0/Samples/ipxrcv.c index 2a71e64..d076506 100644 --- a/ipx-1.0/Samples/ipxrcv.c +++ b/ipx-1.0/Samples/ipxrcv.c @@ -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; } - - - - diff --git a/ipx-1.0/Samples/ipxsend.c b/ipx-1.0/Samples/ipxsend.c index f999fee..e8b519d 100644 --- a/ipx-1.0/Samples/ipxsend.c +++ b/ipx-1.0/Samples/ipxsend.c @@ -1,3 +1,7 @@ + + + + #include #include #include @@ -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; } - - - - diff --git a/ipx-1.0/Samples/rip.c b/ipx-1.0/Samples/rip.c index 12d6e85..67f660e 100644 --- a/ipx-1.0/Samples/rip.c +++ b/ipx-1.0/Samples/rip.c @@ -1,3 +1,7 @@ + + + + #include #include #include @@ -5,25 +9,27 @@ #include #include -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++; } } } - - - - diff --git a/ipx-1.0/Samples/sap.c b/ipx-1.0/Samples/sap.c index 594e52d..cfb3a6b 100644 --- a/ipx-1.0/Samples/sap.c +++ b/ipx-1.0/Samples/sap.c @@ -1,3 +1,7 @@ + + + + #include #include #include @@ -6,55 +10,58 @@ #include -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++; } } } - - - - diff --git a/ipx-1.0/ipx_configure.c b/ipx-1.0/ipx_configure.c index da72787..1f4d754 100644 --- a/ipx-1.0/ipx_configure.c +++ b/ipx-1.0/ipx_configure.c @@ -1,5 +1,5 @@ /* Copyright (c) 1995-1996 Caldera, Inc. All Rights Reserved. - * + * See file COPYING for details. */ @@ -14,20 +14,21 @@ #include #include -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); } - diff --git a/ipx-1.0/ipx_interface.c b/ipx-1.0/ipx_interface.c index e1ef8fe..105c529 100644 --- a/ipx-1.0/ipx_interface.c +++ b/ipx-1.0/ipx_interface.c @@ -1,5 +1,6 @@ + /* Copyright (c) 1995-1996 Caldera, Inc. All Rights Reserved. - * + * See file COPYING for details. */ @@ -17,8 +18,8 @@ #include #include -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; } diff --git a/ipx-1.0/ipx_internal_net.c b/ipx-1.0/ipx_internal_net.c index 2cad875..52e37ab 100644 --- a/ipx-1.0/ipx_internal_net.c +++ b/ipx-1.0/ipx_internal_net.c @@ -1,5 +1,5 @@ /* Copyright (c) 1995-1996 Caldera, Inc. All Rights Reserved. - * + * See file COPYING for details. */ @@ -15,8 +15,8 @@ #include #include -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; } - diff --git a/ipx-1.0/ipx_route.c b/ipx-1.0/ipx_route.c index e280ac2..8f0489d 100644 --- a/ipx-1.0/ipx_route.c +++ b/ipx-1.0/ipx_route.c @@ -1,5 +1,6 @@ + /* Copyright (c) 1995-1996 Caldera, Inc. All Rights Reserved. - * + * See file COPYING for details. */ @@ -16,18 +17,21 @@ #include #include -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; diff --git a/ipxdump/ipxdump.c b/ipxdump/ipxdump.c index 105c5ae..c85b024 100644 --- a/ipxdump/ipxdump.c +++ b/ipxdump/ipxdump.c @@ -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)])); diff --git a/ipxdump/ipxparse.c b/ipxdump/ipxparse.c index 2fb8d1c..b612e26 100644 --- a/ipxdump/ipxparse.c +++ b/ipxdump/ipxparse.c @@ -1,7 +1,7 @@ -/* ipxparse.c */ +/* ipxparse.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 @@ -35,117 +35,127 @@ #include #include "ipxutil.h" -#define DUMPALLSAPS /* #define if you want to dump all SAP's */ +#define DUMPALLSAPS /* #define if you want to dump all SAP's */ 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)); }; #define NCP_ALLOC_SLOT_REQUEST (0x1111) #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)); }; #define NCP_BURST_PACKET (0x7777) -struct ncp_burst_header { - __u16 type __attribute__ ((packed)); - __u8 system_flags __attribute__ ((packed)); - __u8 stream_type __attribute__ ((packed)); - __u32 source_conn __attribute__ ((packed)); - __u32 dest_conn __attribute__ ((packed)); - __u32 packet_sequence __attribute__ ((packed)); - __u32 send_delay __attribute__ ((packed)); - __u16 burst_sequence __attribute__ ((packed)); - __u16 ack_sequence __attribute__ ((packed)); - __u32 burst_length __attribute__ ((packed)); - __u32 data_offset __attribute__ ((packed)); - __u16 data_bytes __attribute__ ((packed)); - __u16 missing_frags __attribute__ ((packed)); +struct ncp_burst_header +{ + __u16 type __attribute__((packed)); + __u8 system_flags __attribute__((packed)); + __u8 stream_type __attribute__((packed)); + __u32 source_conn __attribute__((packed)); + __u32 dest_conn __attribute__((packed)); + __u32 packet_sequence __attribute__((packed)); + __u32 send_delay __attribute__((packed)); + __u16 burst_sequence __attribute__((packed)); + __u16 ack_sequence __attribute__((packed)); + __u32 burst_length __attribute__((packed)); + __u32 data_offset __attribute__((packed)); + __u16 data_bytes __attribute__((packed)); + __u16 missing_frags __attribute__((packed)); }; -void handle_ipx (unsigned char *buf, int length, char *frame, int no); -void handle_ncp (struct sockaddr_ipx *source, - struct sockaddr_ipx *target, - unsigned char *buf, int length, int no); +void handle_ipx(unsigned char *buf, int length, char *frame, int no); +void handle_ncp(struct sockaddr_ipx *source, + struct sockaddr_ipx *target, + unsigned char *buf, int length, int no); int handle_burst(struct sockaddr_ipx *source, struct sockaddr_ipx *target, unsigned char *buf, int length, int no); #define SAP_MAX_SERVER_NAME_LENGTH 48 /* in network packets */ #define SAP_MAX_SAPS_PER_PACKET 7 -#define SAP_SHUTDOWN 16 /* Magic "hops" value to stop SAP advertising */ +#define SAP_SHUTDOWN 16 /* Magic "hops" value to stop SAP advertising */ /* SAP Query structure (returned in sap_packet as an array) * NBO == Network Byte Order) */ -typedef struct saps { - __u16 serverType __attribute__ ((packed)); /* NBO */ - __u8 serverName[SAP_MAX_SERVER_NAME_LENGTH] __attribute__ ((packed)); - struct ipx_address serverAddress __attribute__ ((packed)); - __u16 serverHops __attribute__ ((packed)); /* NBO */ -} SAPS; +typedef struct saps +{ + __u16 serverType __attribute__((packed)); /* NBO */ + __u8 serverName[SAP_MAX_SERVER_NAME_LENGTH] __attribute__((packed)); + struct ipx_address serverAddress __attribute__((packed)); + __u16 serverHops __attribute__((packed)); /* NBO */ +} +SAPS; /* General Service/Nearest Server Response SAP packet */ -union sap_packet { - unsigned short sapOperation; - struct sap_query { - __u16 sapOperation __attribute__ ((packed)); - __u16 serverType __attribute__ ((packed)); - } query; - struct sap_response { - __u16 sapOperation __attribute__ ((packed)); +union sap_packet +{ + unsigned short sapOperation; + struct sap_query + { + __u16 sapOperation __attribute__((packed)); + __u16 serverType __attribute__((packed)); + } + query; + struct sap_response + { + __u16 sapOperation __attribute__((packed)); /* each SAP can has a max of SAP_MAX_SAPS_PER_PACKET packets */ - SAPS sap[SAP_MAX_SAPS_PER_PACKET] __attribute__ ((packed)); - } response; + SAPS sap[SAP_MAX_SAPS_PER_PACKET] __attribute__((packed)); + } + response; }; /* print out one SAP record */ static void -print_sap(FILE *file, SAPS *sapp) +print_sap(FILE * file, SAPS * sapp) { fprintf(file, " Name:%s, serverType 0x%x, ", sapp->serverName, @@ -159,25 +169,25 @@ print_sap(FILE *file, SAPS *sapp) } void -handle_ipx (unsigned char *buf, int length, char *frame, int no) +handle_ipx(unsigned char *buf, int length, char *frame, int no) { - 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; - union sap_packet *sappacket; - int hbo_dsock; /* Host Byte Order of Destination SOCKet */ - int hbo_sapop; /* Host Byte Order of SAP OPeration */ + union sap_packet *sappacket; + int hbo_dsock; /* Host Byte Order of Destination SOCKet */ + int hbo_sapop; /* Host Byte Order of SAP OPeration */ memset(&s_addr, 0, sizeof(s_addr)); memset(&d_addr, 0, sizeof(d_addr)); 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; printf("%6.6d %s from ", no, frame); @@ -191,42 +201,37 @@ handle_ipx (unsigned char *buf, int length, char *frame, int no) { return; } - - if ( (ntohs(s_addr.sipx_port) == 0x451) + if ((ntohs(s_addr.sipx_port) == 0x451) || (ntohs(d_addr.sipx_port) == 0x451)) { handle_ncp(&s_addr, &d_addr, buf + sizeof(struct ipx_packet), length - sizeof(struct ipx_packet), no); - } - else /* next 3 handle IPX by type vs by socket (one or other) */ - /* Note: most things use either ipx_type OR socket, not both */ - if (h->ipx_type == 0x01) + } else + /* next 3 handle IPX by type vs by socket (one or other) */ + /* Note: most things use either ipx_type OR socket, not both */ if (h->ipx_type == 0x01) printf(" type 0x01 (RIP packet (router))\n"); - else - if (h->ipx_type == 0x05) + else if (h->ipx_type == 0x05) printf(" type 0x05 (SPX sequenced packet)\n"); - else - if (h->ipx_type == 0x14) + else if (h->ipx_type == 0x14) printf(" type 0x14 (propogated Client-NetBios)\n"); else { hbo_dsock = ntohs(d_addr.sipx_port); - if (hbo_dsock == 0x452) /* SAP */ + if (hbo_dsock == 0x452) /* SAP */ { sappacket = (union sap_packet *) - (buf + sizeof(struct ipx_packet)); + (buf + sizeof(struct ipx_packet)); hbo_sapop = ntohs(sappacket->sapOperation); if ((hbo_sapop == 0x01) || (hbo_sapop == 0x03)) { printf(" type 0x%x, SAP op:0x%x %s Query, " "serverType 0x%x wanted\n", h->ipx_type, hbo_sapop, - (hbo_sapop == 0x01)?"General Service" : - (hbo_sapop == 0x03)?"Nearest Server" : + (hbo_sapop == 0x01) ? "General Service" : + (hbo_sapop == 0x03) ? "Nearest Server" : "Error", ntohs(sappacket->query.serverType)); - } - else + } else { int hops; @@ -238,12 +243,12 @@ handle_ipx (unsigned char *buf, int length, char *frame, int no) ? "General Service Response" : (hbo_sapop == 0x04) ? "Nearest Server Response" : - "Unknown", + "Unknown", (hops >= SAP_SHUTDOWN) ? "[Shutdown]" : ""); /* Service ending */ - if (hops >= SAP_SHUTDOWN) + if (hops >= SAP_SHUTDOWN) { print_sap(stdout, sappacket->response.sap); @@ -251,80 +256,80 @@ handle_ipx (unsigned char *buf, int length, char *frame, int no) #ifdef DUMPALLSAPS /* If you want to dump all SAP's */ else - { int num_saps; - SAPS *sapp; + { + int num_saps; + SAPS *sapp; num_saps = (length - sizeof(struct ipx_packet) - 2) / sizeof(SAPS); sapp = sappacket->response.sap; - for(; num_saps > 0; sapp++, num_saps--) + for (; num_saps > 0; sapp++, num_saps--) print_sap(stdout, sapp); } -#endif /* DUMPALLSAPS */ +#endif /* DUMPALLSAPS */ } - } - else /* Other IPX types */ - printf(" type 0x%x, Socket 0x%x (%s)\n", h->ipx_type, - hbo_dsock, - (hbo_dsock == 0x451) ? "NCP" : -/* (hbo_dsock == 0x452) ? "SAP" :*/ - (hbo_dsock == 0x453) ? "RIP" : - (hbo_dsock == 0x455) ? "Client-NetBios" : - (hbo_dsock == 0x456) ? "Diags" : - (hbo_dsock == 0x002) ? "Xecho" : - (hbo_dsock == 0x8063) ? "NVT2" : "Other"); + } else /* Other IPX types */ + printf(" type 0x%x, Socket 0x%x (%s)\n", h->ipx_type, + hbo_dsock, + (hbo_dsock == 0x451) ? "NCP" : +/* (hbo_dsock == 0x452) ? "SAP" : */ + (hbo_dsock == 0x453) ? "RIP" : + (hbo_dsock == 0x455) ? "Client-NetBios" : + (hbo_dsock == 0x456) ? "Diags" : + (hbo_dsock == 0x002) ? "Xecho" : + (hbo_dsock == 0x8063) ? "NVT2" : "Other"); } - + } -int handle_burst(struct sockaddr_ipx *source, - struct sockaddr_ipx *target, - unsigned char *buf, int length, int no) +int +handle_burst(struct sockaddr_ipx *source, + struct sockaddr_ipx *target, + unsigned char *buf, int length, int no) { - struct ncp_burst_header *rq = (struct ncp_burst_header *)buf; + struct ncp_burst_header *rq = (struct ncp_burst_header *) buf; if (rq->type != NCP_BURST_PACKET) { return 0; } - printf("Burst Packet\n"); printf("Stream Type: %02X, System Flags: %02X\n", rq->stream_type, rq->system_flags); printf("Source Conn: %08X, Dest Conn: %08X, Packet Seq: %08X\n", rq->source_conn, rq->dest_conn, - (unsigned int)ntohl(rq->packet_sequence)); + (unsigned int) ntohl(rq->packet_sequence)); printf("Send Delay: %08X, Burst Seq: %04X, Ack Seq: %04X\n", - (unsigned int)ntohl(rq->send_delay), ntohs(rq->burst_sequence), + (unsigned int) ntohl(rq->send_delay), ntohs(rq->burst_sequence), ntohs(rq->ack_sequence)); - printf("Burst Length: %08X\n", (unsigned int)ntohl(rq->burst_length)); + printf("Burst Length: %08X\n", (unsigned int) ntohl(rq->burst_length)); printf("Data Offset: %08X, Data Bytes: %04X, Missing Frags: %04X\n", - (unsigned int)ntohl(rq->data_offset), ntohs(rq->data_bytes), + (unsigned int) ntohl(rq->data_offset), ntohs(rq->data_bytes), ntohs(rq->missing_frags)); if (ntohs(rq->data_bytes) == 24) { struct ncp_burst_request { - struct ncp_burst_header h __attribute__ ((packed)); - __u32 function __attribute__ ((packed)); - __u32 file_handle __attribute__ ((packed)); - __u8 reserved[8] __attribute__ ((packed)); - __u32 file_offset __attribute__ ((packed)); - __u32 number_of_bytes __attribute__ ((packed)); - } *brq = (struct ncp_burst_request *)rq; + struct ncp_burst_header h __attribute__((packed)); + __u32 function __attribute__((packed)); + __u32 file_handle __attribute__((packed)); + __u8 reserved[8] __attribute__((packed)); + __u32 file_offset __attribute__((packed)); + __u32 number_of_bytes __attribute__((packed)); + } + *brq = (struct ncp_burst_request *) rq; printf("Assuming Burst Request:\n"); printf("%s: Handle %08X, Offset %08X, Bytes %08X\n", brq->function == 1 ? "Read " : "Write", brq->file_handle, - (unsigned int)ntohl(brq->file_offset), - (unsigned int)ntohl(brq->number_of_bytes)); + (unsigned int) ntohl(brq->file_offset), + (unsigned int) ntohl(brq->number_of_bytes)); } - printf("\n"); return 1; } @@ -334,8 +339,8 @@ handle_ncp(struct sockaddr_ipx *source, struct sockaddr_ipx *target, unsigned char *buf, int length, int no) { - struct ncp_request_header *rq = (struct ncp_request_header *)buf; - struct ncp_reply_header *rs = (struct ncp_reply_header *)buf; + struct ncp_request_header *rq = (struct ncp_request_header *) buf; + struct ncp_reply_header *rs = (struct ncp_reply_header *) buf; unsigned char *data = NULL; int data_length = 0; int i; @@ -353,12 +358,12 @@ handle_ncp(struct sockaddr_ipx *source, memcpy(&request_source, source, sizeof(request_source)); memcpy(&request_header, rq, sizeof(request_header)); - memcpy(request_data, rq+1, sizeof(request_data)); + memcpy(request_data, rq + 1, sizeof(request_data)); data = buf + sizeof(struct ncp_request_header); data_length = length - sizeof(struct ncp_request_header); - switch(rq->function) + switch (rq->function) { case 18: printf("fn: %-3d\n", rq->function); @@ -371,7 +376,7 @@ handle_ncp(struct sockaddr_ipx *source, case 21: printf("fn: %-3d, subfn: %-3d\n", rq->function, data[2]); - switch(data[2]) + switch (data[2]) { case 0: printf("Send Broadcast Message\n"); @@ -386,7 +391,7 @@ handle_ncp(struct sockaddr_ipx *source, case 22: printf("fn: %-3d, subfn: %-3d\n", rq->function, data[2]); - switch(data[2]) + switch (data[2]) { case 00: printf("Set Directory Handle\n"); @@ -431,7 +436,7 @@ handle_ncp(struct sockaddr_ipx *source, case 23: printf("fn: %-3d, subfn: %-3d\n", rq->function, data[2]); - switch(data[2]) + switch (data[2]) { case 17: printf("Get Fileserver Information\n"); @@ -497,7 +502,7 @@ handle_ncp(struct sockaddr_ipx *source, printf("Service Queue Job \n"); break; } - + data += 3; data_length -= 3; break; @@ -551,26 +556,26 @@ handle_ncp(struct sockaddr_ipx *source, printf("fn: %-3d\n", rq->function); printf("Open File (old)\n"); break; - + case 87: printf("fn: %-3d, subfn: %-3d\n", rq->function, data[0]); - switch(data[0]) + switch (data[0]) { case 1: - { - unsigned char *p = &(data[0]); - printf("Open Create File or Subdirectory\n"); - printf("Name Space: %d\n", p[1]); - printf("Open Create Mode: %x\n", p[2]); - printf("Search Attributes: %x\n", - *(__u16 *)&(p[3])); - printf("Return Information Mask: %x\n", - (unsigned int)(*(__u32 *)&(p[5]))); - printf("Desired Access Rights: %x\n", - *(__u16 *)&(p[9])); - break; - } + { + unsigned char *p = &(data[0]); + printf("Open Create File or Subdirectory\n"); + printf("Name Space: %d\n", p[1]); + printf("Open Create Mode: %x\n", p[2]); + printf("Search Attributes: %x\n", + *(__u16 *) & (p[3])); + printf("Return Information Mask: %x\n", + (unsigned int) (*(__u32 *) & (p[5]))); + printf("Desired Access Rights: %x\n", + *(__u16 *) & (p[9])); + break; + } case 2: printf("Initialize Search\n"); break; @@ -592,348 +597,350 @@ handle_ncp(struct sockaddr_ipx *source, data_length -= 1; break; case 97: - { - struct INPUT - { - __u16 proposed_max_size; - __u8 security_flag; - } *i = (struct INPUT *)data; - - printf("fn: %-3d\n", rq->function); - printf("Get Big Packet NCP Max Packet Size\n"); - printf("proposed_max_size: %x\n", - ntohs(i->proposed_max_size)); - printf("security_flag: %x\n", - i->security_flag); - break; - } - case 101: - { - struct INPUT - { - __u32 local_conn_id; - __u32 local_max_packet_size; - __u16 local_target_socket; - __u32 local_max_send_size; - __u32 local_max_recv_size; - } *i = (struct INPUT *)data; - - printf("fn: %-3d\n", rq->function); - printf("Packet Burst Connection Request\n"); - printf("local_conn_id: %lx\n", - ntohl(i->local_conn_id)); - printf("local_max_packet_size: %lx\n", - ntohl(i->local_max_packet_size)); - printf("local_target_socket: %lx\n", - ntohl(i->local_target_socket)); - printf("local_max_send_size: %lx\n", - ntohl(i->local_max_send_size)); - printf("local_max_recv_size: %lx\n", - ntohl(i->local_max_recv_size)); - } - break; - case 104: - { - printf("fn: %-3d, subfn: %-3d, NDS call\n", - rq->function, data[0]); - - /* I took this information from the (german!!) - book 'Einf"uhrung in die NetWare LAN - Analyse', Laura A. Chappell, Dan E. Hakes, - Novell Press, Markt & Technik, ISBN - 3-8272-5084-6, and from the book mentioned - in the ncpfs README. I'm not sure it is - correct, because I do not have NW 4.x. If - you have the time, could you watch a NW4 - workstation, and tell me whether anything - of this makes sense at all. */ - - switch(data[0]) - { - case 1: - printf("Ping for NDS\n"); - break; - case 2: { struct INPUT { - __u8 subfunction_code; - __u32 fragger_handle; - __u32 max_fragment_size; - __u32 message_size; - __u32 fragment_flag; - __u32 verb; - } *i = (struct INPUT *)data; - printf("Send NDS Fragment Request/Reply\n"); - printf("fragger_handle: %lx\n", - (unsigned long)i->fragger_handle); - printf("max_fragment_size: %lx\n", - (unsigned long)i->max_fragment_size); - printf("message_size: %lx\n", - (unsigned long)i->message_size); - printf("fragment_flag: %lx\n", - (unsigned long)i->fragment_flag); - printf("verb: %d\n", i->verb); + __u16 proposed_max_size; + __u8 security_flag; + } + *i = (struct INPUT *) data; - switch (i->verb) + printf("fn: %-3d\n", rq->function); + printf("Get Big Packet NCP Max Packet Size\n"); + printf("proposed_max_size: %x\n", + ntohs(i->proposed_max_size)); + printf("security_flag: %x\n", + i->security_flag); + break; + } + case 101: + { + struct INPUT + { + __u32 local_conn_id; + __u32 local_max_packet_size; + __u16 local_target_socket; + __u32 local_max_send_size; + __u32 local_max_recv_size; + } + *i = (struct INPUT *) data; + + printf("fn: %-3d\n", rq->function); + printf("Packet Burst Connection Request\n"); + printf("local_conn_id: %lx\n", + ntohl(i->local_conn_id)); + printf("local_max_packet_size: %lx\n", + ntohl(i->local_max_packet_size)); + printf("local_target_socket: %lx\n", + ntohl(i->local_target_socket)); + printf("local_max_send_size: %lx\n", + ntohl(i->local_max_send_size)); + printf("local_max_recv_size: %lx\n", + ntohl(i->local_max_recv_size)); + } + break; + case 104: + { + printf("fn: %-3d, subfn: %-3d, NDS call\n", + rq->function, data[0]); + + /* I took this information from the (german!!) + book 'Einf"uhrung in die NetWare LAN + Analyse', Laura A. Chappell, Dan E. Hakes, + Novell Press, Markt & Technik, ISBN + 3-8272-5084-6, and from the book mentioned + in the ncpfs README. I'm not sure it is + correct, because I do not have NW 4.x. If + you have the time, could you watch a NW4 + workstation, and tell me whether anything + of this makes sense at all. */ + + switch (data[0]) { case 1: - printf("Resolve Name\n"); + printf("Ping for NDS\n"); break; case 2: - printf("Read Entry Information\n"); - break; + { + struct INPUT + { + __u8 subfunction_code; + __u32 fragger_handle; + __u32 max_fragment_size; + __u32 message_size; + __u32 fragment_flag; + __u32 verb; + } + *i = (struct INPUT *) data; + printf("Send NDS Fragment Request/Reply\n"); + printf("fragger_handle: %lx\n", + (unsigned long) i->fragger_handle); + printf("max_fragment_size: %lx\n", + (unsigned long) i->max_fragment_size); + printf("message_size: %lx\n", + (unsigned long) i->message_size); + printf("fragment_flag: %lx\n", + (unsigned long) i->fragment_flag); + printf("verb: %d\n", i->verb); + + switch (i->verb) + { + case 1: + printf("Resolve Name\n"); + break; + case 2: + printf("Read Entry Information\n"); + break; + case 3: + printf("Read\n"); + break; + case 4: + printf("Compare\n"); + break; + case 5: + printf("List\n"); + break; + case 6: + printf("Search Entries\n"); + break; + case 7: + printf("Add Entry\n"); + break; + case 8: + printf("Remove Entry\n"); + break; + case 9: + printf("Modify Entry\n"); + break; + case 10: + printf("Modify RDN\n"); + break; + case 11: + printf("Create Attribute\n"); + break; + case 12: + printf("Read Attribute Definition\n"); + break; + case 13: + printf("Remove Attribute Definition\n"); + break; + case 14: + printf("Define Class\n"); + break; + case 15: + printf("Read Class Definition\n"); + break; + case 16: + printf("Modify Class Definition\n"); + break; + case 17: + printf("Remove Class Definition\n"); + break; + case 18: + printf("List Containable Classes\n"); + break; + case 19: + printf("Get Effective Rights\n"); + break; + case 20: + printf("Add Partition\n"); + break; + case 21: + printf("Remove Partition\n"); + break; + case 22: + printf("List Partitions\n"); + break; + case 23: + printf("Split Partition\n"); + break; + case 24: + printf("Join Partitions\n"); + break; + case 25: + printf("Add Replica\n"); + break; + case 26: + printf("Remove Replica\n"); + break; + case 27: + printf("Open Stream\n"); + break; + case 28: + printf("Search Filter\n"); + break; + case 29: + printf("Create Subordinate Reference\n"); + break; + case 30: + printf("Link Replica\n"); + break; + case 31: + printf("Change Replica Type\n"); + break; + case 32: + printf("Start Update Schema\n"); + break; + case 33: + printf("End Update Schema\n"); + break; + case 34: + printf("Update Schema\n"); + break; + case 35: + printf("Start Update Replica\n"); + break; + case 36: + printf("End Update Replica\n"); + break; + case 37: + printf("Update Replica\n"); + break; + case 38: + printf("Synchronize Partition\n"); + break; + case 39: + printf("Synchronize Schema\n"); + break; + case 40: + printf("Read Syntaxes\n"); + break; + case 41: + printf("Get Replica Root ID\n"); + break; + case 42: + printf("Begin Move Entry\n"); + break; + case 43: + printf("Finish Move Entry\n"); + break; + case 44: + printf("Release Moved Entry\n"); + break; + case 45: + printf("Backup Entry\n"); + break; + case 46: + printf("Restore Entry\n"); + break; + case 47: + printf("Save DIB\n"); + break; + case 48: + case 49: + printf("Unused\n"); + break; + case 50: + printf("Close Iteration\n"); + break; + case 51: + printf("Unused\n"); + break; + case 52: + printf("Audit Skulking\n"); + break; + case 53: + printf("Get Server Address\n"); + break; + case 54: + printf("Set Keys\n"); + break; + case 55: + printf("Change Password\n"); + break; + case 56: + printf("Verify Password\n"); + break; + case 57: + printf("Begin Login\n"); + break; + case 58: + printf("Finish Login\n"); + break; + case 59: + printf("Begin Authentication\n"); + break; + case 60: + printf("Finish Authentication\n"); + break; + case 61: + printf("Logout\n"); + break; + case 62: + printf("Repair Ring\n"); + break; + case 63: + printf("Repair Timestamps\n"); + break; + case 64: + printf("Create Back Link\n"); + break; + case 65: + printf("Delete External Reference\n"); + break; + case 66: + printf("Rename External Reference\n"); + break; + case 67: + printf("Create Directory Entry\n"); + break; + case 68: + printf("Remove Directory Entry\n"); + break; + case 69: + printf("Designate New Master\n"); + break; + case 70: + printf("Change Tree Name\n"); + break; + case 71: + printf("Partition Entry Count\n"); + break; + case 72: + printf("Check Login Restrictions\n"); + break; + case 73: + printf("Start Join\n"); + break; + case 74: + printf("Low Level Split\n"); + break; + case 75: + printf("Low Level Join\n"); + break; + case 76: + printf("Abort Low Level Join\n"); + break; + case 77: + printf("Get All Servers\n"); + break; + default: + printf("Unknown Verb: %d\n", + data[0]); + break; + } + break; + } case 3: - printf("Read\n"); + printf("Close NDS Fragment\n"); break; case 4: - printf("Compare\n"); + printf("Return Bindery Context\n"); break; case 5: - printf("List\n"); + printf("Monitor NDS connection\n"); break; - case 6: - printf("Search Entries\n"); - break; - case 7: - printf("Add Entry\n"); - break; - case 8: - printf("Remove Entry\n"); - break; - case 9: - printf("Modify Entry\n"); - break; - case 10: - printf("Modify RDN\n"); - break; - case 11: - printf("Create Attribute\n"); - break; - case 12: - printf("Read Attribute Definition\n"); - break; - case 13: - printf("Remove Attribute Definition\n"); - break; - case 14: - printf("Define Class\n"); - break; - case 15: - printf("Read Class Definition\n"); - break; - case 16: - printf("Modify Class Definition\n"); - break; - case 17: - printf("Remove Class Definition\n"); - break; - case 18: - printf("List Containable Classes\n"); - break; - case 19: - printf("Get Effective Rights\n"); - break; - case 20: - printf("Add Partition\n"); - break; - case 21: - printf("Remove Partition\n"); - break; - case 22: - printf("List Partitions\n"); - break; - case 23: - printf("Split Partition\n"); - break; - case 24: - printf("Join Partitions\n"); - break; - case 25: - printf("Add Replica\n"); - break; - case 26: - printf("Remove Replica\n"); - break; - case 27: - printf("Open Stream\n"); - break; - case 28: - printf("Search Filter\n"); - break; - case 29: - printf("Create Subordinate Reference\n"); - break; - case 30: - printf("Link Replica\n"); - break; - case 31: - printf("Change Replica Type\n"); - break; - case 32: - printf("Start Update Schema\n"); - break; - case 33: - printf("End Update Schema\n"); - break; - case 34: - printf("Update Schema\n"); - break; - case 35: - printf("Start Update Replica\n"); - break; - case 36: - printf("End Update Replica\n"); - break; - case 37: - printf("Update Replica\n"); - break; - case 38: - printf("Synchronize Partition\n"); - break; - case 39: - printf("Synchronize Schema\n"); - break; - case 40: - printf("Read Syntaxes\n"); - break; - case 41: - printf("Get Replica Root ID\n"); - break; - case 42: - printf("Begin Move Entry\n"); - break; - case 43: - printf("Finish Move Entry\n"); - break; - case 44: - printf("Release Moved Entry\n"); - break; - case 45: - printf("Backup Entry\n"); - break; - case 46: - printf("Restore Entry\n"); - break; - case 47: - printf("Save DIB\n"); - break; - case 48: - case 49: - printf("Unused\n"); - break; - case 50: - printf("Close Iteration\n"); - break; - case 51: - printf("Unused\n"); - break; - case 52: - printf("Audit Skulking\n"); - break; - case 53: - printf("Get Server Address\n"); - break; - case 54: - printf("Set Keys\n"); - break; - case 55: - printf("Change Password\n"); - break; - case 56: - printf("Verify Password\n"); - break; - case 57: - printf("Begin Login\n"); - break; - case 58: - printf("Finish Login\n"); - break; - case 59: - printf("Begin Authentication\n"); - break; - case 60: - printf("Finish Authentication\n"); - break; - case 61: - printf("Logout\n"); - break; - case 62: - printf("Repair Ring\n"); - break; - case 63: - printf("Repair Timestamps\n"); - break; - case 64: - printf("Create Back Link\n"); - break; - case 65: - printf("Delete External Reference\n"); - break; - case 66: - printf("Rename External Reference\n"); - break; - case 67: - printf("Create Directory Entry\n"); - break; - case 68: - printf("Remove Directory Entry\n"); - break; - case 69: - printf("Designate New Master\n"); - break; - case 70: - printf("Change Tree Name\n"); - break; - case 71: - printf("Partition Entry Count\n"); - break; - case 72: - printf("Check Login Restrictions\n"); - break; - case 73: - printf("Start Join\n"); - break; - case 74: - printf("Low Level Split\n"); - break; - case 75: - printf("Low Level Join\n"); - break; - case 76: - printf("Abort Low Level Join\n"); - break; - case 77: - printf("Get All Servers\n"); + case 200: + printf("NDS Auditing\n"); break; default: - printf("Unknown Verb: %d\n", - data[0]); break; } - break; } - case 3: - printf("Close NDS Fragment\n"); - break; - case 4: - printf("Return Bindery Context\n"); - break; - case 5: - printf("Monitor NDS connection\n"); - break; - case 200: - printf("NDS Auditing\n"); - break; - default: - break; - } - } default: printf("fn: %-3d\n", rq->function); } } - if (ntohs(rs->type) == NCP_REPLY) { printf("NCP respons: conn: %-5d, seq: %-3d, task: %-3d, ", @@ -945,8 +952,8 @@ handle_ncp(struct sockaddr_ipx *source, data = buf + sizeof(struct ncp_reply_header); data_length = length - sizeof(struct ncp_reply_header); - if ( (memcmp(&request_source, target, - sizeof(request_source)) == 0) + if ((memcmp(&request_source, target, + sizeof(request_source)) == 0) && (request_header.sequence == rs->sequence)) { switch (request_header.function) @@ -955,17 +962,18 @@ handle_ncp(struct sockaddr_ipx *source, switch (request_data[2]) { case 18: - { - struct XDATA { - __u8 new_directory_handle; - __u8 access_rights_mask; - } *x = (struct XDATA *)data; - printf("new_directory_handle: %x\n", - x->new_directory_handle); - printf("access_rights_mask: %x\n", - x->access_rights_mask); - } + struct XDATA + { + __u8 new_directory_handle; + __u8 access_rights_mask; + } + *x = (struct XDATA *) data; + printf("new_directory_handle: %x\n", + x->new_directory_handle); + printf("access_rights_mask: %x\n", + x->access_rights_mask); + } break; } break; @@ -974,65 +982,63 @@ handle_ncp(struct sockaddr_ipx *source, data_length = 0; break; case 97: - { - struct XDATA { - __u16 accepted_max_size; - __u16 echo_socket; - __u8 security_flag; - } *x = (struct XDATA *)data; - printf("accepted_max_size: %x\n", - ntohs(x->accepted_max_size)); - printf("echo_socket: %x\n", - ntohs(x->echo_socket)); - printf("security_flag: %x\n", - (x->security_flag)); - } + struct XDATA + { + __u16 accepted_max_size; + __u16 echo_socket; + __u8 security_flag; + } + *x = (struct XDATA *) data; + printf("accepted_max_size: %x\n", + ntohs(x->accepted_max_size)); + printf("echo_socket: %x\n", + ntohs(x->echo_socket)); + printf("security_flag: %x\n", + (x->security_flag)); + } break; case 101: - { - struct XDATA { - __u8 completion_code; - __u32 remote_target_id; - __u32 remote_max_packet_size; - } *x = (struct XDATA *)data; - printf("completion_code: %x\n", - x->completion_code); - printf("remote_target_id: %lx\n", - ntohl(x->remote_target_id)); - printf("remote_max_packet_size: %lx\n", - ntohl(x->remote_max_packet_size)); - } + struct XDATA + { + __u8 completion_code; + __u32 remote_target_id; + __u32 remote_max_packet_size; + } + *x = (struct XDATA *) data; + printf("completion_code: %x\n", + x->completion_code); + printf("remote_target_id: %lx\n", + ntohl(x->remote_target_id)); + printf("remote_max_packet_size: %lx\n", + ntohl(x->remote_max_packet_size)); + } break; } } - } - if (data == NULL) { data = buf; data_length = length; } - i = 0; while (i < data_length) { int j; - for (j = i; j < i+16; j++) + for (j = i; j < i + 16; j++) { if (j >= data_length) { printf(" "); - } - else + } else { printf("%-2.2X", data[j]); } } printf(" "); - for (j = i; j < i+16; j++) + for (j = i; j < i + 16; j++) { if (j >= data_length) { @@ -1041,8 +1047,7 @@ handle_ncp(struct sockaddr_ipx *source, if (isprint(data[j])) { printf("%c", data[j]); - } - else + } else { printf("."); } @@ -1055,7 +1060,7 @@ handle_ncp(struct sockaddr_ipx *source, void -main (int argc, char *argv[]) +main(int argc, char *argv[]) { unsigned char buf[16384]; unsigned char packet[8192]; @@ -1065,19 +1070,17 @@ main (int argc, char *argv[]) while (fgets(buf, sizeof(buf), stdin) != NULL) { - if (strlen(buf) == sizeof(buf)-1) + if (strlen(buf) == sizeof(buf) - 1) { fprintf(stderr, "line too long\n"); exit(1); } - b = strchr(buf, ' '); if (b == NULL) { fprintf(stderr, "illegal line format\n"); exit(1); } - *b = '\0'; b += 1; len = 0; @@ -1097,6 +1100,6 @@ main (int argc, char *argv[]) handle_ipx(packet, len, buf, i); i += 1; } - - exit (0); + + exit(0); } diff --git a/ipxdump/ipxutil.c b/ipxdump/ipxutil.c index 215e0d5..7fe5c4c 100644 --- a/ipxdump/ipxutil.c +++ b/ipxdump/ipxutil.c @@ -1,97 +1,101 @@ + + + + /* - IPX support library - general functions + IPX support library - general functions - Copyright (C) 1994, 1995 Ales Dryak - Copyright (C) 1996, Volker Lendecke + Copyright (C) 1994, 1995 Ales Dryak + Copyright (C) 1996, Volker Lendecke - 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 #include #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"; diff --git a/ipxdump/ipxutil.h b/ipxdump/ipxutil.h index b5588ff..e259a58 100644 --- a/ipxdump/ipxutil.h +++ b/ipxdump/ipxutil.h @@ -1,25 +1,25 @@ /* - IPX support library + IPX support library - Copyright (C) 1994, 1995 Ales Dryak - Copyright (C) 1996, Volker Lendecke + Copyright (C) 1994, 1995 Ales Dryak + Copyright (C) 1996, Volker Lendecke - 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 diff --git a/kernel-1.2/linux/ncp.h b/kernel-1.2/linux/ncp.h index 3d5286e..88d9261 100644 --- a/kernel-1.2/linux/ncp.h +++ b/kernel-1.2/linux/ncp.h @@ -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 */ diff --git a/kernel-1.2/linux/ncp_fs.h b/kernel-1.2/linux/ncp_fs.h index 309ec11..116b289 100644 --- a/kernel-1.2/linux/ncp_fs.h +++ b/kernel-1.2/linux/ncp_fs.h @@ -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 */ diff --git a/kernel-1.2/linux/ncp_fs_i.h b/kernel-1.2/linux/ncp_fs_i.h index c0ab3da..b36821f 100644 --- a/kernel-1.2/linux/ncp_fs_i.h +++ b/kernel-1.2/linux/ncp_fs_i.h @@ -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; }; diff --git a/kernel-1.2/linux/ncp_fs_sb.h b/kernel-1.2/linux/ncp_fs_sb.h index 36fd36b..ccdff2a 100644 --- a/kernel-1.2/linux/ncp_fs_sb.h +++ b/kernel-1.2/linux/ncp_fs_sb.h @@ -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 diff --git a/kernel-1.2/linux/ncp_mount.h b/kernel-1.2/linux/ncp_mount.h index cbc58aa..9399a41 100644 --- a/kernel-1.2/linux/ncp_mount.h +++ b/kernel-1.2/linux/ncp_mount.h @@ -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 diff --git a/kernel-1.2/src/dir.c b/kernel-1.2/src/dir.c index 56f86e0..781af52 100644 --- a/kernel-1.2/src/dir.c +++ b/kernel-1.2/src/dir.c @@ -23,53 +23,54 @@ #include #include "ncplib_kernel.h" -struct ncp_dirent { +struct ncp_dirent +{ struct nw_info_struct i; - struct nw_search_sequence s; /* given back for i */ + struct nw_search_sequence s; /* given back for i */ unsigned long f_pos; }; -static int -ncp_dir_read(struct inode *inode, struct file *filp, char *buf, int count); - -static int -ncp_readdir(struct inode *inode, struct file *filp, - struct dirent *dirent, int count); +static int + ncp_dir_read(struct inode *inode, struct file *filp, char *buf, int count); static int -ncp_read_volume_list(struct ncp_server *server, int start_with, - int cache_size); + ncp_readdir(struct inode *inode, struct file *filp, + struct dirent *dirent, int count); static int -ncp_do_readdir(struct ncp_server *server, struct inode *dir, int fpos, - int cache_size, struct ncp_dirent *entry); + ncp_read_volume_list(struct ncp_server *server, int start_with, + int cache_size); + +static int + ncp_do_readdir(struct ncp_server *server, struct inode *dir, int fpos, + int cache_size, struct ncp_dirent *entry); static struct inode * -ncp_iget(struct inode *dir, struct nw_file_info *finfo); + ncp_iget(struct inode *dir, struct nw_file_info *finfo); static struct ncp_inode_info * -ncp_find_dir_inode(struct inode *dir, const char *name); + ncp_find_dir_inode(struct inode *dir, const char *name); static int -ncp_lookup(struct inode *dir, const char *__name, - int len, struct inode **result); - -static int -ncp_create(struct inode *dir, const char *name, int len, int mode, - struct inode **result); - -static int -ncp_mkdir(struct inode *dir, const char *name, int len, int mode); - -static int -ncp_rmdir(struct inode *dir, const char *name, int len); + ncp_lookup(struct inode *dir, const char *__name, + int len, struct inode **result); static int -ncp_unlink(struct inode *dir, const char *name, int len); + ncp_create(struct inode *dir, const char *name, int len, int mode, + struct inode **result); static int -ncp_rename(struct inode *old_dir, const char *old_name, int old_len, - struct inode *new_dir, const char *new_name, int new_len); + ncp_mkdir(struct inode *dir, const char *name, int len, int mode); + +static int + ncp_rmdir(struct inode *dir, const char *name, int len); + +static int + ncp_unlink(struct inode *dir, const char *name, int len); + +static int + ncp_rename(struct inode *old_dir, const char *old_name, int old_len, + struct inode *new_dir, const char *new_name, int new_len); static inline void str_upper(char *name) @@ -93,14 +94,14 @@ str_lower(char *name) { *name += ('a' - 'A'); } - name ++; + name++; } } static inline int ncp_namespace(struct inode *i) { - struct ncp_server *server = NCP_SERVER(i); + struct ncp_server *server = NCP_SERVER(i); struct nw_info_struct *info = NCP_ISTRUCT(i); return server->name_space[info->volNumber]; } @@ -111,8 +112,9 @@ ncp_preserve_case(struct inode *i) return (ncp_namespace(i) == NW_NS_OS2); } -static struct file_operations ncp_dir_operations = { - NULL, /* lseek - default */ +static struct file_operations ncp_dir_operations = +{ + NULL, /* lseek - default */ ncp_dir_read, /* read - bad */ NULL, /* write - bad */ ncp_readdir, /* readdir */ @@ -124,23 +126,24 @@ static struct file_operations ncp_dir_operations = { NULL /* fsync */ }; -struct inode_operations ncp_dir_inode_operations = { +struct inode_operations ncp_dir_inode_operations = +{ &ncp_dir_operations, /* default directory file ops */ ncp_create, /* create */ - ncp_lookup, /* lookup */ + ncp_lookup, /* lookup */ NULL, /* link */ - ncp_unlink, /* unlink */ + ncp_unlink, /* unlink */ NULL, /* symlink */ - ncp_mkdir, /* mkdir */ - ncp_rmdir, /* rmdir */ + ncp_mkdir, /* mkdir */ + ncp_rmdir, /* rmdir */ NULL, /* mknod */ - ncp_rename, /* rename */ + ncp_rename, /* rename */ NULL, /* readlink */ NULL, /* follow_link */ NULL, /* bmap */ NULL, /* truncate */ NULL, /* permission */ - NULL /* smap */ + NULL /* smap */ }; @@ -159,10 +162,10 @@ ncp_single_volume(struct ncp_server *server) } inline ino_t -ncp_info_ino(struct ncp_server *server, struct ncp_inode_info *info) +ncp_info_ino(struct ncp_server * server, struct ncp_inode_info * info) { return ncp_single_volume(server) - ? info->finfo.i.dirEntNum : (ino_t)info; + ? info->finfo.i.dirEntNum : (ino_t) info; } static inline int @@ -170,7 +173,7 @@ ncp_is_server_root(struct inode *inode) { struct ncp_server *s = NCP_SERVER(inode); - return ( (!ncp_single_volume(s)) + return ((!ncp_single_volume(s)) && (inode->i_ino == ncp_info_ino(s, &(s->root)))); } @@ -178,25 +181,25 @@ struct ncp_inode_info * ncp_find_inode(struct inode *inode) { struct ncp_server *server = NCP_SERVER(inode); - struct ncp_inode_info *root = &(server->root); - struct ncp_inode_info *this = root; + struct ncp_inode_info *root = &(server->root); + struct ncp_inode_info *this = root; ino_t ino = inode->i_ino; - do + do { - if (ino == ncp_info_ino(server, this)) + if (ino == ncp_info_ino(server, this)) { return this; } this = this->next; - } + } while (this != root); return NULL; } -static int +static int ncp_dir_read(struct inode *inode, struct file *filp, char *buf, int count) { return -EISDIR; @@ -209,13 +212,13 @@ ncp_dir_read(struct inode *inode, struct file *filp, char *buf, int count) all inodes that are in memory. That's why it's enough to index the directory cache by the inode number. */ -static int c_dev = 0; -static unsigned long c_ino = 0; -static int c_size; -static int c_seen_eof; -static int c_last_returned_index; -static struct ncp_dirent* c_entry = NULL; -static int c_lock = 0; +static int c_dev = 0; +static unsigned long c_ino = 0; +static int c_size; +static int c_seen_eof; +static int c_last_returned_index; +static struct ncp_dirent *c_entry = NULL; +static int c_lock = 0; static struct wait_queue *c_wait = NULL; static inline void @@ -239,9 +242,9 @@ ncp_readdir(struct inode *inode, struct file *filp, { int result = 0; int i = 0; - int index = 0; + int index = 0; struct ncp_dirent *entry = NULL; - struct ncp_server *server = NCP_SERVER(inode); + struct ncp_server *server = NCP_SERVER(inode); struct ncp_inode_info *dir = NCP_INOP(inode); int filldir(struct dirent *dirent, @@ -256,7 +259,7 @@ ncp_readdir(struct inode *inode, struct file *filp, return 1; } - DPRINTK("ncp_readdir: filp->f_pos = %d\n", (int)filp->f_pos); + DPRINTK("ncp_readdir: filp->f_pos = %d\n", (int) filp->f_pos); DPRINTK("ncp_readdir: inode->i_ino = %ld, c_ino = %ld\n", inode->i_ino, c_ino); @@ -265,16 +268,14 @@ ncp_readdir(struct inode *inode, struct file *filp, printk("ncp_readdir: inode is NULL or not a directory\n"); return -EBADF; } - if (!ncp_conn_valid(server)) { return -EIO; } - ncp_lock_dircache(); - if (c_entry == NULL) + if (c_entry == NULL) { - i = sizeof (struct ncp_dirent) * NCP_READDIR_CACHE_SIZE; + i = sizeof(struct ncp_dirent) * NCP_READDIR_CACHE_SIZE; c_entry = (struct ncp_dirent *) ncp_kmalloc(i, GFP_KERNEL); if (c_entry == NULL) { @@ -283,50 +284,46 @@ ncp_readdir(struct inode *inode, struct file *filp, goto finished; } } - - if (filp->f_pos == 0) + if (filp->f_pos == 0) { - ncp_invalid_dir_cache(inode); - if (filldir(dirent,".",1, filp->f_pos, + ncp_invalid_dir_cache(inode); + if (filldir(dirent, ".", 1, filp->f_pos, ncp_info_ino(server, dir)) < 0) { goto finished; } filp->f_pos += 1; - result = ROUND_UP(NAME_OFFSET(dirent)+i+1); + result = ROUND_UP(NAME_OFFSET(dirent) + i + 1); goto finished; - } - + } if (filp->f_pos == 1) { - if (filldir(dirent,"..",2, filp->f_pos, + if (filldir(dirent, "..", 2, filp->f_pos, ncp_info_ino(server, dir->dir)) < 0) { goto finished; } filp->f_pos += 1; - result = ROUND_UP(NAME_OFFSET(dirent)+i+1); + result = ROUND_UP(NAME_OFFSET(dirent) + i + 1); goto finished; } - if ((inode->i_dev == c_dev) && (inode->i_ino == c_ino)) { for (i = 0; i < c_size; i++) { if (filp->f_pos == c_entry[i].f_pos) { - entry = &c_entry[i]; - c_last_returned_index = i; - index = i; - break; + entry = &c_entry[i]; + c_last_returned_index = i; + index = i; + break; } } - if ((entry == NULL) && c_seen_eof) + if ((entry == NULL) && c_seen_eof) { goto finished; } } - if (entry == NULL) { int entries; @@ -338,8 +335,7 @@ ncp_readdir(struct inode *inode, struct file *filp, NCP_READDIR_CACHE_SIZE); DPRINTK("ncp_read_volume_list returned %d\n", entries); - } - else + } else { entries = ncp_do_readdir(server, inode, filp->f_pos, NCP_READDIR_CACHE_SIZE, @@ -354,16 +350,15 @@ ncp_readdir(struct inode *inode, struct file *filp, result = entries; goto finished; } - if (entries > 0) { - c_seen_eof = (entries < NCP_READDIR_CACHE_SIZE); - c_dev = inode->i_dev; - c_ino = inode->i_ino; + c_seen_eof = (entries < NCP_READDIR_CACHE_SIZE); + c_dev = inode->i_dev; + c_ino = inode->i_ino; c_size = entries; entry = c_entry; - c_last_returned_index = 0; - index = 0; + c_last_returned_index = 0; + index = 0; if (!ncp_preserve_case(inode)) { @@ -374,27 +369,24 @@ ncp_readdir(struct inode *inode, struct file *filp, } } } - - if (entry == NULL) + if (entry == NULL) { - /* Nothing found, even from a ncp call */ + /* Nothing found, even from a ncp call */ goto finished; - } - - if (index < c_size) + } + if (index < c_size) { - /* We found it. For getwd(), we have to return the - correct inode in d_ino if the inode is currently in - use. Otherwise the inode number does not - matter. (You can argue a lot about this..) */ + /* We found it. For getwd(), we have to return the + correct inode in d_ino if the inode is currently in + use. Otherwise the inode number does not + matter. (You can argue a lot about this..) */ ino_t ino; if (ncp_single_volume(server)) { - ino = (ino_t)(entry->i.dirEntNum); - } - else + ino = (ino_t) (entry->i.dirEntNum); + } else { struct ncp_inode_info *ino_info; ino_info = ncp_find_dir_inode(inode, @@ -407,25 +399,24 @@ ncp_readdir(struct inode *inode, struct file *filp, { ino_info = (struct ncp_inode_info *) 1; } - ino = (ino_t)(ino_info); + ino = (ino_t) (ino_info); } DPRINTK("ncp_readdir: entry->path= %s\n", entry->i.entryName); DPRINTK("ncp_readdir: entry->f_pos = %ld\n", entry->f_pos); - if (filldir(dirent, entry->i.entryName, entry->i.nameLen, - entry->f_pos, ino) < 0) + if (filldir(dirent, entry->i.entryName, entry->i.nameLen, + entry->f_pos, ino) < 0) { goto finished; - } - - filp->f_pos += 1; - index += 1; - entry += 1; - result = ROUND_UP(NAME_OFFSET(dirent)+i+1); + } + filp->f_pos += 1; + index += 1; + entry += 1; + result = ROUND_UP(NAME_OFFSET(dirent) + i + 1); goto finished; } - finished: + finished: ncp_unlock_dircache(); return result; } @@ -446,7 +437,7 @@ ncp_read_volume_list(struct ncp_server *server, int fpos, int cache_size) } #endif - for (i=0; i 0) { if (total_count < fpos) { DPRINTK("ncp_read_volumes: skipped vol: %s\n", info.volume_name); - } - else if (total_count >= fpos + cache_size) + } else if (total_count >= fpos + cache_size) { return (total_count - fpos); - } - else + } else { DPRINTK("ncp_read_volumes: found vol: %s\n", info.volume_name); @@ -479,7 +467,6 @@ ncp_read_volume_list(struct ncp_server *server, int fpos, int cache_size) "%s\n", info.volume_name); continue; } - entry->f_pos = total_count; entry += 1; } @@ -511,7 +498,6 @@ ncp_do_readdir(struct ncp_server *server, struct inode *dir, int fpos, last_dir = NULL; total_count = 2; } - if ((fpos != total_count) || (dir != last_dir)) { total_count = 2; @@ -520,13 +506,12 @@ ncp_do_readdir(struct ncp_server *server, struct inode *dir, int fpos, DPRINTK("ncp_do_readdir: re-used seq for %s\n", NCP_ISTRUCT(dir)->entryName); - if (ncp_initialize_search(server, NCP_ISTRUCT(dir), &seq)!=0) + if (ncp_initialize_search(server, NCP_ISTRUCT(dir), &seq) != 0) { DPRINTK("ncp_init_search failed\n"); return total_count - fpos; } } - while (total_count < fpos + cache_size) { if (ncp_search_for_file_or_subdir(server, &seq, @@ -534,13 +519,11 @@ ncp_do_readdir(struct ncp_server *server, struct inode *dir, int fpos, { return total_count - fpos; } - if (total_count < fpos) { DPRINTK("ncp_do_readdir: skipped file: %s\n", entry->i.entryName); - } - else + } else { DDPRINTK("ncp_do_r: file: %s, f_pos=%d,total_count=%d", entry->i.entryName, fpos, total_count); @@ -556,9 +539,9 @@ ncp_do_readdir(struct ncp_server *server, struct inode *dir, int fpos, void ncp_init_dir_cache(void) { - c_dev = 0; - c_ino = 0; - c_entry = NULL; + c_dev = 0; + c_ino = 0; + c_entry = NULL; } void @@ -567,26 +550,25 @@ ncp_invalid_dir_cache(struct inode *inode) if ((inode->i_dev == c_dev) && (inode->i_ino == c_ino)) { c_dev = 0; - c_ino = 0; - c_seen_eof = 0; - } + c_ino = 0; + c_seen_eof = 0; + } } void ncp_free_dir_cache(void) { - DPRINTK("ncp_free_dir_cache: enter\n"); - - if (c_entry == NULL) + DPRINTK("ncp_free_dir_cache: enter\n"); + + if (c_entry == NULL) { - return; + return; } + ncp_kfree_s(c_entry, + sizeof(struct ncp_dirent) * NCP_READDIR_CACHE_SIZE); + c_entry = NULL; - ncp_kfree_s(c_entry, - sizeof(struct ncp_dirent) * NCP_READDIR_CACHE_SIZE); - c_entry = NULL; - - DPRINTK("ncp_free_dir_cache: exit\n"); + DPRINTK("ncp_free_dir_cache: exit\n"); } @@ -594,113 +576,109 @@ static struct inode * ncp_iget(struct inode *dir, struct nw_file_info *finfo) { struct inode *inode; - struct ncp_inode_info *new_inode_info; - struct ncp_inode_info *root; + struct ncp_inode_info *new_inode_info; + struct ncp_inode_info *root; if (dir == NULL) { printk("ncp_iget: dir is NULL\n"); return NULL; } - if (finfo == NULL) { printk("ncp_iget: finfo is NULL\n"); return NULL; } + new_inode_info = ncp_kmalloc(sizeof(struct ncp_inode_info), + GFP_KERNEL); - new_inode_info = ncp_kmalloc(sizeof(struct ncp_inode_info), - GFP_KERNEL); - - if (new_inode_info == NULL) + if (new_inode_info == NULL) { - printk("ncp_iget: could not alloc mem for %s\n", + printk("ncp_iget: could not alloc mem for %s\n", finfo->i.entryName); - return NULL; - } + return NULL; + } + new_inode_info->state = NCP_INODE_LOOKED_UP; + new_inode_info->nused = 0; + new_inode_info->dir = NCP_INOP(dir); + new_inode_info->finfo = *finfo; - new_inode_info->state = NCP_INODE_LOOKED_UP; - new_inode_info->nused = 0; - new_inode_info->dir = NCP_INOP(dir); - new_inode_info->finfo = *finfo; + NCP_INOP(dir)->nused += 1; - NCP_INOP(dir)->nused += 1; + /* We have to link the new inode_info into the doubly linked + list of inode_infos to make a complete linear search + possible. */ - /* We have to link the new inode_info into the doubly linked - list of inode_infos to make a complete linear search - possible. */ + root = &(NCP_SERVER(dir)->root); - root = &(NCP_SERVER(dir)->root); + new_inode_info->prev = root; + new_inode_info->next = root->next; + root->next->prev = new_inode_info; + root->next = new_inode_info; - new_inode_info->prev = root; - new_inode_info->next = root->next; - root->next->prev = new_inode_info; - root->next = new_inode_info; - if (!(inode = iget(dir->i_sb, ncp_info_ino(NCP_SERVER(dir), new_inode_info)))) { printk("ncp_iget: iget failed!"); return NULL; } - return inode; } void ncp_free_inode_info(struct ncp_inode_info *i) { - if (i == NULL) + if (i == NULL) { - printk("ncp_free_inode: i == NULL\n"); - return; - } - - i->state = NCP_INODE_CACHED; - while ((i->nused == 0) && (i->state == NCP_INODE_CACHED)) + printk("ncp_free_inode: i == NULL\n"); + return; + } + i->state = NCP_INODE_CACHED; + while ((i->nused == 0) && (i->state == NCP_INODE_CACHED)) { - struct ncp_inode_info *dir = i->dir; + struct ncp_inode_info *dir = i->dir; - i->next->prev = i->prev; - i->prev->next = i->next; + i->next->prev = i->prev; + i->prev->next = i->next; DDPRINTK("ncp_free_inode_info: freeing %s\n", i->finfo.i.entryName); - ncp_kfree_s(i, sizeof(struct ncp_inode_info)); + ncp_kfree_s(i, sizeof(struct ncp_inode_info)); - if (dir == i) return; + if (dir == i) + return; - (dir->nused)--; - i = dir; - } + (dir->nused)--; + i = dir; + } } - + void ncp_init_root(struct ncp_server *server) { - struct ncp_inode_info *root = &(server->root); + struct ncp_inode_info *root = &(server->root); struct nw_info_struct *i = &(root->finfo.i); unsigned short dummy; - DPRINTK("ncp_init_root: i = %x\n", (int)i); + DPRINTK("ncp_init_root: i = %x\n", (int) i); - root->finfo.opened = 0; - i->attributes = aDIR; + root->finfo.opened = 0; + i->attributes = aDIR; i->dataStreamSize = 1024; i->dirEntNum = i->DosDirNum = 0; - i->volNumber = NCP_NUMBER_OF_VOLUMES+1; /* illegal volnum */ + i->volNumber = NCP_NUMBER_OF_VOLUMES + 1; /* illegal volnum */ ncp_date_unix2dos(0, &(i->creationTime), &(i->creationDate)); ncp_date_unix2dos(0, &(i->modifyTime), &(i->modifyDate)); ncp_date_unix2dos(0, &dummy, &(i->lastAccessDate)); i->nameLen = 0; - i->entryName[0] = '\0'; + i->entryName[0] = '\0'; - root->state = NCP_INODE_LOOKED_UP; - root->nused = 1; - root->dir = root; - root->next = root->prev = root; - return; + root->state = NCP_INODE_LOOKED_UP; + root->nused = 1; + root->dir = root; + root->next = root->prev = root; + return; } int @@ -710,7 +688,6 @@ ncp_conn_logged_in(struct ncp_server *server) { return 0; } - str_upper(server->m.mounted_vol); if (ncp_lookup_volume(server, server->m.mounted_vol, &(server->root.finfo.i)) != 0) @@ -725,27 +702,26 @@ ncp_conn_logged_in(struct ncp_server *server) void ncp_free_all_inodes(struct ncp_server *server) { - /* Here nothing should be to do. I do not know whether it's - better to leave some memory allocated or be stuck in an - endless loop */ + /* Here nothing should be to do. I do not know whether it's + better to leave some memory allocated or be stuck in an + endless loop */ #if 1 - struct ncp_inode_info *root = &(server->root); + struct ncp_inode_info *root = &(server->root); - if (root->next != root) + if (root->next != root) { - printk("ncp_free_all_inodes: INODES LEFT!!!\n"); - } + printk("ncp_free_all_inodes: INODES LEFT!!!\n"); + } + while (root->next != root) + { + printk("ncp_free_all_inodes: freeing inode\n"); + ncp_free_inode_info(root->next); + /* In case we have an endless loop.. */ + schedule(); + } +#endif - while (root->next != root) - { - printk("ncp_free_all_inodes: freeing inode\n"); - ncp_free_inode_info(root->next); - /* In case we have an endless loop.. */ - schedule(); - } -#endif - - return; + return; } /* We will search the inode that belongs to this name, currently by a @@ -756,45 +732,44 @@ ncp_find_dir_inode(struct inode *dir, const char *name) { struct ncp_server *server = NCP_SERVER(dir); struct nw_info_struct *dir_info = NCP_ISTRUCT(dir); - struct ncp_inode_info *result = &(server->root); + struct ncp_inode_info *result = &(server->root); - if (name == NULL) + if (name == NULL) { - return NULL; + return NULL; } - - do + do { - if ( (result->dir->finfo.i.dirEntNum == dir_info->dirEntNum) + if ((result->dir->finfo.i.dirEntNum == dir_info->dirEntNum) && (result->dir->finfo.i.volNumber == dir_info->volNumber) && (strcmp(result->finfo.i.entryName, name) == 0) - /* The root dir is never looked up using this - * routine. Without the following test a root - * directory 'sys' in a volume named 'sys' could - * never be looked up, because - * server->root->dir==server->root. */ + /* The root dir is never looked up using this + * routine. Without the following test a root + * directory 'sys' in a volume named 'sys' could + * never be looked up, because + * server->root->dir==server->root. */ && (result != &(server->root))) { - return result; + return result; } - result = result->next; + result = result->next; - } + } while (result != &(server->root)); - return NULL; + return NULL; } -static int +static int ncp_lookup(struct inode *dir, const char *__name, int len, - struct inode **result) + struct inode **result) { struct nw_file_info finfo; struct ncp_server *server; - struct ncp_inode_info *result_info; - int found_in_cache; + struct ncp_inode_info *result_info; + int found_in_cache; int down_case = 0; - char name[len+1]; + char name[len + 1]; *result = NULL; @@ -804,15 +779,13 @@ ncp_lookup(struct inode *dir, const char *__name, int len, iput(dir); return -ENOENT; } - server = NCP_SERVER(dir); if (!ncp_conn_valid(server)) { iput(dir); return -EIO; } - - DDPRINTK("ncp_lookup: %s, len %d\n", __name, len); + DDPRINTK("ncp_lookup: %s, len %d\n", __name, len); /* Fast cheat for . */ if (len == 0 || (len == 1 && __name[0] == '.')) @@ -820,7 +793,6 @@ ncp_lookup(struct inode *dir, const char *__name, int len, *result = dir; return 0; } - /* ..and for .. */ if (len == 2 && __name[0] == '.' && __name[1] == '.') { @@ -830,78 +802,72 @@ ncp_lookup(struct inode *dir, const char *__name, int len, { parent->state = NCP_INODE_LOOKED_UP; } - *result = iget(dir->i_sb, ncp_info_ino(server, parent)); iput(dir); if (*result == 0) { return -EACCES; - } - else + } else { return 0; } } - memcpy(name, __name, len); name[len] = 0; lock_super(dir->i_sb); - result_info = ncp_find_dir_inode(dir, name); + result_info = ncp_find_dir_inode(dir, name); - if (result_info != 0) + if (result_info != 0) { - if (result_info->state == NCP_INODE_CACHED) + if (result_info->state == NCP_INODE_CACHED) { - result_info->state = NCP_INODE_LOOKED_UP; + result_info->state = NCP_INODE_LOOKED_UP; } + /* Here we convert the inode_info address into an + inode number */ - /* Here we convert the inode_info address into an - inode number */ - - *result = iget(dir->i_sb, ncp_info_ino(server, result_info)); + *result = iget(dir->i_sb, ncp_info_ino(server, result_info)); unlock_super(dir->i_sb); - iput(dir); + iput(dir); - if (*result == NULL) + if (*result == NULL) { - return -EACCES; - } - + return -EACCES; + } return 0; - } + } + /* If the file is in the dir cache, we do not have to ask the + server. */ - /* If the file is in the dir cache, we do not have to ask the - server. */ + found_in_cache = 0; - found_in_cache = 0; + ncp_lock_dircache(); - ncp_lock_dircache(); - - if ((dir->i_dev == c_dev) && (dir->i_ino == c_ino)) + if ((dir->i_dev == c_dev) && (dir->i_ino == c_ino)) { - int first = c_last_returned_index; - int i; + int first = c_last_returned_index; + int i; - i = first; - do + i = first; + do { - DDPRINTK("ncp_lookup: trying index: %d, name: %s\n", - i, c_entry[i].i.entryName); + DDPRINTK("ncp_lookup: trying index: %d, name: %s\n", + i, c_entry[i].i.entryName); - if (strcmp(c_entry[i].i.entryName, name) == 0) + if (strcmp(c_entry[i].i.entryName, name) == 0) { - DPRINTK("ncp_lookup: found in cache!\n"); + DPRINTK("ncp_lookup: found in cache!\n"); finfo.i = c_entry[i].i; found_in_cache = 1; break; - } - i = (i + 1) % c_size; - } + } + i = (i + 1) % c_size; + } while (i != first); - } + } ncp_unlock_dircache(); - if (found_in_cache == 0) + if (found_in_cache == 0) { int res; @@ -913,8 +879,7 @@ ncp_lookup(struct inode *dir, const char *__name, int len, str_upper(name); down_case = 1; res = ncp_lookup_volume(server, name, &(finfo.i)); - } - else + } else { if (!ncp_preserve_case(dir)) { @@ -929,36 +894,33 @@ ncp_lookup(struct inode *dir, const char *__name, int len, if (res != 0) { unlock_super(dir->i_sb); - iput(dir); - return -ENOENT; - } - } - + iput(dir); + return -ENOENT; + } + } finfo.opened = 0; if (down_case != 0) { str_lower(finfo.i.entryName); } - if (!(*result = ncp_iget(dir, &finfo))) { unlock_super(dir->i_sb); iput(dir); return -EACCES; } - unlock_super(dir->i_sb); iput(dir); return 0; } -static int +static int ncp_create(struct inode *dir, const char *name, int len, int mode, - struct inode **result) + struct inode **result) { struct nw_file_info finfo; - __u8 _name[len+1]; + __u8 _name[len + 1]; *result = NULL; @@ -973,7 +935,6 @@ ncp_create(struct inode *dir, const char *name, int len, int mode, iput(dir); return -EIO; } - strncpy(_name, name, len); _name[len] = '\0'; @@ -981,27 +942,24 @@ ncp_create(struct inode *dir, const char *name, int len, int mode, { str_upper(_name); } - lock_super(dir->i_sb); if (ncp_open_create_file_or_subdir(NCP_SERVER(dir), NCP_ISTRUCT(dir), _name, - OC_MODE_CREATE|OC_MODE_OPEN| + OC_MODE_CREATE | OC_MODE_OPEN | OC_MODE_REPLACE, - 0, AR_READ|AR_WRITE, + 0, AR_READ | AR_WRITE, &finfo) != 0) { unlock_super(dir->i_sb); iput(dir); return -EACCES; } - - ncp_invalid_dir_cache(dir); + ncp_invalid_dir_cache(dir); if (!ncp_preserve_case(dir)) { str_lower(finfo.i.entryName); } - finfo.access = O_RDWR; if (!(*result = ncp_iget(dir, &finfo)) < 0) @@ -1011,10 +969,9 @@ ncp_create(struct inode *dir, const char *name, int len, int mode, iput(dir); return -EINVAL; } - unlock_super(dir->i_sb); iput(dir); - return 0; + return 0; } static int @@ -1022,17 +979,16 @@ ncp_mkdir(struct inode *dir, const char *name, int len, int mode) { int error; struct nw_file_info new_dir; - __u8 _name[len+1]; + __u8 _name[len + 1]; - if ( (name[0] == '.') - && ( (len == 1) - || ( (len == 2) + if ((name[0] == '.') + && ((len == 1) + || ((len == 2) && (name[1] == '.')))) { iput(dir); return -EEXIST; } - strncpy(_name, name, len); _name[len] = '\0'; @@ -1040,7 +996,6 @@ ncp_mkdir(struct inode *dir, const char *name, int len, int mode) { str_upper(_name); } - if (!dir || !S_ISDIR(dir->i_mode)) { printk("ncp_mkdir: inode is NULL or not a directory\n"); @@ -1052,19 +1007,17 @@ ncp_mkdir(struct inode *dir, const char *name, int len, int mode) iput(dir); return -EIO; } - if (ncp_open_create_file_or_subdir(NCP_SERVER(dir), NCP_ISTRUCT(dir), _name, OC_MODE_CREATE, aDIR, 0xffff, &new_dir) != 0) { error = -EACCES; - } - else + } else { error = 0; - ncp_invalid_dir_cache(dir); - } + ncp_invalid_dir_cache(dir); + } iput(dir); return error; @@ -1074,7 +1027,7 @@ static int ncp_rmdir(struct inode *dir, const char *name, int len) { int error; - __u8 _name[len+1]; + __u8 _name[len + 1]; if (!dir || !S_ISDIR(dir->i_mode)) { @@ -1087,12 +1040,11 @@ ncp_rmdir(struct inode *dir, const char *name, int len) iput(dir); return -EIO; } - if (ncp_find_dir_inode(dir, name) != NULL) + if (ncp_find_dir_inode(dir, name) != NULL) { iput(dir); - error = -EBUSY; - } - else + error = -EBUSY; + } else { strncpy(_name, name, len); @@ -1102,18 +1054,16 @@ ncp_rmdir(struct inode *dir, const char *name, int len) { str_upper(_name); } - - if ((error = ncp_del_file_or_subdir(NCP_SERVER(dir), + if ((error = ncp_del_file_or_subdir(NCP_SERVER(dir), NCP_ISTRUCT(dir), _name)) == 0) { - ncp_invalid_dir_cache(dir); - } - else + ncp_invalid_dir_cache(dir); + } else { error = -EACCES; } - } + } iput(dir); return error; } @@ -1122,7 +1072,7 @@ static int ncp_unlink(struct inode *dir, const char *name, int len) { int error; - __u8 _name[len+1]; + __u8 _name[len + 1]; if (!dir || !S_ISDIR(dir->i_mode)) { @@ -1135,12 +1085,11 @@ ncp_unlink(struct inode *dir, const char *name, int len) iput(dir); return -EIO; } - if (ncp_find_dir_inode(dir, name) != NULL) + if (ncp_find_dir_inode(dir, name) != NULL) { iput(dir); - error = -EBUSY; - } - else + error = -EBUSY; + } else { strncpy(_name, name, len); _name[len] = '\0'; @@ -1149,57 +1098,51 @@ ncp_unlink(struct inode *dir, const char *name, int len) { str_upper(_name); } - - if ((error = ncp_del_file_or_subdir(NCP_SERVER(dir), + if ((error = ncp_del_file_or_subdir(NCP_SERVER(dir), NCP_ISTRUCT(dir), _name)) == 0) { - ncp_invalid_dir_cache(dir); - } - else + ncp_invalid_dir_cache(dir); + } else { error = -EACCES; } - } + } iput(dir); return error; } static int ncp_rename(struct inode *old_dir, const char *old_name, int old_len, - struct inode *new_dir, const char *new_name, int new_len) + struct inode *new_dir, const char *new_name, int new_len) { int res; - char _old_name[old_len+1]; - char _new_name[new_len+1]; + char _old_name[old_len + 1]; + char _new_name[new_len + 1]; if (!old_dir || !S_ISDIR(old_dir->i_mode)) { printk("ncp_rename: old inode is NULL or not a directory\n"); - res = -ENOENT; - goto finished; + res = -ENOENT; + goto finished; } - if (!ncp_conn_valid(NCP_SERVER(old_dir))) { res = -EIO; goto finished; } - if (!new_dir || !S_ISDIR(new_dir->i_mode)) { printk("ncp_rename: new inode is NULL or not a directory\n"); - res = -ENOENT; - goto finished; + res = -ENOENT; + goto finished; } - - if ( (ncp_find_dir_inode(old_dir, old_name) != NULL) - || (ncp_find_dir_inode(new_dir, new_name) != NULL)) + if ((ncp_find_dir_inode(old_dir, old_name) != NULL) + || (ncp_find_dir_inode(new_dir, new_name) != NULL)) { - res = -EBUSY; - goto finished; - } - + res = -EBUSY; + goto finished; + } strncpy(_old_name, old_name, old_len); _old_name[old_len] = '\0'; @@ -1207,7 +1150,6 @@ ncp_rename(struct inode *old_dir, const char *old_name, int old_len, { str_upper(_old_name); } - strncpy(_new_name, new_name, new_len); _new_name[new_len] = '\0'; @@ -1215,23 +1157,21 @@ ncp_rename(struct inode *old_dir, const char *old_name, int old_len, { str_upper(_new_name); } - res = ncp_ren_or_mov_file_or_subdir(NCP_SERVER(old_dir), NCP_ISTRUCT(old_dir), _old_name, NCP_ISTRUCT(new_dir), _new_name); - if (res == 0) + if (res == 0) { - ncp_invalid_dir_cache(old_dir); - ncp_invalid_dir_cache(new_dir); - } - else + ncp_invalid_dir_cache(old_dir); + ncp_invalid_dir_cache(new_dir); + } else { res = -EACCES; } - - finished: - iput(old_dir); + + finished: + iput(old_dir); iput(new_dir); return res; } @@ -1240,7 +1180,8 @@ ncp_rename(struct inode *old_dir, const char *old_name, int old_len, /* Linear day numbers of the respective 1sts in non-leap years. */ -static int day_n[] = { 0,31,59,90,120,151,181,212,243,273,304,334,0,0,0,0 }; +static int day_n[] = +{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 0, 0, 0}; /* JanFebMarApr May Jun Jul Aug Sep Oct Nov Dec */ @@ -1249,53 +1190,56 @@ extern struct timezone sys_tz; static int utc2local(int time) { - return time - sys_tz.tz_minuteswest*60; + return time - sys_tz.tz_minuteswest * 60; } static int local2utc(int time) { - return time + sys_tz.tz_minuteswest*60; + return time + sys_tz.tz_minuteswest * 60; } /* Convert a MS-DOS time/date pair to a UNIX date (seconds since 1 1 70). */ int -ncp_date_dos2unix(unsigned short time,unsigned short date) +ncp_date_dos2unix(unsigned short time, unsigned short date) { - int month,year,secs; + int month, year, secs; - month = ((date >> 5) & 15)-1; + month = ((date >> 5) & 15) - 1; year = date >> 9; - secs = (time & 31)*2+60*((time >> 5) & 63)+(time >> 11)*3600+86400* - ((date & 31)-1+day_n[month]+(year/4)+year*365-((year & 3) == 0 && - month < 2 ? 1 : 0)+3653); - /* days since 1.1.70 plus 80's leap day */ + secs = (time & 31) * 2 + 60 * ((time >> 5) & 63) + (time >> 11) * 3600 + 86400 * + ((date & 31) - 1 + day_n[month] + (year / 4) + year * 365 - ((year & 3) == 0 && + month < 2 ? 1 : 0) + 3653); + /* days since 1.1.70 plus 80's leap day */ return local2utc(secs); } /* Convert linear UNIX date to a MS-DOS time/date pair. */ void -ncp_date_unix2dos(int unix_date,unsigned short *time, unsigned short *date) +ncp_date_unix2dos(int unix_date, unsigned short *time, unsigned short *date) { - int day,year,nl_day,month; + int day, year, nl_day, month; unix_date = utc2local(unix_date); - *time = (unix_date % 60)/2+(((unix_date/60) % 60) << 5)+ - (((unix_date/3600) % 24) << 11); - day = unix_date/86400-3652; - year = day/365; - if ((year+3)/4+365*year > day) year--; - day -= (year+3)/4+365*year; - if (day == 59 && !(year & 3)) { + *time = (unix_date % 60) / 2 + (((unix_date / 60) % 60) << 5) + + (((unix_date / 3600) % 24) << 11); + day = unix_date / 86400 - 3652; + year = day / 365; + if ((year + 3) / 4 + 365 * year > day) + year--; + day -= (year + 3) / 4 + 365 * year; + if (day == 59 && !(year & 3)) + { nl_day = day; month = 2; - } - else { - nl_day = (year & 3) || day <= 59 ? day : day-1; + } else + { + nl_day = (year & 3) || day <= 59 ? day : day - 1; for (month = 0; month < 12; month++) - if (day_n[month] > nl_day) break; + if (day_n[month] > nl_day) + break; } - *date = nl_day-day_n[month-1]+1+(month << 5)+(year << 9); + *date = nl_day - day_n[month - 1] + 1 + (month << 5) + (year << 9); } diff --git a/kernel-1.2/src/file.c b/kernel-1.2/src/file.c index 2ba0d07..ab40d3c 100644 --- a/kernel-1.2/src/file.c +++ b/kernel-1.2/src/file.c @@ -25,12 +25,13 @@ #include "ncplib_kernel.h" #include -static inline int min(int a, int b) +static inline int +min(int a, int b) { - return aopened = %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 */ diff --git a/kernel-1.2/src/inode.c b/kernel-1.2/src/inode.c index d576ae4..8b575db 100644 --- a/kernel-1.2/src/inode.c +++ b/kernel-1.2/src/inode.c @@ -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 } diff --git a/kernel-1.2/src/ioctl.c b/kernel-1.2/src/ioctl.c index f0a9d9a..0791445 100644 --- a/kernel-1.2/src/ioctl.c +++ b/kernel-1.2/src/ioctl.c @@ -21,8 +21,8 @@ #include 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. * 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; } diff --git a/kernel-1.2/src/mmap.c b/kernel-1.2/src/mmap.c index 344f6eb..ec7f794 100644 --- a/kernel-1.2/src/mmap.c +++ b/kernel-1.2/src/mmap.c @@ -27,19 +27,20 @@ #include #include -static inline int min(int a, int b) +static inline int +min(int a, int b) { - return avm_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; diff --git a/kernel-1.2/src/ncplib_kernel.c b/kernel-1.2/src/ncplib_kernel.c index d987b6e..dd741ce 100644 --- a/kernel-1.2/src/ncplib_kernel.c +++ b/kernel-1.2/src/ncplib_kernel.c @@ -1,3 +1,4 @@ + #include #ifdef MODULE #include @@ -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 apacket[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; } - diff --git a/kernel-1.2/src/ncplib_kernel.h b/kernel-1.2/src/ncplib_kernel.h index 8d46aa6..2abcc4c 100644 --- a/kernel-1.2/src/ncplib_kernel.h +++ b/kernel-1.2/src/ncplib_kernel.h @@ -1,3 +1,4 @@ + #ifndef _NCPLIB_H #define _NCPLIB_H @@ -16,147 +17,147 @@ #include 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 */ diff --git a/kernel-1.2/src/sock.c b/kernel-1.2/src/sock.c index 12e2a51..af82549 100644 --- a/kernel-1.2/src/sock.c +++ b/kernel-1.2/src/sock.c @@ -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); } - diff --git a/lib/com_err/com_err.c b/lib/com_err/com_err.c index 8ee332a..e1a0158 100644 --- a/lib/com_err/com_err.c +++ b/lib/com_err/com_err.c @@ -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; } diff --git a/lib/com_err/com_err.h b/lib/com_err/com_err.h index f28dce8..8e8ad11 100644 --- a/lib/com_err/com_err.h +++ b/lib/com_err/com_err.h @@ -16,25 +16,25 @@ typedef long errcode_t; #include /* 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) */ diff --git a/lib/com_err/error_message.c b/lib/com_err/error_message.c index e1c1c3a..ee2f049 100644 --- a/lib/com_err/error_message.c +++ b/lib/com_err/error_message.c @@ -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<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); } diff --git a/lib/com_err/error_table.h b/lib/com_err/error_table.h index 31971f0..ab498fa 100644 --- a/lib/com_err/error_table.h +++ b/lib/com_err/error_table.h @@ -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 */ diff --git a/lib/com_err/et_name.c b/lib/com_err/et_name.c index db4099f..75617d7 100644 --- a/lib/com_err/et_name.c +++ b/lib/com_err/et_name.c @@ -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); } diff --git a/lib/com_err/init_et.c b/lib/com_err/init_et.c index 4b3b673..8978434 100644 --- a/lib/com_err/init_et.c +++ b/lib/com_err/init_et.c @@ -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; } diff --git a/lib/com_err/internal.h b/lib/com_err/internal.h index 112c016..e185623 100644 --- a/lib/com_err/internal.h +++ b/lib/com_err/internal.h @@ -10,13 +10,13 @@ #include #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 diff --git a/lib/com_err/mit-sipb-copyright.h b/lib/com_err/mit-sipb-copyright.h index 2f7eb29..6438203 100644 --- a/lib/com_err/mit-sipb-copyright.h +++ b/lib/com_err/mit-sipb-copyright.h @@ -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. + */ diff --git a/lib/ncplib.c b/lib/ncplib.c index 5ccad92..d14d877 100644 --- a/lib/ncplib.c +++ b/lib/ncplib.c @@ -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, diff --git a/man/nprint.1 b/man/nprint.1 index c583cf8..fcb4264 100644 --- a/man/nprint.1 +++ b/man/nprint.1 @@ -14,7 +14,7 @@ nprint \- NetWare print client ] [ .B -P .I password - | +| .B -n ] [ .B -C diff --git a/man/nwbocreate.8 b/man/nwbocreate.8 index 7188d98..ee6b544 100644 --- a/man/nwbocreate.8 +++ b/man/nwbocreate.8 @@ -14,7 +14,7 @@ nwbocreate \- Create a NetWare Bindery Object ] [ .B -P .I password - | +| .B -n ] [ .B -C diff --git a/man/nwbols.1 b/man/nwbols.1 index 53d6c66..e60fa97 100644 --- a/man/nwbols.1 +++ b/man/nwbols.1 @@ -14,7 +14,7 @@ nwbols \- List NetWare Bindery Objects ] [ .B -P .I password - | +| .B -n ] [ .B -C diff --git a/man/nwboprops.1 b/man/nwboprops.1 index df4cc21..2d74d6c 100644 --- a/man/nwboprops.1 +++ b/man/nwboprops.1 @@ -14,7 +14,7 @@ nwboprops \- List properies of a NetWare Bindery Object ] [ .B -P .I password - | +| .B -n ] [ .B -C diff --git a/man/nwborm.8 b/man/nwborm.8 index f096efc..f955c58 100644 --- a/man/nwborm.8 +++ b/man/nwborm.8 @@ -14,7 +14,7 @@ nwborm \- Remove a NetWare Bindery Object ] [ .B -P .I password - | +| .B -n ] [ .B -C diff --git a/man/nwbpadd.8 b/man/nwbpadd.8 index f4a21c8..62687cb 100644 --- a/man/nwbpadd.8 +++ b/man/nwbpadd.8 @@ -14,7 +14,7 @@ nwbpadd \- Set the value of a NetWare Bindery Property ] [ .B -P .I password - | +| .B -n ] [ .B -C diff --git a/man/nwbpset.1 b/man/nwbpset.1 index 257abc3..f6147b2 100644 --- a/man/nwbpset.1 +++ b/man/nwbpset.1 @@ -14,7 +14,7 @@ nwbpset \- Create a bindery property or set its value ] [ .B -P .I password - | +| .B -n ] [ .B -C diff --git a/man/nwfstime.1 b/man/nwfstime.1 index c8d8f94..cfc33eb 100644 --- a/man/nwfstime.1 +++ b/man/nwfstime.1 @@ -14,7 +14,7 @@ nwfstime \- Display / Set a NetWare server's date and time ] [ .B -P .I password - | +| .B -n ] [ .B -C diff --git a/man/nwgrant.8 b/man/nwgrant.8 index f4dff43..6a90ae5 100644 --- a/man/nwgrant.8 +++ b/man/nwgrant.8 @@ -14,7 +14,7 @@ nwgrant \- Add Trustee Rights to a directory ] [ .B -P .I password - | +| .B -n ] [ .B -C diff --git a/man/nwrevoke.8 b/man/nwrevoke.8 index 20d3523..afd81ae 100644 --- a/man/nwrevoke.8 +++ b/man/nwrevoke.8 @@ -14,7 +14,7 @@ nwrevoke \- Revoke a Trustee Right from a directory ] [ .B -P .I password - | +| .B -n ] [ .B -C diff --git a/man/nwtrustee.1 b/man/nwtrustee.1 new file mode 100644 index 0000000..f4ffdf0 --- /dev/null +++ b/man/nwtrustee.1 @@ -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 . +This manual page was written by Volker Lendecke. diff --git a/man/nwuserlist.1 b/man/nwuserlist.1 index 0991e6e..0f425be 100644 --- a/man/nwuserlist.1 +++ b/man/nwuserlist.1 @@ -14,7 +14,7 @@ nwuserlist \- List Users logged in at a NetWare server ] [ .B -P .I password - | +| .B -n ] [ .B -C diff --git a/man/pserver.1 b/man/pserver.1 index 0cb3dd2..b8358a0 100644 --- a/man/pserver.1 +++ b/man/pserver.1 @@ -14,7 +14,7 @@ pserver \- NetWare print server ] [ .B -P .I password - | +| .B -n ] [ .B -C diff --git a/ncpfs-2.0.9.lsm b/ncpfs-2.0.10.lsm similarity index 83% rename from ncpfs-2.0.9.lsm rename to ncpfs-2.0.10.lsm index 29cb724..eb8ead1 100644 --- a/ncpfs-2.0.9.lsm +++ b/ncpfs-2.0.10.lsm @@ -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 diff --git a/sutil/ipxlib.h b/sutil/ipxlib.h index ac243b0..bf16bf4 100644 --- a/sutil/ipxlib.h +++ b/sutil/ipxlib.h @@ -15,9 +15,9 @@ #include #include -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 */ diff --git a/sutil/ncplib.c b/sutil/ncplib.c index a1e8ba3..6421b22 100644 --- a/sutil/ncplib.c +++ b/sutil/ncplib.c @@ -9,7 +9,7 @@ #include "ncplib_err.h" #include - /* #include *//* generates a warning here */ + /* #include *//* generates a warning here */ extern pid_t wait(int *); #include #include diff --git a/sutil/ncplib.h b/sutil/ncplib.h index 095eed7..a5f893b 100644 --- a/sutil/ncplib.h +++ b/sutil/ncplib.h @@ -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 */ diff --git a/sutil/ncpmount.c b/sutil/ncpmount.c index e61ad84..b00f383 100644 --- a/sutil/ncpmount.c +++ b/sutil/ncpmount.c @@ -26,7 +26,7 @@ #include #include #include - /* #include *//* generates a warning here */ + /* #include *//* generates a warning here */ extern pid_t waitpid(pid_t, int *, int); #include #include diff --git a/sutil/ncpumount.c b/sutil/ncpumount.c index 15a7e96..589eacc 100644 --- a/sutil/ncpumount.c +++ b/sutil/ncpumount.c @@ -16,7 +16,7 @@ #include #include #include - /* #include *//* generates a warning here */ + /* #include *//* generates a warning here */ extern pid_t waitpid(pid_t, int *, int); #include #include diff --git a/util/Makefile b/util/Makefile index c73f6b7..6fed304 100644 --- a/util/Makefile +++ b/util/Makefile @@ -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 diff --git a/util/ncptest.c b/util/ncptest.c index 4160303..15147d6 100644 --- a/util/ncptest.c +++ b/util/ncptest.c @@ -19,7 +19,7 @@ #include #include #include - /* #include *//* generates a warning here */ + /* #include *//* generates a warning here */ extern pid_t waitpid(pid_t, int *, int); #include #include diff --git a/util/nwtrustee.c b/util/nwtrustee.c index 08ecab7..c253d43 100644 --- a/util/nwtrustee.c +++ b/util/nwtrustee.c @@ -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; }