About signal handler install info

2011-12-01 Thread naveen yadav
Dear All,

I want to know is there any method/API  to know whether there is
previous signal handler for specific signal no.

Example:

In below case  we install 3 handler. So my question is if before
calling signal (SIGUSR1, handler2); is there any way i can get info
that there is handler1 already install with SIGUSR1.

signal (SIGUSR1, handler1);
signal (SIGUSR1, handler2);
signal (SIGUSR1, handler3);

#include stdio.h
#include stdlib.h
#include pthread.h
#include signal.h

void *func ();

void handler1 ()
{
printf (\nIn handler 1\n);
}

void handler2 ()
{
printf (\nIn handler 2\n);
}

void handler3 ()
{ printf (\nIn handler 3\n); }
int main ()
{
int err=-1;
pthread_t t1,t2;


signal (SIGUSR1, handler1);
sleep(5);
signal (SIGUSR1, handler2);
sleep(5);
signal (SIGUSR1, handler3);
sleep(5);
pthread_create (t1, NULL, func, NULL);

sleep(20);

return 0;
}

void *func()
{
while (1) usleep(10);
}

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: About signal handler install info

2011-12-01 Thread rahul dev
See sigaction.

--- On Thu, 1/12/11, naveen yadav yad.nav...@gmail.com wrote:

 From: naveen yadav yad.nav...@gmail.com
 Subject: About signal handler install info
 To: Kernelnewbies@kernelnewbies.org, kernelnewb...@nl.linux.org
 Date: Thursday, 1 December, 2011, 3:33 PM
 Dear All,
 
 I want to know is there any method/API  to know
 whether there is
 previous signal handler for specific signal no.
 
 Example:
 
 In below case  we install 3 handler. So my question is
 if before
 calling signal (SIGUSR1, handler2); is there any way i can
 get info
 that there is handler1 already install with SIGUSR1.
 
         signal (SIGUSR1, handler1);
         signal (SIGUSR1, handler2);
         signal (SIGUSR1, handler3);
 
 #include stdio.h
 #include stdlib.h
 #include pthread.h
 #include signal.h
 
 void *func ();
 
 void handler1 ()
 {
         printf (\nIn handler 1\n);
 }
 
 void handler2 ()
 {
         printf (\nIn handler 2\n);
 }
 
 void handler3 ()
 { printf (\nIn handler 3\n); }
 int main ()
 {
         int err=-1;
         pthread_t t1,t2;
 
 
         signal (SIGUSR1, handler1);
         sleep(5);
         signal (SIGUSR1, handler2);
         sleep(5);
         signal (SIGUSR1, handler3);
         sleep(5);
         pthread_create (t1, NULL,
 func, NULL);
 
         sleep(20);
 
         return 0;
 }
 
 void *func()
 {
         while (1) usleep(10);
 }
 
 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
 

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Booting root filesystem from usb device

2011-12-01 Thread Ezequiel García


--- El mié 30-nov-11, Greg KH g...@kroah.com escribió:

 Then just pass the command line option to sleep for a while
 before
 looking for the root device.  I do that just fine on
 my tiny dns server
 that runs from a USB flash drive.
 
 Look in Documentation/kernel-parameters.txt for the
 rootdelay= option
 for more details as to what to do.
 
It worked like a charm. Looking at kernel-parameters.txt, I also 
came across rootwait option. 

If someone reads this and is trying 
something similar (using lilo) you may find this useful:

http://lkml.indiana.edu/hypermail/linux/kernel/1105.2/03866.html

Thanks,
Ezequiel.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: VFAT i_pos value

2011-12-01 Thread OGAWA Hirofumi
Kai Meyer k...@gnukai.com writes:

 I'm getting this error:
 FAT: Filesystem error (dev sblsnap0)
  fat_get_cluster: invalid cluster chain (i_pos 523791)

 I'm wondering if there was a way to figure out what sector is causing 
 the error? I would like to try and track down what is changing that 
 sector and fix the problem. Is there a straight forward way to convert 
 i_pos to a sector value? I've been staring at the fat.c and fat.h code 
 all morning, and I'm having trouble grok'ing the flow.

The i_pos means directory entry (contains inode information in unix-fs)
position,

block number == i_pos / (logical-blocksize / 32)
offset   == i_pos  (logical-blocksize / 32)

the above position's directory entry contains information for
problematic file. This is how to use i_pos information.

FWIW, in this error case, the cluster chain in FAT table which is
pointed by that entry, it has invalid cluster value.

Thanks.
-- 
OGAWA Hirofumi hirof...@mail.parknet.co.jp

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: VFAT i_pos value

