403Webshell
Server IP : 82.208.35.60  /  Your IP : 216.73.216.238
Web Server : Apache/2.4.55 (FreeBSD) OpenSSL/1.1.1q-freebsd PHP/7.3.31
System : FreeBSD server7.d2m.cz 12.4-RELEASE-p9 FreeBSD 12.4-RELEASE-p9 GENERIC amd64
User : studiokobylisy_cz ( 1008)
PHP Version : 7.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/ports/sysutils/linuxfdisk/files/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/ports/sysutils/linuxfdisk/files/linuxfdisk-sys_bsd.c
#include <sys/param.h>
#include <sys/disklabel.h>
#if __FreeBSD_version < 500000
#include <sys/diskslice.h>
#include <sys/stat.h>
#else
#include <sys/disk.h>
#include <errno.h>
#endif
#include <stddef.h>
#include "common.h"

unsigned int
sys_bsd_sectorsize(int fd)
{
#ifdef DIOCGSECTORSIZE
	;{
		unsigned int d;
		if (ioctl(fd, DIOCGSECTORSIZE, &d) == 0)
			return d;
	}
#endif
#ifdef DIOCGDINFO
	;{
		struct disklabel dl;
		if (ioctl(fd, DIOCGDINFO, &dl) == 0)
			return dl.d_secsize;
	}
#endif
#ifdef DIOCGSLICEINFO
	;{
		struct diskslices dss;
		if (ioctl(fd, DIOCGSLICEINFO, &dss) == 0)
			return dss.dss_secsize;
	}
#endif
	return 0;
}

int
sys_bsd_getsectors(int fd, unsigned long *s)
{
	/* XXX */
	struct disklabel dl;
#if defined(DIOCGMEDIASIZE) && defined(DIOCGSECTORSIZE)
	;{
		off_t fullsize;
		unsigned sectsize;
		if (ioctl(fd, DIOCGMEDIASIZE, &fullsize) == 0 &&
		    ioctl(fd, DIOCGSECTORSIZE, &sectsize) == 0)
		{
			*s = fullsize / sectsize;
			return 0;
		}
	}
#endif
#ifdef DIOCGSLICEINFO
	/* XXX it is somehow ugly, but seems to work on 4.x. */
	;{
		struct diskslices dss;
		struct stat st;
		if (ioctl(fd, DIOCGSLICEINFO, &dss) == 0 &&
		    fstat(fd, &st) == 0)
		{
			int slice = 31 & (st.st_rdev >> 16);
			/* If it have disklabel, fall to disklabel case,
			 * because it shows more exact info.
			 */
			if (slice != WHOLE_DISK_SLICE &&
			    dss.dss_slices[slice].ds_label != NULL &&
			    ioctl(fd, DIOCGDINFO, &dl) == 0) {
				*s = (unsigned long) dl.d_secperunit;
				return 0;
			}
			*s = dss.dss_slices[slice].ds_size;
			return 0;
		}
	}
#endif
#ifdef DIOCGDINFO
	/* Fallback method. */
	if (ioctl(fd, DIOCGDINFO, &dl) == 0) {
		*s = (unsigned long) dl.d_secperunit;
		return 0;
	}
#endif
	return -1;
}

int
sys_bsd_ptsync(int fd)
{
#ifdef DIOCSYNCSLICEINFO
	return ioctl(fd, DIOCSYNCSLICEINFO, NULL);
#else
	/* XXX I suppose here GEOM systems which:
	 * 1) Don't allow writing to raw disk if it is mounted anywhere,
	 * 2) Automatically update GEOM structures after writing to disk.
	 * Hence, no explicit syncing is required.
	 */
	return 0;
#endif
}

int
sys_bsd_getgeometry(int fd, struct hd_geometry *g)
{
	/* XXX */
	struct disklabel dl;
#ifdef DIOCGDINFO
	if (ioctl(fd, DIOCGDINFO, &dl) < 0)
#endif
		return -1;
	g->cylinders = dl.d_ncylinders;
	g->heads = dl.d_ntracks;
	g->sectors = dl.d_nsectors;
	return 0;
}

Youez - 2016 - github.com/yon3zu
LinuXploit