[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Coding problem



   Hello list.
   I have a function that's called from other libraries. The problem is
that when I call it I get the error "Memory fault (core dumped)". I know
(because of the messages) the error happens with the open function, it
returns -1. The path is taken from argv, in main(), and passed as
argument. ¿Is the 'open' function correctly called?
   When answering please CC sistop31_(_at_)_fing_(_dot_)_edu_(_dot_)_uy_(_dot_)_
   Thanks in advance.

int blk_mount(char * path) {
	if (!path) {
		fprintf(stderr, "blk_mount.!path\n");
		return ERROR;
	}

	if ((b_fd = open(path,O_RDWR)) == -1) {
		fprintf(stderr, "blk_mount.open\n");
		return ERROR;
	}

	if ((b_dev = mmap((caddr_t) 0, BLK_BLOCKSIZE * BLK_FSSIZE,\
PROT_READ|PROT_WRITE,MAP_SHARED, b_fd, 0)) == NULL) {
		fprintf(stderr, "blk_mount.mmap\n");
		return ERROR;
	}

	return OK;
}

--
-=   Nicolás Conde    =-
-= yomi_(_at_)_adinet_(_dot_)_com_(_dot_)_uy =-