nofollow ? AT_SYMLINK_NOFOLLOW : 0);
}
#else
-int fstat_at(int dir, const char *dirname, const char *filename,
- struct stat *st, int nofollow)
+int fstat_at(int dir __attribute__ ((__unused__)), const char *dirname,
+ const char *filename, struct stat *st, int nofollow)
{
if (*filename != '/') {
return openat(dir, filename, flags);
}
#else
-int open_at(int dir, const char *dirname, const char *filename, int flags)
+int open_at(int dir __attribute__((__unused__)), const char *dirname,
+ const char *filename, int flags)
{
if (*filename != '/') {
char path[PATH_MAX];
return readlinkat(dir, pathname, buf, bufsiz);
}
#else
-ssize_t readlink_at(int dir, const char *dirname, const char *pathname,
- char *buf, size_t bufsiz)
+ssize_t readlink_at(int dir __attribute__((__unused__)), const char *dirname,
+ const char *pathname, char *buf, size_t bufsiz)
{
if (*pathname != '/') {
char path[PATH_MAX];
* This is the smallest unit the storage device can
* address. It is typically 512 bytes.
*/
+#ifdef BLKSSZGET
int blkdev_get_sector_size(int fd, int *sector_size)
{
-#ifdef BLKSSZGET
if (ioctl(fd, BLKSSZGET, sector_size) >= 0)
return 0;
return -1;
+}
#else
+int blkdev_get_sector_size(int fd __attribute__((__unused__)), int *sector_size)
+{
*sector_size = DEFAULT_SECTOR_SIZE;
return 0;
-#endif
}
+#endif
/*
* Get physical block device size. The BLKPBSZGET is supported since Linux
* physec = DEFAULT_SECTOR_SIZE;
* }
*/
+#ifdef BLKPBSZGET
int blkdev_get_physector_size(int fd, int *sector_size)
{
-#ifdef BLKPBSZGET
if (ioctl(fd, BLKPBSZGET, §or_size) >= 0)
return 0;
return -1;
+}
#else
+int blkdev_get_physector_size(int fd __attribute__((__unused__)), int *sector_size)
+{
*sector_size = DEFAULT_SECTOR_SIZE;
return 0;
-#endif
}
+#endif
/*
* Return the alignment status of a device
*/
+#ifdef BLKALIGNOFF
int blkdev_is_misaligned(int fd)
{
-#ifdef BLKALIGNOFF
int aligned;
if (ioctl(fd, BLKALIGNOFF, &aligned) < 0)
* sizes and alignments exist for stacked devices
*/
return aligned != 0 ? 1 : 0;
+}
#else
+int blkdev_is_misaligned(int fd __attribute__((__unused__)))
+{
return 0;
-#endif
}
+#endif
int open_blkdev_or_file(const struct stat *st, const char *name, const int oflag)
{
return fd;
}
+#ifdef CDROM_GET_CAPABILITY
int blkdev_is_cdrom(int fd)
{
-#ifdef CDROM_GET_CAPABILITY
int ret;
if ((ret = ioctl(fd, CDROM_GET_CAPABILITY, NULL)) < 0)
return 0;
else
return ret;
+}
#else
+int blkdev_is_cdrom(int fd __attribute__((__unused__)))
+{
return 0;
-#endif
}
+#endif
/*
* Get kernel's interpretation of the device's geometry.
*
* Note that this is deprecated in favor of LBA addressing.
*/
+#ifdef HDIO_GETGEO
int blkdev_get_geometry(int fd, unsigned int *h, unsigned int *s)
{
-#ifdef HDIO_GETGEO
struct hd_geometry geometry;
if (ioctl(fd, HDIO_GETGEO, &geometry) == 0) {
return 0;
}
#else
+int blkdev_get_geometry(int fd __attribute__((__unused__)),
+ unsigned int *h, unsigned int *s)
+{
*h = 0;
*s = 0;
#endif
int check_mount_point(const char *device, int *mount_flags,
char *mtpt, int mtlen)
{
- struct stat st_buf;
int retval = 0;
- int fd;
if (is_swap_device(device)) {
*mount_flags = MF_MOUNTED | MF_SWAP;
return retval;
#ifdef __linux__ /* This only works on Linux 2.6+ systems */
- if ((stat(device, &st_buf) != 0) ||
- !S_ISBLK(st_buf.st_mode))
- return 0;
- fd = open(device, O_RDONLY|O_EXCL|O_CLOEXEC);
- if (fd < 0) {
- if (errno == EBUSY)
- *mount_flags |= MF_BUSY;
- } else
- close(fd);
+ {
+ struct stat st_buf;
+ int fd;
+ if ((stat(device, &st_buf) != 0) ||
+ !S_ISBLK(st_buf.st_mode))
+ return 0;
+ fd = open(device, O_RDONLY|O_EXCL|O_CLOEXEC);
+ if (fd < 0) {
+ if (errno == EBUSY)
+ *mount_flags |= MF_BUSY;
+ } else
+ close(fd);
+ }
#endif
return 0;