125a126 > #ifndef __FreeBSD__ 240a242,289 > #else /* defined __FreeBSD__ */ > /* Make grub_guess_root_device() to use statfs(2) on FreeBSD system > ** in order to locate the device associated to a mount point. > ** The diactivated section of the function make the function skip > ** the slice and bsdlabel portion of the device name. > */ > #include > #include > #include > #include > char * > grub_guess_root_device (const char *path) > { > char *ret = NULL; > struct statfs sfsb; > > if ( !statfs (path, &sfsb) ) > {/* > char *endp = sfsb.f_mntfromname, > *s = path; > size_t l; > for (l = 0; l < MNAMELEN && *s; ++l, ++s); > endp += l - 1; > while ( *endp != '/' ) // emulate basename(3) > --endp; > while ( *endp < '0' || *endp > '9' ) // skip driver name > ++endp; > while ( *endp >= '0' && *endp <= '9' ) // skip driver unit > ++endp; > l = endp - sfsb.f_mntfromname; // adjust length > ret = xmalloc (l+1); > if ( ret ) > { > strncpy (ret, sfsb.f_mntfromname, l); > ret[l] = '\0'; > } > */ > ret = xmalloc (MNAMELEN); > strncpy (ret, sfsb.f_mntfromname, MNAMELEN); > } > else > { > grub_util_error ("Cannot stat `%s'", path); > } > > return ret; > } > #endif /* __FreeBSD__ */