Commit d959f7d8 authored by Filippos Giannakos's avatar Filippos Giannakos

xseg_posixfd: Remove 'posixfd' segment type

Remove 'posixfd' segment type. This segment type was identical to 'posix' type
and posed no added benefit. Moreover, it was never used by any xseg or
Archipelago componenent.
parent fb592f68
......@@ -36,77 +36,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define ERRSIZE 512
char errbuf[ERRSIZE];
static long posixfd_allocate(const char *name, uint64_t size)
{
int fd, r;
off_t lr;
fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0770);
if (fd < 0) {
XSEGLOG("Cannot create shared segment: %s\n",
strerror_r(errno, errbuf, ERRSIZE));
return fd;
}
lr = lseek(fd, size -1, SEEK_SET);
if (lr == (off_t)-1) {
close(fd);
XSEGLOG("Cannot seek into segment file: %s\n",
strerror_r(errno, errbuf, ERRSIZE));
return lr;
}
errbuf[0] = 0;
r = write(fd, errbuf, 1);
if (r != 1) {
close(fd);
XSEGLOG("Failed to set segment size: %s\n",
strerror_r(errno, errbuf, ERRSIZE));
return r;
}
close(fd);
return 0;
}
static long posixfd_deallocate(const char *name)
{
return shm_unlink(name);
}
static void *posixfd_map(const char *name, uint64_t size, struct xseg *seg)
{
struct xseg *xseg;
int fd;
fd = shm_open(name, O_RDWR, 0000);
if (fd < 0) {
XSEGLOG("Failed to open '%s' for mapping: %s\n",
name, strerror_r(errno, errbuf, ERRSIZE));
return NULL;
}
xseg = mmap ( XSEG_BASE_AS_PTR,
size,
PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_FIXED /* | MAP_LOCKED */,
fd, 0 );
if (xseg == MAP_FAILED) {
XSEGLOG("Could not map segment: %s\n",
strerror_r(errno, errbuf, ERRSIZE));
return NULL;
}
close(fd);
return xseg;
}
static void posixfd_unmap(void *ptr, uint64_t size)
{
struct xseg *xseg = ptr;
(void)munmap(xseg, size);
}
static struct posixfd_signal_desc * __get_signal_desc(struct xseg *xseg, xport portno)
{
struct xseg_port *port = xseg_get_port(xseg, portno);
......@@ -451,19 +380,6 @@ void posixfd_free_signal_desc(struct xseg *xseg, void *data, void *sd)
return;
}
static struct xseg_type xseg_posixfd = {
/* xseg_operations */
{
.mfree = posixfd_mfree,
.allocate = posixfd_allocate,
.deallocate = posixfd_deallocate,
.map = posixfd_map,
.unmap = posixfd_unmap,
},
/* name */
"posixfd"
};
static struct xseg_peer xseg_peer_posixfd = {
/* xseg_peer_operations */
{
......@@ -491,7 +407,6 @@ static struct xseg_peer xseg_peer_posixfd = {
void xseg_posixfd_init(void)
{
xseg_register_type(&xseg_posixfd);
xseg_register_peer(&xseg_peer_posixfd);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment