patch-1.3.76 linux/fs/nfs/nfsroot.c
Next file: linux/include/asm-i386/smp.h
Previous file: linux/fs/inode.c
Back to the patch index
Back to the overall index
- Lines: 246
- Date:
Tue Mar 19 09:05:23 1996
- Orig file:
v1.3.75/linux/fs/nfs/nfsroot.c
- Orig date:
Sun Mar 17 09:04:07 1996
diff -u --recursive --new-file v1.3.75/linux/fs/nfs/nfsroot.c linux/fs/nfs/nfsroot.c
@@ -1,5 +1,5 @@
/*
- * linux/fs/nfs/nfsroot.c -- version 2.0
+ * linux/fs/nfs/nfsroot.c -- version 2.1
*
* Copyright (C) 1995 Gero Kuhlmann <gero@gkminix.han.de>
* Copyright (C) 1996 Martin Mares <mj@k332.feld.cvut.cz>
@@ -25,6 +25,8 @@
* Martin Mares : Randomized timer with exponential backoff
* installed to minimize network congestion.
* Martin Mares : Code cleanup.
+ * Martin Mares : (2.1) BOOTP and RARP made configuration options.
+ * Martin Mares : Server hostname generation fixed.
*
*
* Known bugs and caveats:
@@ -40,10 +42,6 @@
#undef NFSROOT_DEBUG
#undef NFSROOT_MORE_DEBUG
-/* Choose default protocol(s) */
-#define CONFIG_USE_BOOTP
-#define CONFIG_USE_RARP
-
/* Define the timeout for waiting for a RARP/BOOTP reply */
#define CONF_BASE_TIMEOUT (HZ*5) /* Initial timeout: 5 seconds */
#define CONF_RETRIES 10 /* 10 retries */
@@ -106,14 +104,19 @@
static struct sockaddr_in netmask; /* Netmask for local subnet */
/* BOOTP/RARP variables */
+
static int bootp_flag; /* User said: Use BOOTP! */
static int rarp_flag; /* User said: Use RARP! */
static int bootp_dev_count = 0; /* Number of devices allowing BOOTP */
static int rarp_dev_count = 0; /* Number of devices allowing RARP */
+
+#if defined(CONFIG_RNFS_BOOTP) || defined(CONFIG_RNFS_RARP)
+#define CONFIG_RNFS_DYNAMIC /* Enable dynamic IP config */
volatile static int pkt_arrived; /* BOOTP/RARP packet detected */
#define ARRIVED_BOOTP 1
#define ARRIVED_RARP 2
+#endif
/* NFS-related data */
static struct nfs_mount_data nfs_data; /* NFS mount info */
@@ -212,6 +215,8 @@
***************************************************************************/
+#ifdef CONFIG_RNFS_RARP
+
extern void arp_send(int type, int ptype, unsigned long target_ip,
struct device *dev, unsigned long src_ip,
unsigned char *dest_hw, unsigned char *src_hw,
@@ -350,6 +355,7 @@
}
}
+#endif
/***************************************************************************
@@ -357,6 +363,8 @@
***************************************************************************/
+#ifdef CONFIG_RNFS_BOOTP
+
static struct device *bootp_dev = NULL; /* Device selected as best BOOTP target */
static int bootp_xmit_fd = -1; /* Socket descriptor for transmit */
@@ -827,6 +835,7 @@
}
}
+#endif
/***************************************************************************
@@ -834,6 +843,8 @@
***************************************************************************/
+#ifdef CONFIG_RNFS_DYNAMIC
+
/*
* Determine client and server IP numbers and appropriate device by using
* the RARP and BOOTP protocols.
@@ -843,24 +854,43 @@
int retries;
u32 timeout, jiff;
u32 start_jiffies;
+ int selected = 0;
/* Check devices */
- if (bootp_flag && !bootp_dev_count) {
- printk(KERN_ERR "BOOTP: No suitable device found.\n");
- bootp_flag = 0;
+
+#ifdef CONFIG_RNFS_BOOTP
+ if (bootp_flag) {
+ if (bootp_dev_count)
+ selected = 1;
+ else {
+ printk(KERN_ERR "BOOTP: No suitable device found.\n");
+ bootp_flag = 0;
}
- if (rarp_flag && !rarp_dev_count) {
- printk(KERN_ERR "RARP: No suitable device found.\n");
- rarp_flag = 0;
+ }
+#else
+ bootp_flag = 0;
+#endif
+
+#ifdef CONFIG_RNFS_RARP
+ if (rarp_flag) {
+ if (rarp_dev_count)
+ selected = 1;
+ else {
+ printk(KERN_ERR "RARP: No suitable device found.\n");
+ rarp_flag = 0;
}
+ }
+#else
+ rarp_flag = 0;
+#endif
/* If neither BOOTP nor RARP was selected manually, use both of them */
- if (!bootp_flag && !rarp_flag) {
-#ifdef CONFIG_USE_BOOTP
+ if (!selected) {
+#ifdef CONFIG_RNFS_BOOTP
if (bootp_dev_count)
bootp_flag = 1;
#endif
-#ifdef CONFIG_USE_RARP
+#ifdef CONFIG_RNFS_RARP
if (rarp_dev_count)
rarp_flag = 1;
#endif
@@ -869,12 +899,16 @@
}
/* Setup RARP and BOOTP protocols */
+#ifdef CONFIG_RNFS_RARP
if (rarp_flag)
root_rarp_open();
+#endif
+#ifdef CONFIG_RNFS_BOOTP
if (bootp_flag && root_bootp_open()) {
root_bootp_close();
return -1;
}
+#endif
/*
* Send requests and wait, until we get an answer. This loop
@@ -893,6 +927,7 @@
get_random_bytes(&timeout, sizeof(timeout));
timeout = CONF_BASE_TIMEOUT + (timeout % (unsigned) CONF_TIMEOUT_RANDOM);
for(;;) {
+#ifdef CONFIG_RNFS_BOOTP
if (bootp_flag && root_bootp_send(jiffies - start_jiffies)) {
printk("...BOOTP failed!\n");
root_bootp_close();
@@ -900,12 +935,19 @@
if (!rarp_flag)
break;
}
+#endif
+#ifdef CONFIG_RNFS_RARP
if (rarp_flag)
root_rarp_send();
+#endif
printk(".");
jiff = jiffies + timeout;
while (jiffies < jiff && !pkt_arrived)
+#ifdef CONFIG_RNFS_BOOTP
root_bootp_recv();
+#else
+ ;
+#endif
if (pkt_arrived)
break;
if (! --retries) {
@@ -917,10 +959,14 @@
timeout = CONF_TIMEOUT_MAX;
}
+#ifdef CONFIG_RNFS_RARP
if (rarp_flag)
root_rarp_close();
+#endif
+#ifdef CONFIG_RNFS_BOOTP
if (bootp_flag)
root_bootp_close();
+#endif
if (!pkt_arrived)
return -1;
@@ -934,6 +980,7 @@
return 0;
}
+#endif
/***************************************************************************
@@ -999,10 +1046,6 @@
name = cp;
}
- /* Setup the server hostname */
- cp = in_ntoa(server.sin_addr.s_addr);
- strncpy(nfs_data.hostname, cp, 255);
-
/* Set the name of the directory to mount */
cp = in_ntoa(myaddr.sin_addr.s_addr);
strncpy(buf, name, 255);
@@ -1186,6 +1229,9 @@
system_utsname.nodename[__NEW_UTS_LEN] = '\0';
}
+ /* Setup the server hostname */
+ strncpy(nfs_data.hostname, in_ntoa(server.sin_addr.s_addr), 255);
+
/* Set the correct netmask */
if (netmask.sin_addr.s_addr == INADDR_NONE)
netmask.sin_addr.s_addr = ip_get_mask(myaddr.sin_addr.s_addr);
@@ -1273,8 +1319,11 @@
*/
if ((myaddr.sin_addr.s_addr == INADDR_NONE ||
server.sin_addr.s_addr == INADDR_NONE ||
- (open_base != NULL && open_base->next != NULL)) &&
- root_auto_config() < 0) {
+ (open_base != NULL && open_base->next != NULL))
+#ifdef CONFIG_RNFS_DYNAMIC
+ && root_auto_config() < 0
+#endif
+ ) {
root_dev_close();
return -1;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov
with Sam's (original) version of this