|
Last change
on this file since 2083 was 821, checked in by Bruno Cornec, 19 years ago |
|
Addition of busybox 1.2.1 as a mindi-busybox new package
This should avoid delivering binary files in mindi not built there (Fedora and Debian are quite serious about that)
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | * getsectsize.c --- get the sector size of a device.
|
|---|
| 3 | *
|
|---|
| 4 | * Copyright (C) 1995, 1995 Theodore Ts'o.
|
|---|
| 5 | * Copyright (C) 2003 VMware, Inc.
|
|---|
| 6 | *
|
|---|
| 7 | * %Begin-Header%
|
|---|
| 8 | * This file may be redistributed under the terms of the GNU Public
|
|---|
| 9 | * License.
|
|---|
| 10 | * %End-Header%
|
|---|
| 11 | */
|
|---|
| 12 |
|
|---|
| 13 | #include <stdio.h>
|
|---|
| 14 | #if HAVE_UNISTD_H
|
|---|
| 15 | #include <unistd.h>
|
|---|
| 16 | #endif
|
|---|
| 17 | #if HAVE_ERRNO_H
|
|---|
| 18 | #include <errno.h>
|
|---|
| 19 | #endif
|
|---|
| 20 | #include <fcntl.h>
|
|---|
| 21 | #ifdef HAVE_LINUX_FD_H
|
|---|
| 22 | #include <sys/ioctl.h>
|
|---|
| 23 | #include <linux/fd.h>
|
|---|
| 24 | #endif
|
|---|
| 25 |
|
|---|
| 26 | #if defined(__linux__) && defined(_IO) && !defined(BLKSSZGET)
|
|---|
| 27 | #define BLKSSZGET _IO(0x12,104)/* get block device sector size */
|
|---|
| 28 | #endif
|
|---|
| 29 |
|
|---|
| 30 | #include "ext2_fs.h"
|
|---|
| 31 | #include "ext2fs.h"
|
|---|
| 32 |
|
|---|
| 33 | /*
|
|---|
| 34 | * Returns the number of blocks in a partition
|
|---|
| 35 | */
|
|---|
| 36 | errcode_t ext2fs_get_device_sectsize(const char *file, int *sectsize)
|
|---|
| 37 | {
|
|---|
| 38 | int fd;
|
|---|
| 39 |
|
|---|
| 40 | #ifdef CONFIG_LFS
|
|---|
| 41 | fd = open64(file, O_RDONLY);
|
|---|
| 42 | #else
|
|---|
| 43 | fd = open(file, O_RDONLY);
|
|---|
| 44 | #endif
|
|---|
| 45 | if (fd < 0)
|
|---|
| 46 | return errno;
|
|---|
| 47 |
|
|---|
| 48 | #ifdef BLKSSZGET
|
|---|
| 49 | if (ioctl(fd, BLKSSZGET, sectsize) >= 0) {
|
|---|
| 50 | close(fd);
|
|---|
| 51 | return 0;
|
|---|
| 52 | }
|
|---|
| 53 | #endif
|
|---|
| 54 | *sectsize = 0;
|
|---|
| 55 | close(fd);
|
|---|
| 56 | return 0;
|
|---|
| 57 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.