⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getlabel.ext2.c

📁 linux下的一个mount工具
💻 C
字号:
/* * $Id: getlabel.ext2.c,v 1.1.1.1 2000/09/13 19:36:41 lyonel Exp $ * * Copyright (c) 2000, Lyonel VINCENT <vincentl@ec-lyon.fr> * * This file may be redistributed under the terms of the GNU Public * License. * * Taken from aeb's mount, 990619 */#include <stdio.h>#include <string.h>#include <ctype.h>#include <fcntl.h>#include <unistd.h>#define EXT2_SUPER_MAGIC    0xEF53struct ext2_super_block_struct {        unsigned char   s_dummy1[56];        unsigned char   s_magic[2];        unsigned char   s_dummy2[46];        unsigned char   s_uuid[16];        unsigned char   s_volume_name[16];};typedef struct ext2_super_block_struct ext2_super_block;#define ext2magic(s)    ((unsigned int) s.s_magic[0] + (((unsigned int) s.s_magic[1]) << 8))int ext2_getlabel(int fd, char *label) {	/* start with a test for ext2, taken from mount_guess_fstype */	ext2_super_block e2sb;	if (lseek(fd, 1024, SEEK_SET) != 1024	    || read(fd, (char *) &e2sb, sizeof(e2sb)) != sizeof(e2sb)	    || (ext2magic(e2sb) != EXT2_SUPER_MAGIC)) {		return 0;	}	strncpy(label, e2sb.s_volume_name, sizeof(e2sb.s_volume_name));	return 1;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -