$(Q) $(CC) -o tst_bitops tst_bitops.o $(ALL_CFLAGS) $(ALL_LDFLAGS) \
$(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR) $(SYSLIBS)
-tst_getsectsize: tst_getsectsize.o $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+tst_getsectsize: tst_getsectsize.o getsectsize.o $(STATIC_LIBEXT2FS) \
+ $(DEPSTATIC_LIBCOM_ERR)
$(E) " LD $@"
- $(Q) $(CC) -o tst_sectgetsize tst_getsectsize.o $(ALL_LDFLAGS) \
- $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR) $(SYSLIBS)
+ $(Q) $(CC) -o tst_getsectsize tst_getsectsize.o getsectsize.o \
+ $(ALL_LDFLAGS) $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR) \
+ $(SYSLIBS)
tst_types.o: $(srcdir)/tst_types.c ext2_types.h
check:: tst_bitops tst_badblocks tst_iscan tst_types tst_icount \
tst_super_size tst_types tst_inode_size tst_csum tst_crc32c tst_bitmaps \
tst_inline tst_inline_data tst_libext2fs tst_sha256 tst_sha512 \
- tst_digest_encode
+ tst_digest_encode tst_getsize tst_getsectsize
$(TESTENV) ./tst_bitops
$(TESTENV) ./tst_badblocks
$(TESTENV) ./tst_iscan
clean::
$(RM) -f \#* *.s *.o *.a *~ *.bak core profiled/* \
tst_badblocks tst_iscan ext2_err.et ext2_err.c ext2_err.h \
- tst_byteswap tst_ismounted tst_getsize tst_sectgetsize \
+ tst_byteswap tst_ismounted tst_getsize tst_getsectsize \
tst_bitops tst_types tst_icount tst_super_size tst_csum \
tst_bitmaps tst_bitmaps_out tst_extents tst_inline \
tst_inline_data tst_inode_size tst_bitmaps_cmd.c \
#include <errno.h>
#endif
#include <fcntl.h>
+#ifdef HAVE_SYS_DISK_H
+#include <sys/disk.h>
+#endif
#ifdef HAVE_LINUX_FD_H
#include <sys/ioctl.h>
#include <linux/fd.h>
return 0;
}
#endif
+#ifdef DIOCGSECTORSIZE
+ if (ioctl(fd, DIOCGSECTORSIZE, sectsize) >= 0) {
+ close(fd);
+ return 0;
+ }
+#endif
*sectsize = 0;
close(fd);
return 0;
if (ioctl(fd, BLKSSZGET, &align) < 0)
align = 0;
#endif
+#ifdef DIOCGSECTORSIZE
+ if (align <= 0 &&
+ ioctl(fd, DIOCGSECTORSIZE, &align) < 0)
+ align = 0;
+#endif
#ifdef _SC_PAGESIZE
if (align <= 0)
return 0;
}
#endif
+#ifdef DIOCGSECTORSIZE
+ /* This isn't really the physical sector size, but FreeBSD
+ * doesn't seem to have this concept. */
+ if (ioctl(fd, DIOCGSECTORSIZE, sectsize) >= 0) {
+ close(fd);
+ return 0;
+ }
+#endif
*sectsize = 0;
close(fd);
return 0;
{
int lsectsize, psectsize;
int retval;
+ int fd;
if (argc < 2) {
fprintf(stderr, "Usage: %s device\n", argv[0]);
}
printf("Device %s has logical/physical sector size of %d/%d.\n",
argv[1], lsectsize, psectsize);
+ fd = open(argv[1], O_RDONLY);
+ if (fd < 0) {
+ perror("open");
+ exit(1);
+ }
+ printf("The device's DIO alignment is %d\n",
+ ext2fs_get_dio_alignment(fd));
+ close(fd);
exit(0);
}