diskless swap filename

ian j hart ianjhart at ntlworld.com
Wed Dec 10 16:30:42 PST 2003


Re: http://docs.freebsd.org/cgi/mid.cgi?200311291436.37674.ianjhart

On Saturday 29 November 2003 2:36 pm, ian j hart wrote:
> Does anyone have a patch to use the mac address instead of the ip
> address for the swapfile name?
>
> Feeling lazy this week :)
>
> Cheers

No takers then :(

For the archive, here's a patch. It's probably bogus and it certainly breaks style, but it seems to work okay.

--- sys/nfs/bootp_subr.c.orig   Thu Dec 11 00:06:28 2003
+++ sys/nfs/bootp_subr.c        Thu Dec 11 00:14:10 2003
@@ -57,6 +57,7 @@
 #include <sys/sysctl.h>
 #include <sys/uio.h>

+#include <net/ethernet.h>
 #include <net/if.h>
 #include <net/route.h>

@@ -1845,9 +1846,31 @@
                                               gctx->lookup_path,
                                               nd->swap_fh, &nd->swap_fhsize,
                                               &nd->swap_args, procp);
-                       if (error != 0)
-                               panic("nfs_boot: lookup swap, error=%d",
-                                     error);
+                       if (error != 0) {
+                               if (gctx->interfaces->sdl->sdl_type == IFT_ETHER &&
+                                   gctx->interfaces->sdl->sdl_alen == ETHER_ADDR_LEN) {
+                                       snprintf(gctx->lookup_path,
+                                               sizeof(gctx->lookup_path),
+                                               "swap.%02x:%02x:%02x:%02x:%02x:%02x",
+                                               ((struct ether_addr *)LLADDR(gctx->interfaces->sdl))->octet[0],
+                                               ((struct ether_addr *)LLADDR(gctx->interfaces->sdl))->octet[1],
+                                               ((struct ether_addr *)LLADDR(gctx->interfaces->sdl))->octet[2],
+                                               ((struct ether_addr *)LLADDR(gctx->interfaces->sdl))->octet[3],
+                                               ((struct ether_addr *)LLADDR(gctx->interfaces->sdl))->octet[4],
+                                               ((struct ether_addr *)LLADDR(gctx->interfaces->sdl))->octet[5]
+                                               );
+                                               error = md_lookup_swap(&nd->swap_saddr,
+                                                              gctx->lookup_path,
+                                                              nd->swap_fh, &nd->swap_fhsize,
+                                                              &nd->swap_args, procp);
+                                       if (error != 0)
+                                               panic("nfs_boot: lookup swap name=%s, error=%d",
+                                                     gctx->lookup_path, error);
+                                   }
+                               else
+                                       panic("nfs_boot: lookup swap, error=%d",
+                                             error);
+                       }
                }
                nfs_diskless_valid = 3;
        }


-- 
ian j hart

http://ars.userfriendly.org/cartoons/?id=20031016



More information about the freebsd-questions mailing list