/* * netsniff-ng - the packet sniffing beast * Copyright 2009 - 2013 Daniel Borkmann. * Subject to the GPL, version 2. */ #include #include #include #include #include #include #include "pcap_io.h" #include "built_in.h" #include "die.h" #include "iosched.h" #include "ioops.h" static ssize_t pcap_rw_write(int fd, pcap_pkthdr_t *phdr, enum pcap_type type, const uint8_t *packet, size_t len) { ssize_t ret, hdrsize = pcap_get_hdr_length(phdr, type), hdrlen = 0; ret = write_or_die(fd, &phdr->raw, hdrsize); if (unlikely(ret != hdrsize)) panic("Failed to write pkt header!\n"); hdrlen = pcap_get_length(phdr, type); if (unlikely(hdrlen != len)) return -EINVAL; ret = write_or_die(fd, packet, hdrlen); if (unlikely(ret != hdrlen)) panic("Failed to write pkt payload!\n"); return hdrsize + hdrlen; } static ssize_t pcap_rw_read(int fd, pcap_pkthdr_t *phdr, enum pcap_type type, uint8_t *packet, size_t len) { ssize_t ret, hdrsize = pcap_get_hdr_length(phdr, type), hdrlen = 0; ret = read_or_die(fd, &phdr->raw, hdrsize); if (unlikely(ret != hdrsize)) return -EIO; hdrlen = pcap_get_length(phdr, type); if (unlikely(hdrlen == 0 || hdrlen > len)) return -EINVAL; ret = read(fd, packet, hdrlen); if (unlikely(ret != hdrlen)) return -EIO; return hdrsize + hdrlen; } static void pcap_rw_init_once(void) { set_ioprio_rt(); } static void pcap_rw_fsync(int fd) { fdatasync(fd); } const struct pcap_file_ops pcap_rw_ops = { .init_once_pcap = pcap_rw_init_once, .pull_fhdr_pcap = pcap_generic_pull_fhdr, .push_fhdr_pcap = pcap_generic_push_fhdr, .read_pcap = pcap_rw_read, .write_pcap = pcap_rw_write, .fsync_pcap = pcap_rw_fsync, }; f='/cgit.cgi/linux/net-next.git/tree/sound/soc/sh?id=857953d72f3744f325de93320cc2673795e9ca89'>treecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-08-07 16:38:45 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2016-08-07 16:38:45 -0700
commit857953d72f3744f325de93320cc2673795e9ca89 (patch)
treeb4253224fd74148708bd1fb210e4155e22ee7b63 /sound/soc/sh
parent635a4ba111e3bd0169fd549b24fe108b1f171713 (diff)
parent1eff9d322a444245c67515edb52bc0eb68374aa8 (diff)
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
Pull more block fixes from Jens Axboe: "As mentioned in the pull the other day, a few more fixes for this round, all related to the bio op changes in this series. Two fixes, and then a cleanup, renaming bio->bi_rw to bio->bi_opf. I wanted to do that change right after or right before -rc1, so that risk of conflict was reduced. I just rebased the series on top of current master, and no new ->bi_rw usage has snuck in" * 'for-linus' of git://git.kernel.dk/linux-block: block: rename bio bi_rw to bi_opf target: iblock_execute_sync_cache() should use bio_set_op_attrs() mm: make __swap_writepage() use bio_set_op_attrs() block/mm: make bdev_ops->rw_page() take a bool for read/write
Diffstat (limited to 'sound/soc/sh')