LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 01-10-2020, 01:47 AM   #1
Ashok Selvaraj
LQ Newbie
 
Registered: Jan 2020
Posts: 1

Rep: Reputation: Disabled
Open and write data to binary file in Kernel


Hi All,

My Ask is to write data to a binary file in Kernel code.Is there any option in kernel to save data as binary file.

In userspace we have functions like fwrite() and fread() to operate on binary file, Similarly need some functions in kernel.

Used vfs_write() in order to store the data as hex. Similarly need function to store it as bin.

file = file_open(log_file, O_CREAT | O_BINARY | O_RDWR | O_APPEND, 00644);
vfs_write(file, data, size, &offset);

Used this O_BINARY option, but this doesn't help. Is there any other way to write it as binary data.?
Any help is much appreciated.

#linux #binary #vfs_write #O_BINARY

Thanks in Advance,
Ashok
 
Old 01-10-2020, 06:21 AM   #2
phantom_cyph
Senior Member
 
Registered: Feb 2007
Location: The Tropics
Distribution: Slackware & Derivatives
Posts: 2,472
Blog Entries: 1

Rep: Reputation: 128Reputation: 128
Chances are if you're editing the kernel in this way.. you should stop and ask yourself.. "why?"..

That being said, you have not mentioned what your actual goal/use case is, the distribution of Linux or even the kernel/version you're attempting to do this with.

Should also mention that adding "binaries" to Linux .. anywhere.. generally won't be seen with much appeal.

Try and give more info and you might get some more replies.
 
  


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
[SOLVED] Write a script that searches a txt file and write's specific data to a new file tomtweber Programming 22 02-22-2014 12:36 PM
.oui: cannot execute binary file .oui: cannot execute binary file .oui kazi9822 Linux - Server 18 09-28-2012 04:44 PM
write a file fo data array (with float values) in a binary format in Python justinlapin Programming 3 04-06-2012 04:35 AM
Help: Opening GenICs binary file, writing to binary file for GADGET-2 (in C) parallax147 Programming 0 10-05-2010 11:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 10:06 PM.

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