SHARE
TWEET

Untitled

a guest Mar 19th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct file *kernel_open(const char *filename, int flags, umode_t mode) {
  2.     struct file *filp = NULL;
  3.     mm_segment_t oldfs = get_fs();
  4.     set_fs(get_ds());
  5.     filp = filp_open(filename, flags, mode);
  6.     set_fs(oldfs);
  7.     return filp;
  8. }
  9.  
  10. const char *filename = "/sys/bus/i2c/devices/6-0054/eeprom";
  11. struct file filp = kernel_open(filename, O_RDONLY, 0);
  12. if (IS_ERR(filp)) {
  13.     printk(KERN_ERR "Failed to open file (code: %d)n", PTR_ERR(filp));
  14.     return; <-- always return here
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top