Sanjay Kumar, Noida | 1 Jul 07:02 2005

RE: KernelNewbies Wikki

Hi,
In the module registration function (loading) of the HelloDriverSource
http://wiki.kernelnewbies.org/wiki/HelloDriverSource
if the kmalloc fails for hello_msg, why do we need to release 
the semaphore.This is the code snippet:
	if (!hello_msg){
		up(&hello_sem);
		return -ENOMEM;
	}
Till this point, the semaphore has not even been initialized.
Am I missing something.

Sanjay.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://sanjayku.blogspot.com

>-----Original Message-----
>From: kernelnewbies-bounce <at> nl.linux.org [mailto:kernelnewbies-
>bounce <at> nl.linux.org] On Behalf Of Tyler
>Sent: Thursday, June 30, 2005 2:09 AM
>To: kernelnewbies <at> nl.linux.org
>Subject: KernelNewbies Wikki
>
>Hi all,
>
>I've added a section in the kernel newbies wikki : the
>KernelCodeRepository :
>http://wiki.kernelnewbies.org/wiki/KernelCodeRepository
>Every user can add some kernel code, so everybody can read it, learn
(Continue reading)

Hemant Mohapatra | 1 Jul 07:25 2005
Picon

Re: KernelNewbies Wikki

On 7/1/05, Sanjay Kumar, Noida <sanjayku <at> hcltech.com> wrote:

> Hi,

> if the kmalloc fails for hello_msg, why do we need to release
> the semaphore.This is the code snippet:
>         if (!hello_msg){
>                 up(&hello_sem);
>                 return -ENOMEM;
>         }

Please read the code carefully again:

