"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/blkdev/blkdev.c" between
dosfstools-4.1.tar.gz and dosfstools-4.2.tar.gz

About: dosfstools are utilities to create, check and label (MS-DOS) FAT filesystems.

blkdev.c  (dosfstools-4.1):blkdev.c  (dosfstools-4.2)
/* /*
* No copyright is claimed. This code is in the public domain; do with * No copyright is claimed. This code is in the public domain; do with
* it what you wish. * it what you wish.
* *
* Written by Karel Zak <kzak@redhat.com> * Written by Karel Zak <kzak@redhat.com>
*/ */
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/sysmacros.h>
#include <unistd.h> #include <unistd.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h>
#include <limits.h>
#ifdef HAVE_LINUX_HDREG_H #ifdef HAVE_LINUX_HDREG_H
#include <linux/hdreg.h> #include <linux/hdreg.h>
#endif #endif
#ifdef HAVE_LINUX_FD_H #ifdef HAVE_LINUX_FD_H
#include <linux/fd.h> #include <linux/fd.h>
#endif #endif
#ifdef HAVE_SYS_DISKLABEL_H #ifdef HAVE_SYS_DISKLABEL_H
skipping to change at line 320 skipping to change at line 323
(void)fd; /* prevent unused parameter warning */ (void)fd; /* prevent unused parameter warning */
*h = 0; *h = 0;
*s = 0; *s = 0;
return -1; return -1;
} }
/* /*
* Get start offset of partition * Get start offset of partition
*/ */
int blkdev_get_start(int fd, unsigned int *s) int blkdev_get_start(int fd, dev_t rdev, unsigned long long *s)
{ {
#ifdef __linux__
{
char path[PATH_MAX];
FILE *file;
int ret;
snprintf(path, sizeof(path), "/sys/dev/block/%d:%d/start", major(
rdev), minor(rdev));
file = fopen(path, "r");
if (file) {
ret = fscanf(file, "%llu", s);
fclose(file);
if (ret == 1)
return 0;
}
}
#endif
#ifdef HDIO_GETGEO #ifdef HDIO_GETGEO
{
struct hd_geometry geometry; struct hd_geometry geometry;
if (ioctl(fd, HDIO_GETGEO, &geometry) == 0) { if (ioctl(fd, HDIO_GETGEO, &geometry) == 0) {
*s = geometry.start; *s = geometry.start;
return 0; return 0;
} }
}
#endif #endif
(void)rdev; /* prevent unused parameter warning */
(void)fd; /* prevent unused parameter warning */ (void)fd; /* prevent unused parameter warning */
*s = 0; *s = 0;
return -1; return -1;
} }
/* /*
* Convert scsi type to human readable string. * Convert scsi type to human readable string.
*/ */
const char *blkdev_scsi_type_to_name(int type) const char *blkdev_scsi_type_to_name(int type)
{ {
 End of changes. 7 change blocks. 
1 lines changed or deleted 25 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)