Deleted Added
full compact
linux_stats.c (130585) linux_stats.c (130640)
1/*-
2 * Copyright (c) 1994-1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1994-1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/compat/linux/linux_stats.c 130585 2004-06-16 09:47:26Z phk $");
30__FBSDID("$FreeBSD: head/sys/compat/linux/linux_stats.c 130640 2004-06-17 17:16:53Z phk $");
31
32#include "opt_mac.h"
33
34#include <sys/param.h>
35#include <sys/conf.h>
36#include <sys/dirent.h>
37#include <sys/file.h>
38#include <sys/filedesc.h>

--- 32 unchanged lines hidden (view full) ---

71 tbuf.st_ctime = buf->st_ctime;
72 tbuf.st_blksize = buf->st_blksize;
73 tbuf.st_blocks = buf->st_blocks;
74
75 /* Lie about disk drives which are character devices
76 * in FreeBSD but block devices under Linux.
77 */
78 if (S_ISCHR(tbuf.st_mode) &&
31
32#include "opt_mac.h"
33
34#include <sys/param.h>
35#include <sys/conf.h>
36#include <sys/dirent.h>
37#include <sys/file.h>
38#include <sys/filedesc.h>

--- 32 unchanged lines hidden (view full) ---

71 tbuf.st_ctime = buf->st_ctime;
72 tbuf.st_blksize = buf->st_blksize;
73 tbuf.st_blocks = buf->st_blocks;
74
75 /* Lie about disk drives which are character devices
76 * in FreeBSD but block devices under Linux.
77 */
78 if (S_ISCHR(tbuf.st_mode) &&
79 (dev = udev2dev(buf->st_rdev)) != NODEV) {
79 (dev = findcdev(buf->st_rdev)) != NULL) {
80 cdevsw = devsw(dev);
81 if (cdevsw != NULL && (cdevsw->d_flags & D_DISK)) {
82 tbuf.st_mode &= ~S_IFMT;
83 tbuf.st_mode |= S_IFBLK;
84
85 /* XXX this may not be quite right */
86 /* Map major number to 0 */
87 tbuf.st_dev = uminor(buf->st_dev) & 0xf;

--- 272 unchanged lines hidden (view full) ---

360
361 /*
362 * XXX - Don't return an error if we can't find a vnode for the
363 * device. Our struct cdev *is 32-bits whereas Linux only has a 16-bits
364 * struct cdev *. The struct cdev *that is used now may as well be a truncated
365 * struct cdev *returned from previous syscalls. Just return a bzeroed
366 * ustat in that case.
367 */
80 cdevsw = devsw(dev);
81 if (cdevsw != NULL && (cdevsw->d_flags & D_DISK)) {
82 tbuf.st_mode &= ~S_IFMT;
83 tbuf.st_mode |= S_IFBLK;
84
85 /* XXX this may not be quite right */
86 /* Map major number to 0 */
87 tbuf.st_dev = uminor(buf->st_dev) & 0xf;

--- 272 unchanged lines hidden (view full) ---

360
361 /*
362 * XXX - Don't return an error if we can't find a vnode for the
363 * device. Our struct cdev *is 32-bits whereas Linux only has a 16-bits
364 * struct cdev *. The struct cdev *that is used now may as well be a truncated
365 * struct cdev *returned from previous syscalls. Just return a bzeroed
366 * ustat in that case.
367 */
368 dev = udev2dev(makeudev(args->dev >> 8, args->dev & 0xFF));
369 if (dev != NODEV && vfinddev(dev, &vp)) {
368 dev = findcdev(makedev(args->dev >> 8, args->dev & 0xFF));
369 if (dev != NULL && vfinddev(dev, &vp)) {
370 if (vp->v_mount == NULL)
371 return (EINVAL);
372#ifdef MAC
373 error = mac_check_mount_stat(td->td_ucred, vp->v_mount);
374 if (error)
375 return (error);
376#endif
377 stat = &(vp->v_mount->mnt_stat);

--- 31 unchanged lines hidden (view full) ---

409 lbuf.st_ctime = buf->st_ctime;
410 lbuf.st_blksize = buf->st_blksize;
411 lbuf.st_blocks = buf->st_blocks;
412
413 /* Lie about disk drives which are character devices
414 * in FreeBSD but block devices under Linux.
415 */
416 if (S_ISCHR(lbuf.st_mode) &&
370 if (vp->v_mount == NULL)
371 return (EINVAL);
372#ifdef MAC
373 error = mac_check_mount_stat(td->td_ucred, vp->v_mount);
374 if (error)
375 return (error);
376#endif
377 stat = &(vp->v_mount->mnt_stat);

--- 31 unchanged lines hidden (view full) ---

409 lbuf.st_ctime = buf->st_ctime;
410 lbuf.st_blksize = buf->st_blksize;
411 lbuf.st_blocks = buf->st_blocks;
412
413 /* Lie about disk drives which are character devices
414 * in FreeBSD but block devices under Linux.
415 */
416 if (S_ISCHR(lbuf.st_mode) &&
417 (dev = udev2dev(buf->st_rdev)) != NODEV) {
417 (dev = findcdev(buf->st_rdev)) != NULL) {
418 cdevsw = devsw(dev);
419 if (cdevsw != NULL && (cdevsw->d_flags & D_DISK)) {
420 lbuf.st_mode &= ~S_IFMT;
421 lbuf.st_mode |= S_IFBLK;
422
423 /* XXX this may not be quite right */
424 /* Map major number to 0 */
425 lbuf.st_dev = uminor(buf->st_dev) & 0xf;

--- 103 unchanged lines hidden ---
418 cdevsw = devsw(dev);
419 if (cdevsw != NULL && (cdevsw->d_flags & D_DISK)) {
420 lbuf.st_mode &= ~S_IFMT;
421 lbuf.st_mode |= S_IFBLK;
422
423 /* XXX this may not be quite right */
424 /* Map major number to 0 */
425 lbuf.st_dev = uminor(buf->st_dev) & 0xf;

--- 103 unchanged lines hidden ---