Advertisement
Guest User

Untitled

a guest
Apr 25th, 2014
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. struct data{
  2. struct data *next;
  3. struct msghdr *msg;
  4. size_t len;
  5. }
  6.  
  7. struct data *head = NULL;
  8.  
  9. void add_to_end(struct data *newData){
  10. struct data *temp1;
  11. if (head == NULL){
  12. head = (struct data *)kmalloc(sizeof(struct data),GFP_KERNEL);
  13. head = newData;
  14. } else {
  15. temp1 = (struct data *)kmalloc(sizeof(struct data),GFP_KERNEL);
  16. temp1 = head;
  17. while(temp1->next!=NULL) {
  18. temp1 = temp->next;
  19. }
  20. temp1->next = newData;
  21. }
  22. }
  23.  
  24. struct data *temp;
  25.  
  26. temp = (struct data *)kmalloc(sizeof(struct data),GFP_KERNEL);
  27. temp->next = NULL;
  28. temp->msg = (struct msghdr *)kmalloc(sizeof(struct msghdr),GFP_KERNEL);
  29. temp->msg = message;
  30. temp->len = length;
  31. add_to_end(temp);
  32.  
  33. temp->msg = (struct msghdr *)kmalloc(sizeof(struct msghdr),GFP_KERNEL);
  34. // temp->msg = message;
  35. memcpy(temp->msg, message, sizeof(struct msghdr));
  36.  
  37. DEFINE_RAW_SPINLOCK(mylock);
  38. LIST_HEAD(vm_list);
  39.  
  40. ....
  41. my_function() {
  42. ....
  43. raw_spin_lock(&kvm_lock);
  44. list_for_each_entry(kvm, &vm_list, vm_list)
  45. *val += *(u32 *)((void *)kvm + offset);
  46. raw_spin_unlock(&kvm_lock);
  47.  
  48. }
  49.  
  50. head = (struct data *)kmalloc(sizeof(struct data),GFP_KERNEL);
  51. head = newData;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement