diff --git a/lab6/make.txt b/lab6/make.txt new file mode 100644 index 0000000..e69de29 diff --git a/lab6/pipe_tester.cpp b/lab6/pipe_tester.cpp index 33b40da..f1cf232 100644 --- a/lab6/pipe_tester.cpp +++ b/lab6/pipe_tester.cpp @@ -8,7 +8,16 @@ void writer() { std::osyncstream(std::cout) << "Writer started" << std::endl; std::ofstream pipe_write("/dev/wendy_in"); - pipe_write << "Hello from the other side\n"; + if (!pipe_write.is_open()) { + std::cerr << "Cannot open pipe in" << std::endl; + } + + std::ifstream txt("./make.txt"); + if (!txt.is_open()) { + std::cerr << "Canno open make.txt" << std::endl; + } + // pipe_write << "Hello from the other side\n"; + pipe_write << txt.rdbuf(); std::osyncstream(std::cout) << "Writer ended" << std::endl; } diff --git a/lab6/wendy_mod/wendy.c b/lab6/wendy_mod/wendy.c index 9192bd5..817641c 100644 --- a/lab6/wendy_mod/wendy.c +++ b/lab6/wendy_mod/wendy.c @@ -7,6 +7,7 @@ // https://linux-kernel-labs.github.io/refs/heads/master/labs/device_drivers.html // https://olegkutkov.me/2018/03/14/simple-linux-character-device-driver/ +// BEGIN_LST_DEF #define MYPIPE_BUFFER_SIZE 4096 #define MYPIPE_DEVICE_NAME "wendy" @@ -41,7 +42,9 @@ static DEFINE_MUTEX(isactive_lock); // writing/ reading static DECLARE_WAIT_QUEUE_HEAD(read_queue); static DECLARE_WAIT_QUEUE_HEAD(write_queue); +// END_LST_DEF +// BEGIN_LST_OPEN_RELASE static int mypipe_open(struct inode *inode, struct file *file) { int minor = iminor(inode); printk(KERN_INFO "%s opened, minor = %d", MYPIPE_DEVICE_NAME, minor); @@ -75,6 +78,9 @@ static int mypipe_release(struct inode *inode, struct file *file) { return 0; } +// END_LST_OPEN_RELEASE + +// BEGIN_LST_READ_WRITE static ssize_t mypipe_read(struct file *filep, char __user *buf, size_t size, loff_t *offset) { ssize_t ret = 0; @@ -199,11 +205,15 @@ out: return ret; } +// END_LST_READ_WRITE + +// BEGIN_LST_FOP const struct file_operations mypipe_fops = {.owner = THIS_MODULE, .open = mypipe_open, .read = mypipe_read, .write = mypipe_write, .release = mypipe_release}; +// END_LST_FOP // Used to set the permission to allow any user to r/w static int mypipe_uevent(const struct device *dev, @@ -212,6 +222,7 @@ static int mypipe_uevent(const struct device *dev, return 0; } +// BEGIN_LST_INIT static int __init mypipe_init(void) { int ret; dev_t dev; @@ -277,5 +288,6 @@ static void __exit mypipe_destroy(void) { module_init(mypipe_init); module_exit(mypipe_destroy); +// END_LST_INIT MODULE_LICENSE("GPL"); \ No newline at end of file