LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 07-11-2009, 10:04 AM   #1
sticktrick
LQ Newbie
 
Registered: Jul 2009
Posts: 1

Rep: Reputation: 0
Device attribute in sysfs


Hi there...
I try to build additional device attributes in my module so they will appear in sysfs. But I can't build them and i can't find how to do it!?
Plz help...the atributes are "name", "pid", "pgdir"...

My source-code is:

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/device.h>
#include <linux/fs.h>


MODULE_DESCRIPTION("My kernel module");
MODULE_AUTHOR("root (root@bs-host)");
MODULE_LICENSE("GPL");

static char *name;
module_param(name, charp, 0644);

struct class *bs_class;
struct device *bs_device;
static int bs_Major;

//static int device_open(struct inode *, struct file *);
//static int device_release(struct inode *, struct file *);
//static ssize_t device_read(struct file *, char *, size_t, loff_t *);
//static ssize_t device_write(struct file *, const char *, size_t, loff_t *);

static struct file_operations fops = {
// .read = device_read,
// .write = device_write,
// .open = device_open,
// .release = device_release
};

struct driver_attribute {
char* name;
int pid;
int pgdir;
};

static int bs1_init_module(void)
{
printk("<0>Module BS1 init\n" );
bs_Major = register_chrdev(0,"bs-device", &fops);
if (bs_Major<0) {
printk(KERN_WARNING "Kann keine Major-Nummer bekommen!");
return bs_Major;
}
bs_class = class_create(THIS_MODULE,"bs-class");
bs_device = device_create(bs_class,NULL,MKDEV(bs_Major,0),"bs-device");
// DEVICE_ATTR(name,0644,show_debug, NULL);
//driver_create_file(bs_device,"Name");
return 0;
}

static void bs1_exit_module(void)
{
printk("<0>Module BS1 exit\n" );
class_destroy(bs_class);
device_destroy(bs_class,MKDEV(bs_Major,0));
unregister_chrdev(bs_Major,"bs-device");
}

module_init(bs1_init_module);
module_exit(bs1_exit_module);
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ldap_add: Undefined attribute type (17) additional info: ojectclass: attribute type vinaytp Linux - Newbie 2 05-28-2009 04:57 AM
how to create a device node in sysfs? hash123 Linux - Kernel 0 08-11-2008 01:41 AM
Sysfs use chessi Linux - Kernel 1 04-24-2007 03:59 PM
How to use sysfs? asahlot Linux - Kernel 1 01-21-2007 03:44 PM
sysfs do i need it for kernel 2.6? demmylls Linux - General 11 02-07-2004 01:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 08:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration