Esempio n. 1
0
static void inotify_modify_file(const char *name, const char *path)
{
	char filepath[PATH_MAX];

	mk_filename(filepath, PATH_MAX, path, "inotify_file");
	inotify_exercise(name, filepath, path, "inotify_file", inotify_modify_helper, IN_MODIFY, NULL);
}
Esempio n. 2
0
static void
unlink_file (GskIndexer *indexer,
             guint64 file_no)
{
  char buf[MAX_FILENAME];
  mk_filename (buf, indexer, file_no);
  unlink (buf);
}
Esempio n. 3
0
static void inotify_creat_file(const char *name, const char *path)
{
	char filepath[PATH_MAX];

	mk_filename(filepath, PATH_MAX, path, "inotify_file");
	inotify_exercise(name, filepath, path, "inotify_file", inotify_creat_helper, IN_CREATE, NULL);
	(void)rm_file(name, filepath);
}
Esempio n. 4
0
static void inotify_open_file(const char *name, const char *path)
{
	char filepath[PATH_MAX];

	mk_filename(filepath, PATH_MAX, path, "inotify_file");
	if (mk_file(name, filepath, 4096) < 0)
		return;
	inotify_exercise(name, filepath, path, "inotify_file", inotify_open_helper, IN_OPEN, NULL);
	(void)rm_file(name, filepath);
}
Esempio n. 5
0
void do_one_file(int fileno)
{
    char *name = mk_filename(fileno);
    int fd, flags;

    flags = O_RDWR|O_CREAT|O_TRUNC;
    if (use_osync)
        flags |= O_SYNC;

    show("open(%s)\n", name);
    fd = open(name, flags, 0666);
    if (fd < 0) {
        fprintf(stderr, "%s: failed to create file `%s': %s\n",
                progname, name, strerror(errno));
        exit(1);
    }

    write_stuff_to(fd, name);

    if (use_fsync) {
        show("fsync(%s)\n", name);
        if (fsync(fd) < 0) {
            fprintf(stderr, "%s: failed to fsync `%s': %s\n",
                    progname, name, strerror(errno));
            exit(1);
        }
    }

    show("close(%s)\n", name);
    if (close(fd) < 0) {
        fprintf(stderr, "%s: failed to close `%s': %s\n",
                progname, name, strerror(errno));
        exit(1);
    }

    sync_dir();

    for (rename_pass = 0; rename_pass < RENAME_PASSES; rename_pass++) {
        char *newname = mk_new_filename(fileno, rename_pass);

        show("rename(%s, %s)\n", name, newname);
        if (rename(name, newname) < 0) {
            fprintf(stderr,
                    "%s: failed to rename `%s' to `%s': %s\n",
                    progname, name, newname, strerror(errno));
            exit(1);
        }
        sync_dir();
        free(name);
        name = newname;
    }
    rename_pass--;
    free(name);
}
Esempio n. 6
0
static void inotify_delete_self(const char *name, const char *path)
{
	char filepath[PATH_MAX];

	mk_filename(filepath, PATH_MAX, path, "inotify_dir");
	if (mk_dir(name, filepath) < 0)
		return;
	inotify_exercise(name, filepath, filepath, "inotify_dir", inotify_delete_self_helper, IN_DELETE_SELF, NULL);
	/* We remove (again) in case the test failed */
	(void)rm_dir(name, filepath);
}
Esempio n. 7
0
static void inotify_delete_file(const char *name, const char *path)
{
	char filepath[PATH_MAX];

	mk_filename(filepath, PATH_MAX, path, "inotify_file");
	if (mk_file(name, filepath, 4096) < 0)
		return;
	inotify_exercise(name, filepath, path, "inotify_file", inotify_delete_helper, IN_DELETE, NULL);
	/* We remove (again) it just in case the test failed */
	(void)rm_file(name, filepath);
}
Esempio n. 8
0
void inotify_attrib_file(const char *name, const char *path)
{
	char filepath[PATH_MAX];

	mk_filename(filepath, PATH_MAX, path, "inotify_file");
	if (mk_file(name, filepath, 4096) < 0)
		return;

	inotify_exercise(name, filepath, path, "inotify_file", inotify_attrib_helper, IN_ATTRIB, NULL);
	(void)rm_file(name, filepath);
}
Esempio n. 9
0
static FILE *
open_file_for_reading(uint32 type)
{
    char *fn;
    FILE *out;

    fn = mk_filename(type, cur_ctl_path);

    out = fopen(fn, "r");
    if (out == NULL) {
	E_ERROR_SYSTEM("Unable to open %s for reading\n", fn);
    }
    
    return out;
}
Esempio n. 10
0
// Open image file for write
static FRESULT open_file(void)
{
    FRESULT res;
    BYTE mode;

    // make file name
    mk_filename(FDR_INFO.file_name, FDR_INFO.track, FDR_INFO.side);

    // open file
    if (FDR_INFO.overwrite)
        mode = FA_WRITE|FA_CREATE_ALWAYS;
    else
        mode = FA_WRITE|FA_CREATE_NEW;
    res=f_open(&fd, FDR_INFO.file_name, mode);
    return res;
}
Esempio n. 11
0
int
corpus_get_seg(uint16 **seg,
	       int32 *n_seg)
{
    char *rel_path;

    if (!requires_seg) {
	/* asked for seg data, but not set up to send it */
	return S3_ERROR;
    }

    /* If control file specifies an utt ID, use it.  O/W use the path */
    if (cur_ctl_utt_id != NULL)
	rel_path = cur_ctl_utt_id;
    else
	rel_path = cur_ctl_path;

    if (areadshort(mk_filename(DATA_TYPE_SEG, rel_path), (int16**)seg, n_seg) < 0)
	return S3_ERROR;
    
    return S3_SUCCESS;
}
Esempio n. 12
0
static int
corpus_read_next_sent_file(char **trans)
{
    FILE *fp;
    lineiter_t *li;

    /* open the current file */
    fp = open_file_for_reading(DATA_TYPE_SENT);

    li = lineiter_start_clean(fp);
    if (li == NULL) {
	E_ERROR("Unable to read data in sent file %s\n",
		mk_filename(DATA_TYPE_SENT, cur_ctl_path));		
	return S3_ERROR;
    }

    *trans = strdup(li->buf);
    lineiter_free(li);
    fclose(fp);

    return S3_SUCCESS;
}
Esempio n. 13
0
int
corpus_get_phseg(acmod_set_t *acmod_set,
		 s3phseg_t **out_phseg)
{
    char *rel_path;

    if (!requires_phseg) {
	/* asked for seg data, but not set up to send it */
	return S3_ERROR;
    }

    /* If control file specifies an utt ID, use it.  O/W use the path */
    if (cur_ctl_utt_id != NULL)
	rel_path = cur_ctl_utt_id;
    else
	rel_path = cur_ctl_path;

    if (s3phseg_read(mk_filename(DATA_TYPE_PHSEG, rel_path),
		     acmod_set,
		     out_phseg) < 0)
	return S3_ERROR;
    
    return S3_SUCCESS;
}
Esempio n. 14
0
int
corpus_get_generic_featurevec(vector_t **mfc,
			      int32 *n_frame,
			      uint32 veclen)
{
    vector_t *out;
    float32 *coeff, **cptr;
    uint32 n_f;
    uint32 n_c;
    uint32 i, j;
    uint32 ret=S3_ERROR;
    uint32 no_retries=0;

    if (!requires_mfcc) {
	/* asked for mfc data, but not set up to send it */
	return S3_ERROR;
    }

    if (mfc)
	cptr = &coeff;
    else {
	/* If mfc == NULL, just get the number of frames. */
	coeff = NULL;
	cptr = NULL;
    }

    do {
	if ((cur_ctl_sf == NO_FRAME) && (cur_ctl_ef == NO_FRAME)) {
	    ret = areadfloat(mk_filename(DATA_TYPE_MFCC, cur_ctl_path),
			     cptr, (int *)&n_c);
	}
	else if ((cur_ctl_sf != NO_FRAME) && (cur_ctl_ef != NO_FRAME)) {
	    ret = areadfloat_part(mk_filename(DATA_TYPE_MFCC, cur_ctl_path),
				  cur_ctl_sf * veclen,
				  (cur_ctl_ef + 1) * veclen - 1,
				  cptr, (int *)&n_c);
	}
	else {
	    E_FATAL("Both start and end frame must be set in the ctl file\n");
	}

	if (ret == S3_ERROR) {
	    E_ERROR_SYSTEM("Failed to read MFC file '%s'. Retrying after sleep...\n",
		    mk_filename(DATA_TYPE_MFCC, cur_ctl_path));
	    no_retries++;
	    sleep(3);
	    if(no_retries>100){ 
	      E_FATAL("Failed to get the files after 100 retries (about 300 seconds)\n");
	    }
	}
    } while (ret == S3_ERROR);

    if ((ret == 0) && (cur_ctl_sf != NO_FRAME) && (cur_ctl_ef != NO_FRAME)) {
	E_ERROR("Region [%d %d] for %s extends beyond end of file\n",
		cur_ctl_sf, cur_ctl_ef, corpus_utt());
    }

    if ((n_c % veclen) != 0) {
	E_FATAL("Expected mfcc vector len of %d, got %d (%d)\n", veclen, n_c % veclen, n_c);
    }
    
    n_f = n_c / veclen;

    if (n_f == 0) {
	if (mfc)
	    *mfc = NULL;
	if (n_frame)
	    *n_frame = 0;
    }

    if (mfc && coeff) {
	out = (vector_t *)ckd_calloc(n_f, sizeof(vector_t));

	for (i = 0, j = 0; i < n_f; i++, j += veclen) {
	    out[i] = &coeff[j];
	}

	*mfc = out;
    }
    if (n_frame)
	*n_frame = n_f;

    return S3_SUCCESS;
}