From 419bfaceaffad5004ea87fd42d2ab335f09ed5ff Mon Sep 17 00:00:00 2001 From: Charles Weng Date: Fri, 11 Sep 2015 18:48:21 +0800 Subject: [PATCH] fix null f_ops in kernel 4.1 --- src/os/linux/rt_linux.c | 47 +++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/os/linux/rt_linux.c b/src/os/linux/rt_linux.c index e26df14..eba1134 100644 --- a/src/os/linux/rt_linux.c +++ b/src/os/linux/rt_linux.c @@ -437,14 +437,14 @@ void RTMP_QueryPacketInfo( if (RTMP_GET_PKT_SG(pPacket)) { struct sk_buff *skb = (struct sk_buff *)pPacket; int i, nr_frags = skb_shinfo(skb)->nr_frags; - + info->BufferCount = nr_frags + 1; info->PhysicalBufferCount = info->BufferCount; info->sg_list[0].data = (VOID *)GET_OS_PKT_DATAPTR(pPacket); info->sg_list[0].len = skb_headlen(skb); for (i = 0; i < nr_frags; i++) { skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; - + info->sg_list[i+1].data = ((void *) page_address(frag->page) + frag->page_offset); info->sg_list[i+1].len = frag->size; @@ -1161,18 +1161,20 @@ void RtmpOSFileSeek(RTMP_OS_FD osfd, int offset) int RtmpOSFileRead(RTMP_OS_FD osfd, char *pDataPtr, int readLen) { + return vfs_read(osfd, pDataPtr, readLen, &osfd->f_pos); /* The object must have a read method */ - if (osfd->f_op && osfd->f_op->read) { - return osfd->f_op->read(osfd, pDataPtr, readLen, &osfd->f_pos); - } else { - DBGPRINT(RT_DEBUG_ERROR, ("no file read method\n")); - return -1; - } + // if (osfd->f_op && osfd->f_op->read) { + // return osfd->f_op->read(osfd, pDataPtr, readLen, &osfd->f_pos); + // } else { + // DBGPRINT(RT_DEBUG_ERROR, ("no file read method\n")); + // return -1; + // } } int RtmpOSFileWrite(RTMP_OS_FD osfd, char *pDataPtr, int writeLen) { - return osfd->f_op->write(osfd, pDataPtr, (size_t) writeLen, &osfd->f_pos); + return vfs_write(osfd, pDataPtr, writeLen, &osfd->f_pos); + //return osfd->f_op->write(osfd, pDataPtr, (size_t) writeLen, &osfd->f_pos); } static inline void __RtmpOSFSInfoChange(OS_FS_INFO * pOSFSInfo, BOOLEAN bSet) @@ -1710,9 +1712,9 @@ PNET_DEV RtmpOSNetDevGetByName(PNET_DEV pNetDev, PSTRING pDevName) void RtmpOSNetDeviceRefPut(PNET_DEV pNetDev) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) - /* - every time dev_get_by_name is called, and it has returned a valid struct - net_device*, dev_put should be called afterwards, because otherwise the + /* + every time dev_get_by_name is called, and it has returned a valid struct + net_device*, dev_put should be called afterwards, because otherwise the machine hangs when the device is unregistered (since dev->refcnt > 1). */ if (pNetDev) @@ -1818,7 +1820,7 @@ int RtmpOSNetDevAttach( pNetDev->ethtool_ops = &RALINK_Ethtool_Ops; #endif - /* if you don't implement get_stats, just leave the callback function as NULL, a dummy + /* if you don't implement get_stats, just leave the callback function as NULL, a dummy function will make kernel panic. */ if (pDevOpHook->get_stats) @@ -1984,9 +1986,9 @@ UCHAR VLAN_8023_Header_Copy( /* no VLAN tag is needed to insert */ memcpy(pData, pHeader802_3, HdrLen); } - + return VLAN_Size; -} +} #endif /* CONFIG_AP_SUPPORT */ @@ -2064,7 +2066,7 @@ VOID RtmpDrvAllMacPrint( os_alloc_mem(NULL, (UCHAR **)&msg, 1024); if (!msg) return; - + orig_fs = get_fs(); set_fs(KERNEL_DS); @@ -2115,10 +2117,10 @@ VOID RtmpDrvAllE2PPrint( os_alloc_mem(NULL, (UCHAR **)&msg, 1024); if (!msg) return; - + orig_fs = get_fs(); set_fs(KERNEL_DS); - + /* open file */ file_w = filp_open(fileName, O_WRONLY | O_CREAT, 0); if (IS_ERR(file_w)) { @@ -2160,7 +2162,7 @@ VOID RtmpDrvAllRFPrint( PSTRING fileName = "RFDump.txt"; mm_segment_t orig_fs; UINT32 macAddr = 0, macValue = 0; - + orig_fs = get_fs(); set_fs(KERNEL_DS); @@ -2693,7 +2695,7 @@ VOID CFG80211OS_UnRegister( Must unregister, or you will suffer problem when you change regulatory domain by using iw. */ - + #ifdef RFKILL_HW_SUPPORT wiphy_rfkill_stop_polling(pCfg80211_CB->pCfg80211_Wdev->wiphy); #endif /* RFKILL_HW_SUPPORT */ @@ -3798,7 +3800,7 @@ VOID RTMP_OS_Add_Timer(NDIS_MINIPORT_TIMER *pTimerOrg, ULONG timeout) __RTMP_OS_Add_Timer(pTimer, timeout); } -} +} VOID RTMP_OS_Mod_Timer(NDIS_MINIPORT_TIMER *pTimerOrg, ULONG timeout) @@ -5274,7 +5276,7 @@ PUCHAR RtmpOsPktHeadBufExtend(PNDIS_PACKET pNetPkt, UINT Len) /* ======================================================================== Routine Description: - + Arguments: pPkt - the packet @@ -5585,4 +5587,3 @@ VOID RtmpOsTaskWakeUp(RTMP_OS_TASK *pTask) } #endif /* OS_ABL_FUNC_SUPPORT */ -