Exemplo n.º 1
0
int sys_remove(const char *filename, int *ret){
	int err;
	char *filename_cp;

	/* Error check inputs */
	if((filename == NULL) || (ret == NULL)){
		*ret = -1;
		return EINVAL;
	}

	filename_cp = kmalloc(strlen(filename) + 1);
	if(filename_cp == NULL){
		*ret = -1;
		return ENOMEM;
	}
	strcpy(filename_cp, filename);

	err = vfs_remove(filename_cp);
	kfree(filename_cp);
	if(err){
                *ret = -1;
                return err;
        }

	*ret = 0;
	return 0;
}
Exemplo n.º 2
0
static void cmd_dele(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate *fsm)
{
	vfs_stat_t st;

	if (arg == NULL) {
		send_msg(pcb, fsm, msg501);
		return;
	}
	if (*arg == '\0') {
		send_msg(pcb, fsm, msg501);
		return;
	}
	if (vfs_stat(fsm->vfs, arg, &st) != 0) {
		send_msg(pcb, fsm, msg550);
		return;
	}
	if (!VFS_ISREG(st.st_mode)) {
		send_msg(pcb, fsm, msg550);
		return;
	}
	if (vfs_remove(fsm->vfs, arg) != 0) {
		send_msg(pcb, fsm, msg550);
	} else {
		send_msg(pcb, fsm, msg250);
	}
}
Exemplo n.º 3
0
static int esp8266_Delete( sqlite3_vfs * vfs, const char * path, int syncDir )
{
	sint32_t rc = vfs_remove( path );
	if (rc == VFS_RES_ERR)
		return SQLITE_IOERR_DELETE;

	dbg_printf("esp8266_Delete: %s OK\n", path);
	return SQLITE_OK;
}
Exemplo n.º 4
0
int
sys_remove(userptr_t p)
{
	char pbuf_store[PATH_MAX];
	int err;

	err = copyinstr(p, pbuf_store, sizeof(pbuf_store), NULL);
	if (!err) {
		return vfs_remove(pbuf_store);
	}
	else {
		return err;
	}
}
Exemplo n.º 5
0
static void single_run(int32_t chunksize, int32_t repetitions)
{
    errval_t err;
    vfs_handle_t handle;

    // create file
    err = vfs_create(FILENAME, &handle);
    assert(err_is_ok(err));

    // create chunk containing arbitraty data
    uint8_t *chunk = malloc(chunksize);
    assert(chunk != NULL);

    // start time
    printf("Start run with chunksize: %" PRId32 ", repetitions: %" PRId32
           "\n", chunksize, repetitions);
    cycles_t start_cycles = bench_tsc();

    size_t written = 0;
    for (int32_t i = 0; i < repetitions; i++) {
        err = vfs_write(handle, chunk, chunksize, &written);
        assert(err_is_ok(err));
        assert(written == chunksize);
    }
    err = vfs_close(handle);
    assert(err_is_ok(err));

    // end time
    cycles_t end_cycles = bench_tsc();

    // evaluation
    cycles_t cycles = end_cycles - start_cycles;
    uint64_t ms = bench_tsc_to_ms(cycles);
    double sec = (double) ms / 1000.0;
    int64_t bytes_written = chunksize * repetitions;
    double kibibytes_written = (double) bytes_written / 1024.0;
    double mebibytes_written = (double) bytes_written / (1024.0 * 1024.0);
    double kibps = kibibytes_written / sec;
    printf("%" PRId64 " bytes (%.1f KiB, %.1f MiB) written in %" PRIuCYCLES
           " cycles (%" PRIu64 " ms, %.1f s) -> %.1f KiB/s\n", bytes_written,
           kibibytes_written, mebibytes_written, cycles, ms, sec, kibps);

    // cleanup
    free(chunk);
    err = vfs_remove(FILENAME);
    assert(err_is_ok(err));
}
Exemplo n.º 6
0
static
int
fstest_remove(const char *fs, const char *namesuffix)
{
	char name[32];
	char buf[32];
	int err;

	MAKENAME();

	strcpy(buf, name);
	err = vfs_remove(buf);
	if (err) {
		kprintf("Could not remove %s: %s\n", name, strerror(err));
		return -1;
	}

	return 0;
}
Exemplo n.º 7
0
static int rm(int argc, char *argv[])
{
    if(argc < 2) {
        printf("Usage: %s file...\n", argv[0]);
        return 1;
    }

    int ret = 0;

    for (int i = 1; i < argc; i++) {
        char *path = vfs_path_mkabsolute(cwd, argv[i]);
        errval_t err = vfs_remove(path);
        free(path);
        if (err_is_fail(err)) {
            printf("%s: %s\n", argv[i], err_getstring(err));
            ret = 1;
        }
    }

    return ret;
}
Exemplo n.º 8
0
Arquivo: syscall.c Projeto: mrb852/osm
int syscall_remove(const char *pathname) {
  int result = vfs_remove(pathname);
  if (result < 0) {
    switch(result) {
      case VFS_UNUSABLE:
        kprintf("Error removing file. File system unusable.\n");
      break;
      case VFS_INVALID_PARAMS:
        kprintf("Error removing file: Invalid params\n");
      break;
      case VFS_NO_SUCH_FS:
        kprintf("Error removing file: No such filesystem\n");
      break;
      default:
        kprintf("Error writing file: unknown error\n");
      break;
    }

  }

  return result;
}
Exemplo n.º 9
0
/* Deletes the file with name pathname from the file system, fails if
   the file is open. Returns 0 on success, or a negative number on
   error. */
int syscall_delete(char *pathname) {
    return vfs_remove(pathname);
}
Exemplo n.º 10
0
Arquivo: io.c Projeto: mrb852/osm-exam
int io_remove(const char* pathname) {
  return vfs_remove(pathname);
}
Exemplo n.º 11
0
static
int
fstest_write(const char *fs, const char *namesuffix,
	     int stridesize, int stridepos)
{
	struct vnode *vn;
	int err;
	int i;
	size_t shouldbytes=0;
	size_t bytes=0;
	off_t pos=0;
	char name[32];
	char buf[32];
	struct iovec iov;
	struct uio ku;
	int flags;

	KASSERT(sizeof(buf) > strlen(SLOGAN));

	MAKENAME();

	flags = O_WRONLY|O_CREAT;
	if (stridesize == 1) {
		flags |= O_TRUNC;
	}

	/* vfs_open destroys the string it's passed */
	strcpy(buf, name);
	err = vfs_open(buf, flags, 0664, &vn);
	if (err) {
		kprintf("Could not open %s for write: %s\n",
			name, strerror(err));
		return -1;
	}

	for (i=0; i<NCHUNKS; i++) {
		if (i % stridesize != stridepos) {
			pos += strlen(SLOGAN);
			continue;
		}
		strcpy(buf, SLOGAN);
		rotate(buf, i);
		uio_kinit(&iov, &ku, buf, strlen(SLOGAN), pos, UIO_WRITE);
		err = VOP_WRITE(vn, &ku);
		if (err) {
			kprintf("%s: Write error: %s\n", name, strerror(err));
			vfs_close(vn);
			vfs_remove(name);
			return -1;
		}

		if (ku.uio_resid > 0) {
			kprintf("%s: Short write: %lu bytes left over\n",
				name, (unsigned long) ku.uio_resid);
			vfs_close(vn);
			vfs_remove(name);
			return -1;
		}

		bytes += (ku.uio_offset - pos);
		shouldbytes += strlen(SLOGAN);
		pos = ku.uio_offset;
	}

	vfs_close(vn);

	if (bytes != shouldbytes) {
		kprintf("%s: %lu bytes written, should have been %lu!\n",
			name, (unsigned long) bytes,
			(unsigned long) (NCHUNKS*strlen(SLOGAN)));
		vfs_remove(name);
		return -1;
	}
	kprintf("%s: %lu bytes written\n", name, (unsigned long) bytes);

	return 0;
}