filemon.c (253977) | filemon.c (255219) |
---|---|
1/*- 2 * Copyright (c) 2011, David E. O'Brien. 3 * Copyright (c) 2009-2011, Juniper Networks, Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2011, David E. O'Brien. 3 * Copyright (c) 2009-2011, Juniper Networks, Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/dev/filemon/filemon.c 253977 2013-08-06 02:14:30Z hrs $"); | 29__FBSDID("$FreeBSD: head/sys/dev/filemon/filemon.c 255219 2013-09-05 00:09:56Z pjd $"); |
30 31#include "opt_compat.h" 32 33#include <sys/param.h> 34#include <sys/file.h> 35#include <sys/systm.h> 36#include <sys/buf.h> 37#include <sys/condvar.h> --- 95 unchanged lines hidden (view full) --- 133 /* Give up write access. */ 134 filemon_unlock_write(); 135 136 if (fp != NULL) 137 fdrop(fp, curthread); 138 } 139} 140 | 30 31#include "opt_compat.h" 32 33#include <sys/param.h> 34#include <sys/file.h> 35#include <sys/systm.h> 36#include <sys/buf.h> 37#include <sys/condvar.h> --- 95 unchanged lines hidden (view full) --- 133 /* Give up write access. */ 134 filemon_unlock_write(); 135 136 if (fp != NULL) 137 fdrop(fp, curthread); 138 } 139} 140 |
141#if __FreeBSD_version < 900041 142#define FGET_WRITE(a1, a2, a3) fget_write((a1), (a2), (a3)) 143#else 144#define FGET_WRITE(a1, a2, a3) fget_write((a1), (a2), CAP_WRITE | CAP_SEEK, (a3)) 145#endif 146 | |
147static int 148filemon_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag __unused, 149 struct thread *td) 150{ 151 int error = 0; 152 struct filemon *filemon; 153 struct proc *p; | 141static int 142filemon_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag __unused, 143 struct thread *td) 144{ 145 int error = 0; 146 struct filemon *filemon; 147 struct proc *p; |
148#if __FreeBSD_version >= 900041 149 cap_rights_t rights; 150#endif |
|
154 155 devfs_get_cdevpriv((void **) &filemon); 156 157 switch (cmd) { 158 /* Set the output file descriptor. */ 159 case FILEMON_SET_FD: | 151 152 devfs_get_cdevpriv((void **) &filemon); 153 154 switch (cmd) { 155 /* Set the output file descriptor. */ 156 case FILEMON_SET_FD: |
160 if ((error = FGET_WRITE(td, *(int *)data, &filemon->fp)) == 0) | 157 error = fget_write(td, *(int *)data, 158#if __FreeBSD_version >= 900041 159 cap_rights_init(&rights, CAP_PWRITE), 160#endif 161 &filemon->fp); 162 if (error == 0) |
161 /* Write the file header. */ 162 filemon_comment(filemon); 163 break; 164 165 /* Set the monitored process ID. */ 166 case FILEMON_SET_PID: 167 error = pget(*((pid_t *)data), PGET_CANDEBUG | PGET_NOTWEXIT, 168 &p); --- 143 unchanged lines hidden --- | 163 /* Write the file header. */ 164 filemon_comment(filemon); 165 break; 166 167 /* Set the monitored process ID. */ 168 case FILEMON_SET_PID: 169 error = pget(*((pid_t *)data), PGET_CANDEBUG | PGET_NOTWEXIT, 170 &p); --- 143 unchanged lines hidden --- |