Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6905601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:12:15+00:00 2026-05-27T08:12:15+00:00

I’m having some problems with this system call and probably with kmalloc. Well ,

  • 0

I’m having some problems with this system call and probably with kmalloc.

Well , basically I’m building a system call , and this system call and the kernel are compiled without a problem.
But when I call my system call , the shell shows a lot of message and then the computer crash.

I think the problem is with the kmalloc , because when I remove the kmalloc and other code that envolves the kmalloc the system call works perfectly.

For example: bloqueados = kmalloc(sizeof(struct bloqueio),GFP_ATOMIC);

Just to add :
Maybe it’s ocurring a deadlock , but I don’t know accuratelly.

Thank you.

This is the code :

#include <linux/linkage.h>
#include <linux/io_block_unblock.h>
//#include <linux/printk.h>
#include <linux/kernel.h>
#include <linux/unistd.h>
#include <linux/stddef.h>
#include <linux/slab.h>
#include <linux/gfp.h>
#include <linux/unistd.h>
#include <linux/uaccess.h>
#include <linux/fs.h>
#include <linux/mount.h>
#include <linux/genhd.h>
#include <linux/device.h>

struct bloqueio *bloqueados;
EXPORT_SYMBOLL(bloqueados);
asmlinkage long sys_io_block(const char __user *particao, const char __user *arquivo){
    int id_inode;
    struct file *arq;
    char *part;
    struct bloqueio *tmp;
    arq  = filp_open(arquivo,O_CREAT, S_IRWXU);
    printk(KERN_EMERG "\nstruct file criado para o arquivo %s",arquivo);
    id_inode = arq->f_path.dentry->d_inode->i_ino;
    printk(KERN_EMERG "\nO inode do arquivo %s e  %d",arquivo, id_inode);
    //part = arq->f_path.mnt->mnt_sb->s_bdev->bd_part->__dev.init_name;
    //printk(KERN_EMERG "\nA particao a qual o arquivo se encontra e %s",part);
    if(bloqueados == NULL){
            bloqueados = kmalloc(sizeof(struct bloqueio),GFP_ATOMIC);//<--------------
            if(!bloqueados){
                    printk(KERN_EMERG "\n Erro ao alocar memoria");
                    return 0;
            }
            bloqueados->inode = id_inode;
            bloqueados->tipo = 0;
            bloqueados->prox = NULL;
    }
    else
    {
            tmp = kmalloc(sizeof(struct bloqueio), GFP_ATOMIC);//<--------------------
            if(!bloqueados){
                    printk(KERN_EMERG "\n Erro ao alocar memoria");
                    return 0;
            }
            tmp->inode = id_inode;
            tmp->tipo = 0;
            tmp->prox = bloqueados->prox;
            bloqueados->prox = tmp;
    }
    return 1;

}

Just to add , this is the struct bloqueio.

extern int contem(const char *arquivo);

struct bloqueio{
   int inode;
   int tipo;   // 0 -> arquivo   1 -> partição
   struct bloqueio *prox;
};

 extern struct bloqueio *bloqueados;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:12:15+00:00Added an answer on May 27, 2026 at 8:12 am

    Apparently I can’t comment yet, so I will ask a couple questions as an answer…

    I see “EXPORT_SYMBOLL(bloqueados);” … was this a mistype just in your copy/paste or is that mistyped in the actual code? This could be a problem…

    Whats the reason you are using GFP_ATOMIC vs GFP_KERNEL?

    This may help,

    http://www.linuxjournal.com/article/6930

    It recommends not using GFP_ATOMIC if you don’t absolutely need it… because it can fail. I might be missing something, but I don’t see why you need it… you don’t appear to be using any locks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.