static ssize_t hello_write(struct inode *inode, const char __user
*user_buf, size_t len, loff_t offset)
{
        ..
        down(&hello_sem);   --> semaphore initialized here.
        if (hello_msg) {
                kfree(hello_msg);
                hello_msg = kmalloc(len+1, GFP_KERNEL);
                if (!hello_msg) {
                        up(&hello_sem);  --> if fails,  change back to
original semval and return
                        return -ENOMEM;

..
}

Where is the problem?
(Continue reading)

Vishwas Manral | 1 Jul 07:33 2005

RE: KernelNewbies Wikki

Hemant/ Sanjay,

Sanjay is talking about the fact that, in the "loading" function itself
the semaphore is made up although it has not been "sema_init".

That said I think they are just "idiot modules" that have been put in
and of course may not work really perfectly.

Thanks,
Vishwas
-----Original Message-----
From: kernelnewbies-bounce <at> nl.linux.org
[mailto:kernelnewbies-bounce <at> nl.linux.org] On Behalf Of Hemant Mohapatra
Sent: Friday, July 01, 2005 10:55 AM
To: Sanjay Kumar, Noida
Cc: kernelnewbies <at> nl.linux.org
Subject: Re: KernelNewbies Wikki

On 7/1/05, Sanjay Kumar, Noida <sanjayku <at> hcltech.com> wrote:

> Hi,

> if the kmalloc fails for hello_msg, why do we need to release
> the semaphore.This is the code snippet:
>         if (!hello_msg){
>                 up(&hello_sem);
>                 return -ENOMEM;
>         }

Please read the code carefully again:
(Continue reading)

sundeep kumar | 1 Jul 07:34 2005
Picon

help

hello everybody,
i am trying to develope a VFS.. As i am new to this
field i was trying to learn the present structures.. I
was not able to follow the usage of the function
"filldir()".. please if anyone could help me out.. i
want to know the explanation of how it works.
with warm regards

sundeep

	
	
		
___________________________________________________________ 
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/

Hemant Mohapatra | 1 Jul 07:47 2005
Picon

Re: KernelNewbies Wikki

On 7/1/05, Vishwas Manral <Vishwas <at> sinett.com> wrote:

> Hemant/ Sanjay,
> 
> Sanjay is talking about the fact that, in the "loading" function itself
> the semaphore is made up although it has not been "sema_init".
> 
> That said I think they are just "idiot modules" that have been put in
> and of course may not work really perfectly.

Whoops, coffee withdrawl syndrome. My bad. 

The  "up" is a mistake before the semaphore initialization. I checked
the wrong part of the code.

./h
--

-- 
http://www.embedded-tutorials.com

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/

Tyler | 1 Jul 12:17 2005
Picon

Re: KernelNewbies Wikki

Sanjay Kumar, Noida a écrit :
> Hi,
> In the module registration function (loading) of the HelloDriverSource
> http://wiki.kernelnewbies.org/wiki/HelloDriverSource
> if the kmalloc fails for hello_msg, why do we need to release 
> the semaphore.This is the code snippet:
> 	if (!hello_msg){
> 		up(&hello_sem);
> 		return -ENOMEM;
> 	}
> Till this point, the semaphore has not even been initialized.
> Am I missing something.

Hi,
you're right : the up(&hello_sem) has nothong to do here.
Thanks.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/

MHD.Tayseer | 1 Jul 20:33 2005

current->uid is zero ?!

Hi everyone:
i'm implementing mkdir so i must set the uid and the gid of my newly 
created inode, but i've noticed that all of :
current->uid
current->euid
current->fsuid
are zeros ? am i doing something wrong or this result is right and i'm 
missing something ?
and what is the fsuid ? "difference from uid ?
thanks in advance
MHD.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/

MHD.Tayseer | 1 Jul 20:44 2005

d_instantiate(dentry, inode) makes a kernel bug

Hi All:
after reading some file_systems's mkdir to figure out the needed steps 
My simple mkdir looks like: "psudo code"
rahfs_inode_create:
{
    inode = new_inode()  
    underlying_fs_create_inode()
    insert_inode_hash(inode)
    mark_inode_dirty(inode)
    d_instantiate(dentry, inode)
}

when everything goes right the following a sig fault accure and an 
exerpt of the dmesg output is:
kernel BUG at fs/dcache.c:759!
invalid operand: 0000 [#1]
CPU:    0
EIP:    0060:[<c0168cbe>]    Not tainted
EFLAGS: 00010283   (2.6.4-52-default)
EIP is at d_instantiate+0xe/0x50
Process mkdir (pid: 5058, threadinfo=cbc18000 task=cbf0c030)
Call Trace:
 [<e1941a0f>] _rahfs_inode_create+0x5f/0x80 [rahfs]
 [<e1941a3a>] rahfs_mkdir+0xa/0x10 [rahfs]
 [<c01611d2>] vfs_mkdir+0xa2/0xf0
 [<c0163832>] sys_mkdir+0x92/0xd0
 [<c0107dc9>] sysenter_past_esp+0x52/0x79

neither dentry nor inode are null ? so what could cause a fault at 
d_instantiate ? have i miss initializing anything ?
(Continue reading)

MHD.Tayseer | 1 Jul 21:26 2005

Re: current->uid is zero ?!

Mattia Dongili wrote:

>Just trying my first guess: are you running mkdir as root?
>

>second guess: maybe has something to do with the uid eventually
>assigned through mount options?
>  
>
let me guess ? umm YANQ :)
thank you for pointing me to the answer
nice guessing :)
MHD

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/

Mattia Dongili | 1 Jul 18:01 2005
Picon

Re: current->uid is zero ?!

Hello!

On 7/1/05, MHD.Tayseer <gilmour <at> scs-net.org> wrote:
> Hi everyone:
> i'm implementing mkdir so i must set the uid and the gid of my newly
> created inode, but i've noticed that all of :
> current->uid
> current->euid
> current->fsuid
> are zeros ? am i doing something wrong or this result is right and i'm
> missing something ?

Just trying my first guess: are you running mkdir as root?

> and what is the fsuid ? "difference from uid ?

second guess: maybe has something to do with the uid eventually
assigned through mount options?

--

-- 
mattia
:wq!

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


Gmane