亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? device.c

?? Linux啟動程序grub的源碼分析與實現;
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* device.c - Some helper functions for OS devices and BIOS drives *//* *  GRUB  --  GRand Unified Bootloader *  Copyright (C) 1999,2000,2001,2002,2003,2004,2005  Free Software Foundation, Inc. * *  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. * *  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. *//* Try to use glibc's transparant LFS support. */#define _LARGEFILE_SOURCE       1/* lseek becomes synonymous with lseek64.  */#define _FILE_OFFSET_BITS       64#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#include <assert.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <errno.h>#include <limits.h>#include <stdarg.h>#ifdef __linux__# if !defined(__GLIBC__) || \        ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1)))/* Maybe libc doesn't have large file support.  */#  include <linux/unistd.h>     /* _llseek */# endif /* (GLIBC < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR < 1)) */# include <sys/ioctl.h>		/* ioctl */# ifndef HDIO_GETGEO#  define HDIO_GETGEO	0x0301	/* get device geometry *//* If HDIO_GETGEO is not defined, it is unlikely that hd_geometry is   defined.  */struct hd_geometry{  unsigned char heads;  unsigned char sectors;  unsigned short cylinders;  unsigned long start;};# endif /* ! HDIO_GETGEO */# ifndef FLOPPY_MAJOR#  define FLOPPY_MAJOR	2	/* the major number for floppy */# endif /* ! FLOPPY_MAJOR */# ifndef MAJOR#  define MAJOR(dev)	\  ({ \     unsigned long long __dev = (dev); \     (unsigned) ((__dev >> 8) & 0xfff) \                 | ((unsigned int) (__dev >> 32) & ~0xfff); \  })# endif /* ! MAJOR */# ifndef CDROM_GET_CAPABILITY#  define CDROM_GET_CAPABILITY	0x5331	/* get capabilities */# endif /* ! CDROM_GET_CAPABILITY */# ifndef BLKGETSIZE#  define BLKGETSIZE	_IO(0x12,96)	/* return device size */# endif /* ! BLKGETSIZE */#endif /* __linux__ *//* Use __FreeBSD_kernel__ instead of __FreeBSD__ for compatibility with   kFreeBSD-based non-FreeBSD systems (e.g. GNU/kFreeBSD) */#if defined(__FreeBSD__) && ! defined(__FreeBSD_kernel__)# define __FreeBSD_kernel__#endif#ifdef __FreeBSD_kernel__  /* Obtain version of kFreeBSD headers */# include <osreldate.h># ifndef __FreeBSD_kernel_version#  define __FreeBSD_kernel_version __FreeBSD_version# endif  /* Runtime detection of kernel */# include <sys/utsname.h>intget_kfreebsd_version (){  struct utsname uts;  int major; int minor, v[2];  uname (&uts);  sscanf (uts.release, "%d.%d", &major, &minor);  if (major >= 9)    major = 9;  if (major >= 5)    {      v[0] = minor/10; v[1] = minor%10;    }  else    {      v[0] = minor%10; v[1] = minor/10;    }  return major*100000+v[0]*10000+v[1]*1000;}#endif /* __FreeBSD_kernel__ */#if defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__)# include <sys/ioctl.h>		/* ioctl */# include <sys/disklabel.h># include <sys/cdio.h>		/* CDIOCCLRDEBUG */# if defined(__FreeBSD_kernel__)#  include <sys/param.h>#  if __FreeBSD_kernel_version >= 500040#   include <sys/disk.h>#  endif# endif /* __FreeBSD_kernel__ */#endif /* __FreeBSD_kernel__ || __NetBSD__ || __OpenBSD__ */#ifdef HAVE_OPENDISK# include <util.h>#endif /* HAVE_OPENDISK */#define WITHOUT_LIBC_STUBS	1#include <shared.h>#include <device.h>/* Get the geometry of a drive DRIVE.  */voidget_drive_geometry (struct geometry *geom, char **map, int drive){  int fd;  if (geom->flags == -1)    {      fd = open (map[drive], O_RDONLY);      assert (fd >= 0);    }  else    fd = geom->flags;  /* XXX This is the default size.  */  geom->sector_size = SECTOR_SIZE;  #if defined(__linux__)  /* Linux */  {    struct hd_geometry hdg;    unsigned long nr;        if (ioctl (fd, HDIO_GETGEO, &hdg))      goto fail;    if (ioctl (fd, BLKGETSIZE, &nr))      goto fail;        /* Got the geometry, so save it. */    geom->cylinders = hdg.cylinders;    geom->heads = hdg.heads;    geom->sectors = hdg.sectors;    geom->total_sectors = nr;        goto success;  }#elif defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__)# if defined(__FreeBSD_kernel__) && __FreeBSD_kernel_version >= 500040  /* kFreeBSD version 5 or later */  if (get_kfreebsd_version () >= 500040)  {    unsigned int sector_size;    off_t media_size;    unsigned int tmp;        if(ioctl (fd, DIOCGSECTORSIZE, &sector_size) != 0)      sector_size = 512;        if (ioctl (fd, DIOCGMEDIASIZE, &media_size) != 0)      goto fail;    geom->total_sectors = media_size / sector_size;        if (ioctl (fd, DIOCGFWSECTORS, &tmp) == 0)      geom->sectors = tmp;    else      geom->sectors = 63;    if (ioctl (fd, DIOCGFWHEADS, &tmp) == 0)      geom->heads = tmp;    else if (geom->total_sectors <= 63 * 1 * 1024)      geom->heads = 1;    else if (geom->total_sectors <= 63 * 16 * 1024)      geom->heads = 16;    else      geom->heads = 255;    geom->cylinders = (geom->total_sectors			   / geom->heads			   / geom->sectors);        goto success;  }  else#endif /* defined(__FreeBSD_kernel__) && __FreeBSD_kernel_version >= 500040 */  /* kFreeBSD < 5, NetBSD or OpenBSD */  {    struct disklabel hdg;    if (ioctl (fd, DIOCGDINFO, &hdg))      goto fail;        geom->cylinders = hdg.d_ncylinders;    geom->heads = hdg.d_ntracks;    geom->sectors = hdg.d_nsectors;    geom->total_sectors = hdg.d_secperunit;    goto success;  }  #else  /* Notably, defined(__GNU__) */# warning "Automatic detection of geometries will be performed only \partially. This is not fatal."#endif fail:  {    struct stat st;    /* FIXME: It would be nice to somehow compute fake C/H/S settings,       given a proper st_blocks size. */    if (drive & 0x80)      {	geom->cylinders = DEFAULT_HD_CYLINDERS;	geom->heads = DEFAULT_HD_HEADS;	geom->sectors = DEFAULT_HD_SECTORS;      }    else      {	geom->cylinders = DEFAULT_FD_CYLINDERS;	geom->heads = DEFAULT_FD_HEADS;	geom->sectors = DEFAULT_FD_SECTORS;      }    /* Set the total sectors properly, if we can. */    if (! fstat (fd, &st) && st.st_size)      geom->total_sectors = st.st_size >> SECTOR_BITS;    else      geom->total_sectors = geom->cylinders * geom->heads * geom->sectors;  } success:  if (geom->flags == -1)    close (fd);}#ifdef __linux__/* Check if we have devfs support.  */static inthave_devfs (void){  static int dev_devfsd_exists = -1;    if (dev_devfsd_exists < 0)    {      struct stat st;            dev_devfsd_exists = stat ("/dev/.devfsd", &st) == 0;    }    return dev_devfsd_exists;}#endif /* __linux__ *//* These three functions are quite different among OSes.  */static voidget_floppy_disk_name (char *name, int unit){#if defined(__linux__)  /* GNU/Linux */  if (have_devfs ())    sprintf (name, "/dev/floppy/%d", unit);  else    sprintf (name, "/dev/fd%d", unit);#elif defined(__GNU__)  /* GNU/Hurd */  sprintf (name, "/dev/fd%d", unit);#elif defined(__FreeBSD_kernel__)  /* kFreeBSD */  if (get_kfreebsd_version () >= 400000)    sprintf (name, "/dev/fd%d", unit);  else    sprintf (name, "/dev/rfd%d", unit);#elif defined(__NetBSD__)  /* NetBSD */  /* opendisk() doesn't work for floppies.  */  sprintf (name, "/dev/rfd%da", unit);#elif defined(__OpenBSD__)  /* OpenBSD */  sprintf (name, "/dev/rfd%dc", unit);#elif defined(__QNXNTO__)  /* QNX RTP */  sprintf (name, "/dev/fd%d", unit);#else# warning "BIOS floppy drives cannot be guessed in your operating system."  /* Set NAME to a bogus string.  */  *name = 0;#endif}static voidget_ide_disk_name (char *name, int unit){#if defined(__linux__)  /* GNU/Linux */  sprintf (name, "/dev/hd%c", unit + 'a');#elif defined(__GNU__)  /* GNU/Hurd */  sprintf (name, "/dev/hd%d", unit);#elif defined(__FreeBSD_kernel__)  /* kFreeBSD */  if (get_kfreebsd_version () >= 400000)    sprintf (name, "/dev/ad%d", unit);  else    sprintf (name, "/dev/rwd%d", unit);#elif defined(__NetBSD__) && defined(HAVE_OPENDISK)  /* NetBSD */  char shortname[16];  int fd;    sprintf (shortname, "wd%d", unit);  fd = opendisk (shortname, O_RDONLY, name,		 16,	/* length of NAME */		 0	/* char device */		 );  close (fd);#elif defined(__OpenBSD__)  /* OpenBSD */  sprintf (name, "/dev/rwd%dc", unit);#elif defined(__QNXNTO__)  /* QNX RTP */  /* Actually, QNX RTP doesn't distinguish IDE from SCSI, so this could     contain SCSI disks.  */  sprintf (name, "/dev/hd%d", unit);#else# warning "BIOS IDE drives cannot be guessed in your operating system."  /* Set NAME to a bogus string.  */  *name = 0;#endif}static voidget_scsi_disk_name (char *name, int unit){#if defined(__linux__)  /* GNU/Linux */  sprintf (name, "/dev/sd%c", unit + 'a');#elif defined(__GNU__)  /* GNU/Hurd */  sprintf (name, "/dev/sd%d", unit);#elif defined(__FreeBSD_kernel__)  /* kFreeBSD */  if (get_kfreebsd_version () >= 400000)    sprintf (name, "/dev/da%d", unit);  else    sprintf (name, "/dev/rda%d", unit);#elif defined(__NetBSD__) && defined(HAVE_OPENDISK)  /* NetBSD */  char shortname[16];  int fd;    sprintf (shortname, "sd%d", unit);  fd = opendisk (shortname, O_RDONLY, name,		 16,	/* length of NAME */		 0	/* char device */		 );  close (fd);#elif defined(__OpenBSD__)  /* OpenBSD */  sprintf (name, "/dev/rsd%dc", unit);#elif defined(__QNXNTO__)  /* QNX RTP */  /* QNX RTP doesn't distinguish SCSI from IDE, so it is better to     disable the detection of SCSI disks here.  */  *name = 0;#else# warning "BIOS SCSI drives cannot be guessed in your operating system."  /* Set NAME to a bogus string.  */  *name = 0;#endif}#ifdef __linux__static voidget_dac960_disk_name (char *name, int controller, int drive){  sprintf (name, "/dev/rd/c%dd%d", controller, drive);}static voidget_ataraid_disk_name (char *name, int unit){  sprintf (name, "/dev/ataraid/d%c", unit + '0');}#endif/* Check if DEVICE can be read. If an error occurs, return zero,   otherwise return non-zero.  */intcheck_device (const char *device){  char buf[512];  FILE *fp;  /* If DEVICE is empty, just return 1.  */  if (*device == 0)    return 1;    fp = fopen (device, "r");  if (! fp)    {      switch (errno)	{#ifdef ENOMEDIUM	case ENOMEDIUM:# if 0	  /* At the moment, this finds only CDROMs, which can't be	     read anyway, so leave it out. Code should be	     reactivated if `removable disks' and CDROMs are	     supported.  */	  /* Accept it, it may be inserted.  */	  return 1;# endif	  break;#endif /* ENOMEDIUM */	default:	  /* Break case and leave.  */	  break;	}      /* Error opening the device.  */      return 0;    }    /* Make sure CD-ROMs don't get assigned a BIOS disk number      before SCSI disks!  */#ifdef __linux__# ifdef CDROM_GET_CAPABILITY  if (ioctl (fileno (fp), CDROM_GET_CAPABILITY, 0) >= 0)    return 0;# else /* ! CDROM_GET_CAPABILITY */  /* Check if DEVICE is a CD-ROM drive by the HDIO_GETGEO ioctl.  */  {    struct hd_geometry hdg;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美电视剧在线看免费| 欧美做爰猛烈大尺度电影无法无天| 亚洲黄色录像片| 亚洲欧美综合网| 亚洲特级片在线| 综合久久一区二区三区| 亚洲人成电影网站色mp4| 亚洲人xxxx| 亚洲国产精品一区二区久久恐怖片 | 色婷婷综合久久| 91成人国产精品| 欧美性色黄大片| 欧美一级生活片| 久久免费偷拍视频| 亚洲色图欧美激情| 午夜精品国产更新| 国产精品一区二区三区乱码| 国产不卡一区视频| 在线观看www91| 日韩三级.com| 国产精品久久久久永久免费观看| 一区二区三区精品视频| 三级久久三级久久久| 国产福利91精品| 91国在线观看| 久久久久久久久久久久久夜| 最新欧美精品一区二区三区| 日本欧美大码aⅴ在线播放| 国产资源精品在线观看| 色就色 综合激情| 欧美videofree性高清杂交| 国产精品毛片高清在线完整版| 亚洲一区二区视频在线| 国产一区不卡在线| 日本精品免费观看高清观看| 日韩欧美的一区| 亚洲另类一区二区| 国产在线视频一区二区三区| 91麻豆国产自产在线观看| 欧美一级免费大片| 亚洲免费三区一区二区| 激情图片小说一区| 欧美日韩免费电影| 国产精品嫩草影院av蜜臀| 亚洲精品老司机| 粗大黑人巨茎大战欧美成人| 国产很黄免费观看久久| 欧美色综合影院| 国产精品免费久久| 国产在线不卡一卡二卡三卡四卡| 91成人免费在线| 综合色天天鬼久久鬼色| 国产乱子轮精品视频| 日韩一区二区在线观看| 一区二区三区高清在线| 成人午夜视频在线观看| 精品福利av导航| 日本伊人午夜精品| 欧美三级中文字| 夜夜嗨av一区二区三区网页| 波多野结衣一区二区三区| 国产无遮挡一区二区三区毛片日本| 日本少妇一区二区| 宅男在线国产精品| 天天色天天爱天天射综合| 在线看一区二区| 一区二区成人在线| 色综合色综合色综合| 中文字幕一区二区三区av| 成人免费黄色在线| 中文字幕一区在线观看| 99精品欧美一区二区蜜桃免费| 国产欧美日韩三区| 成人免费三级在线| 日韩久久一区二区| 91九色02白丝porn| 日韩高清在线电影| 日韩欧美国产一区在线观看| 麻豆精品一区二区三区| 亚洲精品在线免费观看视频| 国内不卡的二区三区中文字幕| 精品国精品自拍自在线| 国产99精品视频| 国产精品传媒视频| 日本精品一区二区三区四区的功能| 一级日本不卡的影视| 欧美视频在线一区| 免费成人av资源网| 久久精品一区八戒影视| 91日韩一区二区三区| 亚洲一区二区三区激情| 欧美一区二区三区免费大片| 精品一区二区三区av| 国产日产欧美一区| 色天使色偷偷av一区二区| 丝袜a∨在线一区二区三区不卡| 日韩欧美不卡在线观看视频| 高清国产午夜精品久久久久久| 亚洲三级免费电影| 日韩一区二区三区观看| 成人动漫一区二区三区| 亚洲第一av色| 国产肉丝袜一区二区| 94色蜜桃网一区二区三区| 丝袜国产日韩另类美女| 国产拍揄自揄精品视频麻豆| 91国偷自产一区二区使用方法| 日本女优在线视频一区二区| 国产精品亲子乱子伦xxxx裸| 欧美酷刑日本凌虐凌虐| 国产不卡免费视频| 三级精品在线观看| 中文字幕亚洲综合久久菠萝蜜| 欧美日韩国产一级| 成人app网站| 久久9热精品视频| 亚洲成人综合网站| 欧美国产日韩a欧美在线观看| 在线不卡一区二区| 99久久精品国产网站| 精品在线播放午夜| 亚洲综合久久久| 国产精品久久一卡二卡| 日韩女优av电影| 精品视频999| 91欧美一区二区| 国产成人精品亚洲777人妖| 美国十次综合导航| 午夜精品久久久久久久久| 亚洲人快播电影网| 中文乱码免费一区二区| 精品成人一区二区三区| 日韩一区二区免费视频| 欧美日韩免费电影| 欧美做爰猛烈大尺度电影无法无天| 成人高清av在线| 成人av片在线观看| 丰满白嫩尤物一区二区| 国产一区二区看久久| 国内欧美视频一区二区 | 日韩一区二区在线看| 欧美视频在线不卡| 欧美日韩亚洲综合一区| 91成人免费在线| 欧美在线小视频| 欧美三级电影精品| 欧美午夜精品一区二区蜜桃| 欧美在线不卡视频| 精品视频全国免费看| 欧美三级电影在线观看| 欧美日本一道本| 91精品国产乱| 91精品在线麻豆| 久久综合九色综合久久久精品综合 | 国产成人综合在线观看| 国产成人欧美日韩在线电影| 国产高清不卡一区二区| 成人免费视频视频在线观看免费| 懂色av一区二区三区免费看| 不卡视频在线看| 在线视频欧美精品| 在线综合+亚洲+欧美中文字幕| 欧美一区二区三区日韩| 欧美成人精品3d动漫h| 国产人久久人人人人爽| 亚洲精品中文字幕乱码三区| 亚洲一区二区三区国产| 美国精品在线观看| 粉嫩嫩av羞羞动漫久久久| 91视频免费观看| 欧美电影一区二区| 久久久夜色精品亚洲| 亚洲图片激情小说| 日本va欧美va欧美va精品| 国产乱人伦精品一区二区在线观看 | 色爱区综合激月婷婷| 欧美一区二区三区思思人| 欧美精品一区二区在线观看| 欧美高清在线精品一区| 亚洲丶国产丶欧美一区二区三区| 免费成人结看片| 91小视频免费观看| 日韩欧美国产一区二区三区| 中文字幕中文字幕一区二区| 亚洲一区免费在线观看| 国产精品18久久久久久久久| 一本色道亚洲精品aⅴ| 欧美成人a视频| 一区二区三区久久久| 黑人巨大精品欧美一区| 欧亚一区二区三区| 国产精品视频一二| 秋霞国产午夜精品免费视频| av激情综合网| 精品日韩在线一区| 亚洲已满18点击进入久久| 国产麻豆视频精品| 欧美日产在线观看| 亚洲精品免费看| 国产久卡久卡久卡久卡视频精品|