No such device or address linux

bash: /dev/scull: No such device or address

What i did in mistake, please help. Maybe i forgot something.

Apr 14 19:17:14 XLDD kernel: [ 5765.234335] SCULL: device number registration. Apr 14 19:17:14 XLDD kernel: [ 5765.234349] SCULL: debug, scull_init 34 device: F500000 MAJOR: 245 MINOR: 0 count: 1 Apr 14 19:17:14 XLDD kernel: [ 5765.234353] SCULL: success device registration Apr 14 19:17:15 XLDD kernel: [ 5766.384094] SCULL: device number unregistration. Apr 14 19:17:15 XLDD kernel: [ 5766.384109] SCULL: debug, scull_exit 66 device: F500000 MAJOR: 245 MINOR: 0 count: 1 Apr 14 19:17:15 XLDD kernel: [ 5766.384113] SCULL: done device registration 
root@XLDD:/usr/src# make make -C /usr/src/linux-headers-4.10.0-42-generic M=`pwd` make[1]: Entering directory '/usr/src/linux-headers-4.10.0-42-generic' Building modules, stage 2. MODPOST 1 modules make[1]: Leaving directory '/usr/src/linux-headers-4.10.0-42-generic' root@XLDD:/usr/src# insmod scull.ko root@XLDD:/usr/src# mknod /dev/scull c 245 0 root@XLDD:/usr/src# echo "Hello" > /dev/scull bash: /dev/scull: No such device or address root@XLDD:/usr/src# 
#include /* MODULE_LICENSE() MODULE_AUTHOR() */ #include /* init() exit() */ #include /* Used for uint8 e.t.c types */ #include /* Undefined what it is for */ #include /* Used for working with inode */ #include /* Used for errors handling */ #include /* Used for device registration */ #include "scull.h" #include "scull_operations.h" #include "scull_helpers.h" static int scull_init(void) < int alloc_result = 0; /*! * Character device registration: * 0 - success * negative - unsuccess */ printk(KERN_ALERT "SCULL: device number registration. \n"); alloc_result = alloc_chrdev_region(&scull_dev.dev, SCULL_DEV_FIRSTMIRROR, SCULL_DEV_COUNT,SCULL_DEV_NAME); /*! * Checking character device number registration */ if(alloc_result != 0) < printk(KERN_ALERT "SCULL: unsuccess device number registration error code:%d\n",alloc_result); >else < #ifdef SCULL_DEBUG printk(KERN_ALERT "SCULL: debug, %s %d device: %X MAJOR: %d MINOR: %d count: %u\n",__func__,__LINE__,scull_dev.dev,MAJOR(scull_dev.dev),MINOR(scull_dev.dev),SCULL_DEV_COUNT); #endif /* SCULL_DEBUG */ printk(KERN_ALERT "SCULL: success device registration\n"); >/*! * Filling scull file operations */ scull_fops.owner = THIS_MODULE; scull_fops.open = scull_open; scull_fops.read = scull_read; scull_fops.write = scull_write; /*! * Initialize a scull_dev structure * remembering fops, making it ready to add to the system with cdev_add */ cdev_init(&scull_cdev, &scull_fops); return 0; > static void scull_exit(void) < /*! * Remove a character device from the system */ cdev_del(&scull_cdev); /*!< Remove a character device from the system */ /*! * Character device number unregistration: */ printk(KERN_ALERT "SCULL: device number unregistration. \n"); #ifdef SCULL_DEBUG printk(KERN_ALERT "SCULL: debug, %s %d device: %X MAJOR: %d MINOR: %d count: %u\n",__func__,__LINE__,scull_dev.dev,MAJOR(scull_dev.dev),MINOR(scull_dev.dev),SCULL_DEV_COUNT); #endif /* SCULL_DEBUG */ unregister_chrdev_region(scull_dev.dev, SCULL_DEV_COUNT); /*!< Character device number unregistration */ printk(KERN_ALERT "SCULL: done device registration\n"); >module_init(scull_init); module_exit(scull_exit); 
#ifndef SCULL_CONFIG_H #define SCULL_CONFIG_H #include /* struct dev_t */ #include /* file operations */ #include /* struct cdev */ #define SCULL_DEV_COUNT 1 #define SCULL_DEV_NAME "scull" #define SCULL_DEV_FIRSTMIRROR 0 MODULE_LICENSE("GNU"); MODULE_AUTHOR("Andriy Veres"); /*! * data, that store big (12 bits) and little (20 bits) * device numbers (driver and device numbers correspondly). * */ struct cdev scull_cdev; struct file_operations scull_fops; struct scull_dev < dev_t dev; /* used for device registration */ //struct scull_qset * data; /* Pointer to first quantum */ //int quantum; /* Size of current quantum */ //int qset; /* Size of quantum set */ //unsigned long size; /* Size of data stored hear */ //unsigned int access_key; /* used by sculluid and scullpriv */ //struct semaphore sem; /* Semaphore both exeption */ //struct cdev cdev; /* Symbol device structure */ >scull_dev; /*! * Uncomment for debug */ #define SCULL_DEBUG #endif /* SCULL_CONFIG_H */ 
#include "scull_helpers.h" int scull_trim(scull_dev * dev) < #ifdef SCULL_DEBUG printk(KERN_ALERT "SCULL: debug, %s %d device: \n",__func__,__LINE__); #endif /* SCULL_DEBUG */ return 0; >
 #ifndef SCULL_HELPERS_H #define SCULL_HELPERS_H #include "scull.h" int scull_trim(struct scull_dev * dev); #endif /* SCULL_HELPERS_H */ 