2011-12-01 Thread Kai Meyer
On 12/01/2011 07:38 AM, OGAWA Hirofumi wrote:
 Kai Meyerk...@gnukai.com  writes:

 I'm getting this error:
 FAT: Filesystem error (dev sblsnap0)
   fat_get_cluster: invalid cluster chain (i_pos 523791)

 I'm wondering if there was a way to figure out what sector is causing
 the error? I would like to try and track down what is changing that
 sector and fix the problem. Is there a straight forward way to convert
 i_pos to a sector value? I've been staring at the fat.c and fat.h code
 all morning, and I'm having trouble grok'ing the flow.
 The i_pos means directory entry (contains inode information in unix-fs)
 position,

  block number == i_pos / (logical-blocksize / 32)
  offset   == i_pos  (logical-blocksize / 32)

 the above position's directory entry contains information for
 problematic file. This is how to use i_pos information.

 FWIW, in this error case, the cluster chain in FAT table which is
 pointed by that entry, it has invalid cluster value.

 Thanks.

If you would verify my math for me, I would appreciate it.

In this case, my logical block size is 4096, because byte 13 of the 8Gb 
file system is 8, and I take that to be 8 * 512, which is 4096. So:

block_number = 523791 / (4096 / 32) = 4092
offset = 523791 % (4096 / 32) = 15  // I assume you meant modulo in your 
original post, and not binary AND.

So if the block_number is 4092, I would multiply that by 8 (sectors per 
logical block) to get the sector number:
32736

Does the error indicate that sector contains the corrupted data? Or is 
it the sector that contains the information that points to the corrupted 
data? Or is it something entirely different?

-Kai Meyer

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Understanding kmap/kunmap

2011-12-01 Thread Kai Meyer
I want to be able to copy data into a struct bio *, so I use 
bio_for_each_segment to loop through each bvec, like so:

void some_function(struct bio *bio, char *some_data) {
 struct bio_vec *bvec;
 int i;
 unsigned int bio_so_far = 0;
 bio_for_each_segment(bvec, bio, i) {
 char *bio_buffer = __bio_kmap_atomic(bio, i, KM_USER0);
 memcpy(bio_buffer, some_data + bio_so_far, bvec-bv_len);
 __bio_kunmap_atomic(bio, KM_USER0);
 bio_so_far += bvec-bv_len;
 }
}

There's lots more to the function, but this is basically the distilled 
version with out any extra stuff.

What I'm finding is that when the bio has multiple bvecs that share the 
same page, only the first bvec's data actually gets copied back up to 
user-space, the rest is garbage or null (meaning, what was there 
already). For instance, I see a lot of bios from vfat that are 4096 
bytes long but are comprised of 8 bvecs that are 512 bytes long that all 
have an offset to the same page.

I've tried doing just one kmap_atomic on the page by keeping track of 
what the last page I kmap'ed was, but that didn't fix the problem either.

Any documentation or high level explanation of kmap/kunmap or other 
ideas to try are welcome.

-Kai Meyer

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: VFAT i_pos value

2011-12-01 Thread OGAWA Hirofumi
Kai Meyer k...@gnukai.com writes:

 The i_pos means directory entry (contains inode information in unix-fs)
 position,

  block number == i_pos / (logical-blocksize / 32)
  offset   == i_pos  (logical-blocksize / 32)

 the above position's directory entry contains information for
 problematic file. This is how to use i_pos information.

 FWIW, in this error case, the cluster chain in FAT table which is
 pointed by that entry, it has invalid cluster value.

 Thanks.

 If you would verify my math for me, I would appreciate it.

 In this case, my logical block size is 4096, because byte 13 of the 8Gb 
 file system is 8, and I take that to be 8 * 512, which is 4096. So:

 block_number = 523791 / (4096 / 32) = 4092
 offset = 523791 % (4096 / 32) = 15  // I assume you meant modulo in your 
 original post, and not binary AND.

Whoops, you are right. (I forgot -1)

 So if the block_number is 4092, I would multiply that by 8 (sectors per 
 logical block) to get the sector number:
 32736

Right.

 Does the error indicate that sector contains the corrupted data?

No.

 Or is it the sector that contains the information that points to the
 corrupted data?

Right.

The i_pos is pointing a directory entry (include/linux/msdos_fs.h:
struct msdos_dir_entry).

And starthi (if FAT32) and start contain the pointer to next cluster
number. That message was outputted when walking in cluster chain.

If you want to see actual corrupted data, you can check the cluster
chain by pointing from that directory entry.

Thanks.
-- 
OGAWA Hirofumi hirof...@mail.parknet.co.jp

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Understanding kmap/kunmap

2011-12-01 Thread Kai Meyer
Correction. The problem occurs when 8 bios of size 512 with 1 bvec each 
all share the same page. I made a bad assumption previously.

-Kai Meyer

On 12/01/2011 10:49 AM, Kai Meyer wrote:
 I want to be able to copy data into a struct bio *, so I use
 bio_for_each_segment to loop through each bvec, like so:

 void some_function(struct bio *bio, char *some_data) {
   struct bio_vec *bvec;
   int i;
   unsigned int bio_so_far = 0;
   bio_for_each_segment(bvec, bio, i) {
   char *bio_buffer = __bio_kmap_atomic(bio, i, KM_USER0);
   memcpy(bio_buffer, some_data + bio_so_far, bvec-bv_len);
   __bio_kunmap_atomic(bio, KM_USER0);
   bio_so_far += bvec-bv_len;
   }
 }

 There's lots more to the function, but this is basically the distilled
 version with out any extra stuff.

 What I'm finding is that when the bio has multiple bvecs that share the
 same page, only the first bvec's data actually gets copied back up to
 user-space, the rest is garbage or null (meaning, what was there
 already). For instance, I see a lot of bios from vfat that are 4096
 bytes long but are comprised of 8 bvecs that are 512 bytes long that all
 have an offset to the same page.

 I've tried doing just one kmap_atomic on the page by keeping track of
 what the last page I kmap'ed was, but that didn't fix the problem either.

 Any documentation or high level explanation of kmap/kunmap or other
 ideas to try are welcome.

 -Kai Meyer

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: VFAT i_pos value

