struct dev_t

device number(dev_t)

linux driver 2009-08-21 10:08:03 阅读26 评论0 字号:大中小

dev_t

description
    the dev_t type in is used to hold device numbers—both the major and minor

parts.

header: 
    #include

constructor: 
    MKDEV(int major, int minor);

method: 
    MAJOR(dev_t dev);    //obtain the major part of a dev_t 
    MINOR(dev_t dev);    //obtain the minor part of a dev_t 
    register_chrdev_region();    //manually obtain(register) device numbers

from the system 
    alloc_chrdev_region();        //allocate a major number  by kernel 
    unregister_chrdev_region();    //free the device number back to kernel

int print_dev_t(char *buffer, dev_t dev); //encode the device number into the given buffer; char *format_dev_t(char *buffer, dev_t dev); //encode the device number into the given buffer;
转载自:http://leewez.blog.163.com/blog/static/2958954620097211083517/
时间: 2024-08-06 11:57:11

struct dev_t的相关文章

struct inode 和 struct file

1.struct inode──字符设备驱动相关的重要结构介绍 内核中用inode结构表示具体的文件,而用file结构表示打开的文件描述符.Linux2.6.27内核中,inode结构体具体定义如下:struct inode {struct hlist_node    i_hash;struct list_head    i_list;struct list_head    i_sb_list;struct list_head    i_dentry;unsigned long        i

struct dirent/DIR

#include <dirent.h> struct dirent { long d_ino;//inode number索引节点号 off_t d_off;//offset to this dirent 在目录文件中的偏移 unsigned short d_reclen;//length of this d_name 文件名长 unsigned char d_type;//the type of d_name 文件类型 char d_name[NAME_MAX+1];//文件名,最长256字

struct stat结构体的详解和用法

[cpp] view plaincopy //! 需要包含de头文件 #include <sys/types.h> #include <sys/stat.h> int stat(const char *filename, struct stat *buf); //! prototype,原型 struct stat { dev_t       st_dev;     /* ID of device containing file -文件所在设备的ID*/ ino_t       s

S_ISREG等几个常见的宏 struct stat

S_ISLNK(st_mode):是否是一个连接.S_ISREG(st_mode):是否是一个常规文件.S_ISDIR(st_mode):是否是一个目录S_ISCHR(st_mode):是否是一个字符设备.S_ISBLK(st_mode):是否是一个块设备S_ISFIFO(st_mode):是否 是一个FIFO文件.S_ISSOCK(st_mode):是否是一个SOCKET文件 man 2 stat 可以查到stat数据结构,其中的st_mode就是上面几个宏的输入参数struct stat {

linux struct stat 文件结构信息

#include <sys/types.h> #include <sys/stat.h> #include <time.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { struct stat sb; struct tm *ptr; if (argc != 2) { fprintf(stderr, "Usage: %s <pat

VFS四大对象之一 struct super_block

linux虚拟文件系统四大对象: 1)超级块(super block) 2)索引节点(inode) 3)目录项(dentry) 4)文件对象(file) 现在先介绍第一个 一.super_block的含义: 超级块代表了整个文件系统,超级块是文件系统的控制块,有整个文件系统信息,一个文件系统所有的inode都要连接到超级块上,可以说,一个超级块就代表了一个文件系统. 说到inode是啥? 1 struct super_block { 2 struct list_head s_list; /* K

struct stat结构体简介

在使用这个结构体和方法时,需要引入: <sys/types.h> <sys/stat.h> struct stat这个结构体是用来描述一个linux系统文件系统中的文件属性的结构. 可以有两种方法来获取一个文件的属性: 1.通过路径: int stat(const char *path, struct stat *struct_stat); int lstat(const char *path,struct stat *struct_stat); 两个函数的第一个参数都是文件的路径

APUE学习笔记——4.2结构体 struct stat 及其相关函数介绍

以下不少内容来自man手册 结构体struct stat 结构体struct stat用于保存文件相关的所有信息. struct stat的基本成员如下所示 struct stat { dev_t st_dev; // 文件所在设备的设备id,可以分解为主设备号和此设备号 ino_t st_ino; // inode号 mode_t st_mode; // 文件的类型.存取权限等 nlink_t st_nlink; // 文件硬连接数 uid_t st_uid; // 文件拥有者的用户id gi

struct stat / lstat function

今天在看源码是碰到了这个结构和函数,感觉挺不错的,所以就记下了 #include <sys/types.h> #include <sys/stat.h> struct stat的用法 2010-12-09 17:35:20 分类: C/C++ 预备知识:1.    函数名: lstat       需要包含的头文件:            #include <sys/types.h> #include <sys/stat.h> 功 能: 获取一些文件相关的信