LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-01-2010, 09:32 AM   #1
Dufresne
LQ Newbie
 
Registered: Jul 2008
Posts: 23

Rep: Reputation: 16
Block Device and Partitions


Hi!
I'm working on a block device module nowadays.
I found a simple block device module but i couldn't make it the way that our instructor wants.
I can create device by inserting the module and i can create partitions via using fdisk .
My Question is ;

Is it possible to initialize and create partitions in the module code ?
If it's , how ?

BTW , i found some structs in genhd.h which are
Code:
struct disk_part_tbl {
	struct rcu_head rcu_head;
	int len;
	struct hd_struct *last_lookup;
	struct hd_struct *part[];
};

struct gendisk {
	/* major, first_minor and minors are input parameters only,
	 * don't use directly.  Use disk_devt() and disk_max_parts().
	 */
	int major;			/* major number of driver */
	int first_minor;
	int minors;                     /* maximum number of minors, =1 for
                                         * disks that can't be partitioned. */

	char disk_name[DISK_NAME_LEN];	/* name of major driver */
	char *(*nodename)(struct gendisk *gd);
	/* Array of pointers to partitions indexed by partno.
	 * Protected with matching bdev lock but stat and other
	 * non-critical accesses use RCU.  Always access through
	 * helpers.
	 */
	struct disk_part_tbl *part_tbl;
	struct hd_struct part0;

	struct block_device_operations *fops;
	struct request_queue *queue;
	void *private_data;

	int flags;
	struct device *driverfs_dev;  // FIXME: remove
	struct kobject *slave_dir;

	struct timer_rand_state *random;

	atomic_t sync_io;		/* RAID */
	struct work_struct async_notify;
#ifdef  CONFIG_BLK_DEV_INTEGRITY
	struct blk_integrity *integrity;
#endif
	int node_id;
};
When we create partitions with fdisk , are partitions stored in struct_part_tbl ?
I really need help on this,
By the way, my kernel version is 2.6

Last edited by Dufresne; 06-01-2010 at 09:51 AM.
 
Old 06-01-2010, 12:11 PM   #2
Dufresne
LQ Newbie
 
Registered: Jul 2008
Posts: 23

Original Poster
Rep: Reputation: 16
Or,
Can i create partitions via a bash-script or a C code ?
How can it be done ?
 
Old 06-01-2010, 12:47 PM   #3
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
You cannot use any libraries in kernel module code. So you can do anything you want to do, so long as you code it yourself.

Defining partitions in the kernel is the wrong thing to do. You should not take that route anyway.
 
1 members found this post helpful.
Old 06-01-2010, 04:43 PM   #4
Dufresne
LQ Newbie
 
Registered: Jul 2008
Posts: 23

Original Poster
Rep: Reputation: 16
Thanks for the advice.
I used bash script , and i get the result that i want.
 
  


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
Mtd driver as block device and char device Linux_Kid_ Linux - Kernel 1 12-27-2009 12:17 PM
Creating A New Device Node/Not A Valid Block Device indienick Debian 4 07-13-2007 02:07 PM
Difference between Block device and Character device quartslove Fedora 2 11-29-2006 08:50 PM
Block device /dev/sda3 is not a valid root device.. rincewind Linux - Hardware 7 06-09-2006 04:47 AM
UL 1.0 GRUB: could not find device for /boot: not found or not a block device cma Linux - General 4 12-12-2005 03:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:06 AM.

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