mirror of
https://github.com/AetherDroid/android_kernel_samsung_on5xelte.git
synced 2025-09-08 01:08:03 -04:00
Fixed MTP to work with TWRP
This commit is contained in:
commit
f6dfaef42e
50820 changed files with 20846062 additions and 0 deletions
54
arch/um/drivers/slip_common.c
Normal file
54
arch/um/drivers/slip_common.c
Normal file
|
@ -0,0 +1,54 @@
|
|||
#include <string.h>
|
||||
#include "slip_common.h"
|
||||
#include <net_user.h>
|
||||
|
||||
int slip_proto_read(int fd, void *buf, int len, struct slip_proto *slip)
|
||||
{
|
||||
int i, n, size, start;
|
||||
|
||||
if(slip->more > 0){
|
||||
i = 0;
|
||||
while(i < slip->more){
|
||||
size = slip_unesc(slip->ibuf[i++], slip->ibuf,
|
||||
&slip->pos, &slip->esc);
|
||||
if(size){
|
||||
memcpy(buf, slip->ibuf, size);
|
||||
memmove(slip->ibuf, &slip->ibuf[i],
|
||||
slip->more - i);
|
||||
slip->more = slip->more - i;
|
||||
return size;
|
||||
}
|
||||
}
|
||||
slip->more = 0;
|
||||
}
|
||||
|
||||
n = net_read(fd, &slip->ibuf[slip->pos],
|
||||
sizeof(slip->ibuf) - slip->pos);
|
||||
if(n <= 0)
|
||||
return n;
|
||||
|
||||
start = slip->pos;
|
||||
for(i = 0; i < n; i++){
|
||||
size = slip_unesc(slip->ibuf[start + i], slip->ibuf,&slip->pos,
|
||||
&slip->esc);
|
||||
if(size){
|
||||
memcpy(buf, slip->ibuf, size);
|
||||
memmove(slip->ibuf, &slip->ibuf[start+i+1],
|
||||
n - (i + 1));
|
||||
slip->more = n - (i + 1);
|
||||
return size;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int slip_proto_write(int fd, void *buf, int len, struct slip_proto *slip)
|
||||
{
|
||||
int actual, n;
|
||||
|
||||
actual = slip_esc(buf, slip->obuf, len);
|
||||
n = net_write(fd, slip->obuf, actual);
|
||||
if(n < 0)
|
||||
return n;
|
||||
else return len;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue