Linux MySQL login anomaly Error 1045 (28000): Access Denied for User ‘ROOT’@’LocalHost’ (USING Password: Yes)

2023-01-22   ES  

In the VXWORKS system, call the PCIFINDEVICE () function can directly get the BUS, Deviceno, and DeVFN data information of the specified device. Compared to the Linux system, VXWorks writing driver is relatively simple.

  LINUX system BUS, Deviceno, and DEVFN data are used by the driver’s internal function (these data are hardly used during the writing of the driver), and there is no clear interface, we need to analyze the method of calling these data by ourselves.

First enter in Terminal: lspci -vmmD;
这里写图片描述
  We see the first line of equipment information slot: 0000 represents the device domain, 02 represents BUS information, 05 represents DEVICENO information, 0 represents DEVFN information;

  After learning about the data information, start tracking PCI -related files, first follow the header file of Linux/PCI.H
    #define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f)
    #define PCI_FUNC(devfn) ((devfn) & 0x07),

  According to the defined name, we know that PCI_SLOT represents the PCI slot, PCI_FUNC represents the PCI function information (or description information), we got the conversion method of Deviceno and Devfn. The following continues to track the Struct PCI_DEV structure, the UNSIGNED Int Devfn is found in the structure, and here you can determine that Devfn and Deviceno are converted with this variable.

  Now you still need to get the BUS number. There is no definition BUS variable in the PCI_DEV structure, indicating that our device BUS number should not be obtained directly
Continue to check the PCI_DEV structure and find Struct PCI_BUSbus; / bus this device is on /, I saw this annotation understanding that the device BUS we was looking for was in the PCI_BUS structure. bus number */。

Now we know the method of obtaining these data. If you want to get the data, you need to use the Struct PCI_DEV *DEV pointer. The PCI entry function static into __init PCI_PROBE (struct PCI_DEV *DEV, Const Struct PCI_DEVICE_ID *ID) The first parameter is the pointer data we use to describe the specific implementation method with the PCI driver instance in the previous article. The code is posted below:

#define devname "test" 
 #Define className "class_test" 
 #Define vendorid 0xfa01 
 #define deviceid 0x1234 

 unsigned char bus; // Add BUS number definition 
 unsigned int Deviceno; 
 unsigned int devfn; 

 struct class *mem_class; 
 struct pci_test 
 {{ 
 struct cdev _cdev; 
 dev_t dev; 
 char msi_enabled; 
 }*pci_test; 


 Static int test_open (Struct Inode *Inode, Struct File *Filp) 
 {{ 
 Return 0; 
 } 

 Static int test_release (Struct Inode *Inode, Struct File *FILP) 
 {{ 
 Return 0; 
 } 


 Static Struct File_operations Test_fops = { 
 .OWner = This_module, 
 //.iOCTL = test_ioctl, 
 .opeen = test_open, 
 .rease = test_release, 
 }; 

 // character driver 
 Static Init_chrdev (Struct PCI_TEST *Test_ptr) 
 {{ 
 int Result = Alloc_chrdev_region (& Test_ptr-> DEV, 0, 2, Devname); 
 if (result <0) 
 {{ 
 Printk ("ERR: FAILED in Alloc_chrdev_region! \ N"); 
 Return result; 
 } 
 
 mem_Class = class_create (this_module, className); /// dev/ create devfile 
     if (IS_ERR (MEM_CLASS))) 
     {{ 
 Printk ("ERR: FAILED in Creating class! \ n"); 
   } 
 device_create (MEM_CLASS, NULL, TEST_PTR-> DEV, NULL, Devname); 

 CDEV_INIT (& Test_ptr-> _ CDEV, & Test_fops); 
 test_ptr-> _ cdev.Owner = this_module; 
 test_ptr-> _ cdev.ops = & test_fops; // create dev and file_operations connected 
 result = cdev_add (& test_ptr-> _ cdev, test_ptr-> dev, 1); 
 Return result; 
 } 

 // The PCI driver entry function adds Bus, Device, and DeVFN data acquisition methods in this function 
 static int __init PCI_PROBE (Struct PCI_DEV *DEV, Const Struct PCI_DEVICE_ID *ID) 
 {{ 
 int RC = 0; 
 pci_test = dev; 
     pCI_SET_DRVDATA (dev, pCi_test); 
     // Create a character device driver here 
 RC = Init_chrdev (PCI_TEST); 
     if (rc) {{ 
         dev_err (& dev-> dev, "init_chrdev () failed \ n"); 
         Return -1; 
     } 

 rc = pci_enable_device (dev); 
     if (rc) {{ 
         dev_err (& dev-> dev, "pci_enable_device () failed \ n"); 
        Return -1; 
     } 

 rc = pci_request_regions (dev, devname); 
     if (rc) {{ 
         dev_err (& dev-> dev, "pCi_request_regions () failed \ n"); 
         Return -1; 
     } 

     pCI_SET_MASTER (DEV); 
     rc = pci_enable_msi (DEV); 
    if (rc) {{ 
         dev_info (& dev-> dev, "pCi_enable_msi () failed \ n"); 
         pci_test-> msi_enabled = 0; 
     } else { 
         dev_info (& dev-> dev, "pCi_enable_msi () successful \ n"); 
        pci_test-> msi_enabled = 1; 
    } 

 // Here 
 bus = dev-> bus-> number; 
 deviceeno = ((dev-> devfn) >> 3) && 0x1f; 
 devfn = ((DEV-> DEVFN) && 0x07; 

 Return RC; 
 } 

 Static void __exit PCI_Remove (Struct PCI_DEV *DEV) 
 {{ 
     if (0! = MEM_Class) 
     {{ 
 device_destroy (MEM_CLASS, PCI_TEST-> DEV); 
 class_destroy (MEM_CLASS); 
 mem_class = 0; 
     } 

 pci_test = pci_get_drvdata (DEV); 
     cdev_del (& pci_test-> _ cDEV); 
     unregister_chrdev_region (PCI_TEST-> DEV, 1); 
    pci_disable_device (dev); 

     if (pci_test) { 
         if (PCI_TEST-> msi_enabled) {{ 
             pci_disable_msi (DEV); 
             pci_test-> msi_enabled = 0; 
         } 
     } 
 
     pci_release_regions (DEV); 
 } 

 Static Struct PCI_DEVICE_ID PCI_IDS [] = { 
     {PCI_DEVICE (VENDORID, Deviceid)}, 
     {0} 
 }; 

 Static Struct PCI_DRIVER DRIVER_OPS = { 
     .Name = Devname, 
     .id_table = PCI_IDS, 
     .probe = PCI_PROBE, 
     .remove = pci_remove, 
 }; 
 // Drive module entry function 
 static int test_init_module (VOID) 
 {{ 
 int RC = 0; 
 pci_test = kzalloc (sizeof (struct pci_test), gfp_kernel); 
 // The pairing device and the registered PCI driver, if the corresponding device calls the PCI entry function 
 rc = pci_register_driver (& driver_ops); 
     if (rc) {{ 
        Printk (kern_alert ": PCI Driver registration failed \ n"); 
     } 
 
 Return RC; 
 } 

 static void test_exit_module (void) 
 {{ 
 pci_unregister_driver (& driver_ops); 
 kfree (pci_test); 
 } 
 module_init (test_init_module); 
 module_exit (test_exit_module); 
 Module_author (devname); 
 Module_license ("gpl");

Previous PCI driver calling character device driver method:http://blog.csdn.net/a29562268/article/details/78446178!

source

Related Posts

View constraints, add constraints, delete the constraints added columns, modify columns, delete columns

Configure the constant in the .properties file, used in the XML file

[244 Issue] The back slope \\ in mysql, too pit! Intersection

China Adult Blood Liposuction Guide (2016 revised edition) -The learning notes

Linux MySQL login anomaly Error 1045 (28000): Access Denied for User ‘ROOT’@’LocalHost’ (USING Password: Yes)

Random Posts

PIP3 in PYTHON3 Install an error, you can’t find SSL

Detailed explanation SpringBoot Schedule configuration Amelia

[RUST Tiring Notes] Rust basic grammar data type -02

FLEX layout dictionary

SpringBoot and JWT integration