#include "scull_operations.h" int scull_open(struct inode *inode, struct file *filp) < #ifdef SCULL_DEBUG printk(KERN_ALERT "SCULL: debug, %s\n",__func__,__LINE__); #endif /* SCULL_DEBUG */ return 0; /* success */ >int scull_release(struct inode *inode, struct file *filp) < #ifdef SCULL_DEBUG printk(KERN_ALERT "SCULL: debug, %s\n",__func__,__LINE__); #endif /* SCULL_DEBUG */ return 0; >ssize_t scull_read(struct file *filp, char *buf, size_t count, loff_t *f_pos) < ssize_t result = count; #ifdef SCULL_DEBUG printk(KERN_ALERT "SCULL: debug, %s result: %d\n",__func__,__LINE__,result); #endif /* SCULL_DEBUG */ return result; >ssize_t scull_write(struct file *filp, const char *buf, size_t count, loff_t *f_pos) < ssize_t result = count; #ifdef SCULL_DEBUG printk(KERN_ALERT "SCULL: debug, %s result: %d\n",__func__,__LINE__,result); #endif /* SCULL_DEBUG */ return result; >
#ifndef SCULL_OPEARATIONS_H #define SCULL_OPEARATIONS_H int (*scull_open) (struct inode *, struct file *); int (*scull_release) (struct inode *, struct file *); ssize_t (*scull_read) (struct file *, char *, size_t, loff_t *); ssize_t (*scull_write) (struct file *, const char *, size_t, loff_t *); #endif /* SCULL_OPERATIONS_H */ 

Источник

Читайте также:  Linux echo text file

write пишет write: No such device or address

При попытке запустить так sudo ./run пишет ошибку write: No such device or address .

#include #include #include #include #include #include #include #include #include #include unsigned char ipsrc[4] = < 0xc0, 0xa8, 0x01, 0x05 >; unsigned char ipdst[4] = < 0xc0, 0xa8, 0x01, 0x02 >; unsigned char srchw[6] = < 0x74, 0x2f, 0x68, 0xa2, 0x87, 0xc6 >; unsigned char broadcast[6]= < 0xff, 0xff, 0xff, 0xff, 0xff, 0xff >; unsigned char unknown[6] = < 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 >; int main ( int argc, char *argv[] ) < int sock; if ( ( sock = socket ( AF_PACKET, SOCK_RAW, htons ( ETH_P_ALL ) ) ) == -1 ) // ETH_P_ARP < perror ( "socket" ); exit ( EXIT_FAILURE ); >int length = sizeof ( struct ether_header ) + sizeof ( struct ether_arp ); char buffer[length+1]; // length == 42 struct ether_header *eh = (struct ether_header *)&buffer[0]; struct ether_arp *ea = (struct ether_arp *) ( sizeof ( struct ether_header ) + &buffer[0] ); strncpy ( eh->ether_shost, srchw, ETH_ALEN ); strncpy ( eh->ether_dhost, broadcast, ETH_ALEN ); eh->ether_type = ETHERTYPE_ARP; ea->ea_hdr.ar_hrd = ARPHRD_ETHER; ea->ea_hdr.ar_pro = 0x800; ea->ea_hdr.ar_hln = 6; ea->ea_hdr.ar_pln = 4; ea->ea_hdr.ar_op = ARPOP_REQUEST; strncpy ( ea->arp_sha, srchw, ETH_ALEN ); strncpy ( ea->arp_tha, unknown, ETH_ALEN ); strncpy ( ea->arp_spa, ipsrc, 4 ); strncpy ( ea->arp_tpa, ipdst, 4 ); if ( write ( sock, buffer, length ) == -1 ) < perror ( "write" ); >close ( sock ); > 

Источник

No such device or address — Linux device driver development

When I try to cat /dev/gpio-reflect , I get the error: No such device or address cat proc/devices lists my driver with the correct major number. dmesg prints the logs form the init and exit functions. I also created the corresponding file under /dev (major is correct). cdev_add and alloc_chrdev_region don’t return error codes. I don’t know what i am doing wrong. Please help me.

