old mode 100644new mode 100755.. | .. |
---|
1718 | 1718 | return rand; |
---|
1719 | 1719 | } |
---|
1720 | 1720 | |
---|
| 1721 | +/* Linux Kernel: File Operations: start */ |
---|
| 1722 | +void * |
---|
| 1723 | +osl_os_open_image(char *filename) |
---|
| 1724 | +{ |
---|
| 1725 | + struct file *fp; |
---|
| 1726 | + |
---|
| 1727 | + fp = filp_open(filename, O_RDONLY, 0); |
---|
| 1728 | + /* |
---|
| 1729 | + * 2.6.11 (FC4) supports filp_open() but later revs don't? |
---|
| 1730 | + * Alternative: |
---|
| 1731 | + * fp = open_namei(AT_FDCWD, filename, O_RD, 0); |
---|
| 1732 | + * ??? |
---|
| 1733 | + */ |
---|
| 1734 | + if (IS_ERR(fp)) { |
---|
| 1735 | + printf("ERROR %ld: Unable to open file %s\n", PTR_ERR(fp), filename); |
---|
| 1736 | + fp = NULL; |
---|
| 1737 | + } |
---|
| 1738 | + |
---|
| 1739 | + return fp; |
---|
| 1740 | +} |
---|
| 1741 | + |
---|
| 1742 | +int |
---|
| 1743 | +osl_os_get_image_block(char *buf, int len, void *image) |
---|
| 1744 | +{ |
---|
| 1745 | + struct file *fp = (struct file *)image; |
---|
| 1746 | + int rdlen; |
---|
| 1747 | + |
---|
| 1748 | + if (fp == NULL) { |
---|
| 1749 | + return 0; |
---|
| 1750 | + } |
---|
| 1751 | + |
---|
| 1752 | + rdlen = kernel_read_compat(fp, fp->f_pos, buf, len); |
---|
| 1753 | + if (rdlen > 0) { |
---|
| 1754 | + fp->f_pos += rdlen; |
---|
| 1755 | + } |
---|
| 1756 | + |
---|
| 1757 | + return rdlen; |
---|
| 1758 | +} |
---|
| 1759 | + |
---|
| 1760 | +void |
---|
| 1761 | +osl_os_close_image(void *image) |
---|
| 1762 | +{ |
---|
| 1763 | + struct file *fp = (struct file *)image; |
---|
| 1764 | + |
---|
| 1765 | + if (fp != NULL) { |
---|
| 1766 | + filp_close(fp, NULL); |
---|
| 1767 | + } |
---|
| 1768 | +} |
---|
| 1769 | + |
---|
| 1770 | +int |
---|
| 1771 | +osl_os_image_size(void *image) |
---|
| 1772 | +{ |
---|
| 1773 | + int len = 0, curroffset; |
---|
| 1774 | + |
---|
| 1775 | + if (image) { |
---|
| 1776 | + /* store the current offset */ |
---|
| 1777 | + curroffset = generic_file_llseek(image, 0, 1); |
---|
| 1778 | + /* goto end of file to get length */ |
---|
| 1779 | + len = generic_file_llseek(image, 0, 2); |
---|
| 1780 | + /* restore back the offset */ |
---|
| 1781 | + generic_file_llseek(image, curroffset, 0); |
---|
| 1782 | + } |
---|
| 1783 | + return len; |
---|
| 1784 | +} |
---|
| 1785 | + |
---|
1721 | 1786 | /* Linux Kernel: File Operations: end */ |
---|
1722 | 1787 | |
---|
1723 | 1788 | #if defined(AXI_TIMEOUTS_NIC) |
---|
.. | .. |
---|
1874 | 1939 | int |
---|
1875 | 1940 | kernel_read_compat(struct file *file, loff_t offset, char *addr, unsigned long count) |
---|
1876 | 1941 | { |
---|
1877 | | -#ifdef DHD_SUPPORT_VFS_CALL |
---|
| 1942 | + if (!IS_ENABLED(CONFIG_NO_GKI)) |
---|
| 1943 | + return -EPERM; |
---|
1878 | 1944 | return (int)kernel_read(file, addr, (size_t)count, &offset); |
---|
1879 | | -#else |
---|
1880 | | - return 0; |
---|
1881 | | -#endif /* DHD_SUPPORT_VFS_CALL */ |
---|
1882 | 1945 | } |
---|
1883 | 1946 | #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)) */ |
---|
1884 | 1947 | |
---|