Thread: Programing with Grub

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    2

    Programing with Grub

    Hi.. I'm doing a project that use Grub 0.97 as boot loader and first level application. My program will run with Grub and do some other thing that i have set up. The problem here is i need to obtain MAC Address to create another security level. Is there anyone know how to obtain this MAC Address?? I already make some research but still found nothing. Thanks..

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    you'll need to detect the network hardware, and install a driver for it, either in your code or in some kind of loadable module, and then query the driver to get the mac address. there are literally hundreds of network chipsets out there, so this could be a rather large task.

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    So...to get this right you want to use grub to load your code, which in effect will be a kind of a kernel as there wont be much help from grub after loading the second stage, and then get the MAC address of your network interface?

    If so you'd do better to have a look at Expanded Main Page - OSDev Wiki. It wont be easy though...each card will probably have its own port settings to enable you to get this info, and once you have it you'll need to work out how to communicate that back to you or do something with it (no stdlib, only BIOS routines or direct hardware manipulation)

  4. #4
    Registered User
    Join Date
    Oct 2011
    Posts
    2
    Many thanks... So, it's not an easy task. How about other hardware?? Like motherboard or CPU serial number? As i know i can't obtain this number either. Actually i want to obtain a unique number from hardware, at least 2 hardware then recreate new unique number from this number. I got HDD serial number but other hardware seems really hard to get if just using Grub itself.

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by jeme View Post
    Many thanks... So, it's not an easy task. How about other hardware?? Like motherboard or CPU serial number? As i know i can't obtain this number either. Actually i want to obtain a unique number from hardware, at least 2 hardware then recreate new unique number from this number. I got HDD serial number but other hardware seems really hard to get if just using Grub itself.
    Of course. Grub doesn't need anything but the HDD, and bootloaders are no-fat. Fordy's point is that the boatloader is not the kernel, and the kernel is what initializes much of your hardware. You might be better off doing this via a autoloaded kernel module, or even a regular user-space tool. Why do you believe this must take place before the kernel is loaded?
    Last edited by MK27; 10-19-2011 at 08:09 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #6
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    GRUB supports network boot and has a number of drivers for various NICs to enable that. It probably isn't impossible to either call back into GRUB for some basic network functions, or extract GRUB's network driver and adapt it to your own situation somehow.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GRUB from windows
    By underline_bruce in forum Linux Programming
    Replies: 2
    Last Post: 07-08-2008, 05:34 AM
  2. like grub or lilo
    By enjoy in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 10-24-2007, 10:43 AM
  3. Grub
    By Wraithan in forum Tech Board
    Replies: 4
    Last Post: 07-27-2006, 05:21 PM
  4. Windows XP and Debian GRUB
    By kawk in forum Tech Board
    Replies: 5
    Last Post: 03-26-2006, 06:09 PM
  5. getting rid of grub
    By axon in forum Tech Board
    Replies: 3
    Last Post: 03-17-2004, 07:15 PM