static struct file_operations fops = < .owner = THIS_MODULE, .read = device_read, .write = device_write, .open = device_open, .release = device_release >; static int __init gpio_reflect_init(void) < int err,res=alloc_chrdev_region(&dev, 0, 1, dname); classptr = class_create(THIS_MODULE, "socledclass"); device_create(classptr, NULL, MAJOR(dev), NULL, dname); cdev_init(&c_dev, &fops); c_dev.ops=&fops; c_dev.owner=THIS_MODULE; err=cdev_add(&c_dev, MAJOR(dev), 1); if(err)< printk(KERN_INFO "Could not add device"); >if(res<0)< printk(KERN_INFO "Could not alloc device"); return res; >else < printk(KERN_INFO "Major: %i",MAJOR(dev)); >printk(KERN_INFO "Input Pin is: %i\n",in); printk(KERN_INFO "Output Pin is: %i\n",out); return 0; > static void __exit gpio_reflect_cleanup(void) < cdev_del(&c_dev); unregister_chrdev_region(dev,1); printk(KERN_INFO "%s unloaded\n",dname); >static int device_open(struct inode *inode, struct file *file) < printk(KERN_INFO "open\n"); if (Device_Open) return -EBUSY; Device_Open++; sprintf(msg, "Hello\n"); msg_Ptr = msg; try_module_get(THIS_MODULE); return SUCCESS; >static int device_release(struct inode *inode, struct file *file) < printk(KERN_INFO "release\n"); Device_Open--; module_put(THIS_MODULE); return SUCCESS; >static ssize_t device_read(struct file *filp, char *buffer,size_t length, loff_t * offset) < int bytes_read = 0; printk(KERN_INFO "read\n"); if (*msg_Ptr == 0) return 0; while (length && *msg_Ptr) < put_user(*(msg_Ptr++), buffer++); length--; bytes_read++; >return bytes_read; > static ssize_t device_write(struct file *filp, const char *buff, size_t len, loff_t * off) < printk(KERN_INFO "write\n"); printk(KERN_ALERT "Sorry, this operation isn't supported.\n"); return -EINVAL; >module_init(gpio_reflect_init); module_exit(gpio_reflect_cleanup); 

2 Answers 2

In case anyone has the same problem. It was just a stupid mistake.

Читайте также:  Linux last 100 lines

If your device node under /dev/ is /dev/gpio-reflect try cat /dev/gpio-reflect

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

No such device or address

scp is not the right tool to duplicate a remote filesystem, especially a live filesystem with mount points like /proc , /sys , etc. scp follows symbolic links (i.e. they will not be preserved during the copy) and thus may be caught in symlink loops like this. Use tar through ssh for such a duplication.

1 Answer 1

The process that is doing the recursion at the remote end is running as the superuser, and has recursed into /dev/fd . Several of its open file descriptors are for directories that it is in the process of reading as part of the recursion. Since they look like subdirectories as it traverses /dev/fd it is recursing them again.

It is even possible to determine what open file descriptors are open to what directories:

  • file descriptor #3 is open to /
  • file descriptor #5 is open to /dev/fd
  • file descriptor #31 is open to /dev

It has reached, via a long and circuitous route, a point where it is trying to open and copy /dev/rd/c6d16 , which does not correspond with a physical device.

Always be careful of commands, especially those run with superuser privileges, that will end up trying to naïvely open and copy all files in /dev , /device , /proc , /sys , and so forth. This has been unwise since the days that /dev was full of tape devices (sometimes with auto-rewind/auto-retension) and terminal devices that would block an open call until carrier was detected.

Читайте также:  Структура файлов системы linux

Ensure that if you really want to copy /dev , which most likely you do not given that on modern operating systems its contents are determined dynamically at runtime, you use a command that copies special device files, FIFOs, sockets, and symbolic links as themselves, rather than naïvely attempting to open and read them as if they were regular files. (Or that open() them and then fstat() to determine whether they are special devices, which will fail on device files that yield errors on open() .)

Источник

15.04 — Mounting using CIFS failing with «No such device or address»

Ok, it turns out that the problem was with the DNS resolution of the file server. It was trying to resolve the hostname «DFSAPP03» and failing. In my case the problem was fixed by using a different server address. The error:

cifs_mount failed w/return code = -6 

Probably indicates that while the authentication steps are all OK, these is a problem with actually finding the share on the network.

The directory on the remote computer needs to be shared, so that the host computer can access it. This is most easily done by using Nautilus file manager. You might have to install Nautilus if it is not your default file manager. On the remote computer, in Nautilus, right click on the directory you want to mount remotely. Select Properties. In the dialog window, select the checkbox «Share this folder.» You can also check if you want other users to be able to write to this folder. Select the «Create Share» button (or «Modify Share» if it is already created). Now you should be able to mount this directory (or share) remotely.

You must log in to answer this question.

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533

Ubuntu and the circle of friends logo are trade marks of Canonical Limited and are used under licence.

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

Оцените статью
Adblock
detector