2011-12-01 Thread Kai Meyer


On 12/01/2011 12:20 PM, OGAWA Hirofumi wrote:
 Kai Meyerk...@gnukai.com  writes:

 The i_pos means directory entry (contains inode information in unix-fs)
 position,

   block number == i_pos / (logical-blocksize / 32)
   offset   == i_pos   (logical-blocksize / 32)

 the above position's directory entry contains information for
 problematic file. This is how to use i_pos information.

 FWIW, in this error case, the cluster chain in FAT table which is
 pointed by that entry, it has invalid cluster value.

 Thanks.
 If you would verify my math for me, I would appreciate it.

 In this case, my logical block size is 4096, because byte 13 of the 8Gb
 file system is 8, and I take that to be 8 * 512, which is 4096. So:

 block_number = 523791 / (4096 / 32) = 4092
 offset = 523791 % (4096 / 32) = 15  // I assume you meant modulo in your
 original post, and not binary AND.
 Whoops, you are right. (I forgot -1)

 So if the block_number is 4092, I would multiply that by 8 (sectors per
 logical block) to get the sector number:
 32736
 Right.

 Does the error indicate that sector contains the corrupted data?
 No.

 Or is it the sector that contains the information that points to the
 corrupted data?
 Right.

 The i_pos is pointing a directory entry (include/linux/msdos_fs.h:
 struct msdos_dir_entry).

 And starthi (if FAT32) and start contain the pointer to next cluster
 number. That message was outputted when walking in cluster chain.

 If you want to see actual corrupted data, you can check the cluster
 chain by pointing from that directory entry.

 Thanks.

Thanks for the helpful response. I'm not entirely sure I understand the 
next part though. I hacked a dirty entry dumper tool:

#include stdio.h
#include linux/msdos_fs.h
#include sys/types.h
#include sys/stat.h
#include fcntl.h
#include unistd.h
#include string.h

int main(int argc, char** argv)
{
 off_t pos = atoi(argv[2]);
 unsigned long block;
 off_t sector;
 unsigned int offset;
 int fd = open(argv[1], O_RDONLY);
 char buf[512];
 struct msdos_dir_entry dirent;
 block = pos / (4096 / 32);
 sector = block * 8;
 offset = pos % (4096 / 32);
 printf(block %lu, sector %lu, offset %u\n, block, sector, 
offset);
 lseek(fd, sector * 512, SEEK_SET);
 if (read(fd, buf, 512)  0) {
 fprintf(stderr, Unable to read from device %s\n, 
argv[1]);
 return -1;
 }
 memcpy(dirent, buf + offset, sizeof(dirent));
 printf(name  %s\n, dirent.name);
 printf(attr  %u\n, dirent.attr);
 printf(lcase %u\n, dirent.lcase);
 printf(ctime_cs  %u\n, dirent.ctime_cs);
 printf(ctime %u\n, dirent.ctime);
 printf(cdate %u\n, dirent.cdate);
 printf(adate %u\n, dirent.adate);
 printf(starthi   %u\n, dirent.starthi);
 printf(time  %u\n, dirent.time);
 printf(date  %u\n, dirent.date);
 printf(start %u\n, dirent.start);
 printf(size  %u\n, dirent.size);
}

Here's what it outputs:

./vfat_entry /dev/sblsnap0 523793
block 4092, sector 32736, offset 17
name
attr  255
lcase 255
ctime_cs  255
ctime 12799
cdate 12670
adate 8224
starthi   8224
time  23072
date  21061
start 32
size  2171155456

So, I take starthi, and shift 16 bits left, then and in the start value. 
That should give me the byte address of the first cluster of the file, 
correct?

Then I need to follow the cluster chain until I get a bad value.

Thanks

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: contribute to linux kernel

2011-12-01 Thread Mayank Agarwal
Hi all,

i have downloaded the linux kernel 2.6 from git.I have seen the you tube
video of how to modify and submit a patch to the linux kernel.I want to
know how should i get which projects i can contribute.I have failry good
knowledge of embedded linux,c,c++,etc.
Can any one guide me how can i effectively contribute to linux kernel.

Thanks and Regards,
Mayank

On Tue, Nov 15, 2011 at 4:05 AM, Mayank Agarwal mayank77fromin...@gmail.com
 wrote:


 Hi all,

 I have just joined the kernelnewbies.I want to contribute to linux kernel
 or to any of the open source ongoing projects.Has good experience in c,c++
 and linux programming.
 Please suggest how can i go about that.


 Regards,
 Mayank

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies