Example #1
0
int ty_stat(const char *path, ty_file_info *info, bool follow)
{
    assert(path && path[0]);
    assert(info);

    return do_stat(AT_FDCWD, path, info, follow);
}
Example #2
0
static int sys_stat(stat_args_t *arg)
{
        stat_args_t kern_args;
        struct stat buf;
        char *path;
        int ret;

        if (copy_from_user(&kern_args, arg, sizeof(kern_args)) < 0) {
                curthr->kt_errno = EFAULT;
                return -1;
        }

        if ((path = user_strdup(&kern_args.path)) == NULL) {
                curthr->kt_errno = EINVAL;
                return -1;
        }

        ret = do_stat(path, &buf);

        if (ret == 0) {
                ret = copy_to_user(kern_args.buf, &buf, sizeof(struct stat));
        }

        if (ret != 0) {
                kfree(path);
                curthr->kt_errno = -ret;
                return -1;
        }

        kfree(path);
        return 0;
}
Example #3
0
File: flist.c Project: OPSF/uClinux
int link_stat(const char *path, STRUCT_STAT *buffer, int follow_dirlinks)
{
#ifdef SUPPORT_LINKS
	if (copy_links)
		return do_stat(path, buffer);
	if (do_lstat(path, buffer) < 0)
		return -1;
	if (follow_dirlinks && S_ISLNK(buffer->st_mode)) {
		STRUCT_STAT st;
		if (do_stat(path, &st) == 0 && S_ISDIR(st.st_mode))
			*buffer = st;
	}
	return 0;
#else
	return do_stat(path, buffer);
#endif
}
Example #4
0
int uffs_fstat(int fd, struct uffs_stat *buf)
{
    uffs_Object *obj = FD2OBJ(fd);

    CHK_OBJ(obj, -1);

    return do_stat(obj, buf);
}
Example #5
0
//: File size in bytes. Only if is_file() == true
off_t  FileInfo::size() const
{
  struct stat s;
  if (do_stat(filename_.c_str(), &s))
    return s.st_size;
  else
    return 0;
}
Example #6
0
//: Time of last status change. (creation, chmod, ...)
time_t FileInfo::created() const
{
  struct stat s;
  if (do_stat(filename_.c_str(), &s))
    return s.st_ctime;
  else
    return 0;
}
Example #7
0
//: Time of last access
time_t FileInfo::accessed() const
{
  struct stat s;
  if (do_stat(filename_.c_str(), &s))
    return s.st_atime;
  else
    return 0;
}
Example #8
0
//: Time of last data modification. See 'man stat(2)'
time_t FileInfo::modified() const
{
  struct stat s;
  if (do_stat(filename_.c_str(), &s))
    return s.st_mtime;
  else
    return 0;
}
Example #9
0
//: Returns TRUE if we are pointing to a directory or a symbolic link to
//: a directory.
bool FileInfo::is_dir()      const
{
  struct stat s;
  if (do_stat(filename_.c_str(), &s))
    return S_ISDIR(s.st_mode);
  else
    return false;
}
Example #10
0
  //: Returns TRUE if we are pointing to a file or a symbolic link to
  //: a file.
  bool FileInfo::is_file() const
  {
    struct stat s;
    if (do_stat(filename_, &s)) {
      return S_ISREG(s.st_mode);
    }

    return false;
  }
Example #11
0
  //: File size in bytes. Only if is_file() == true
  off_t FileInfo::size() const
  {
    struct stat s;
    if (do_stat(filename_, &s)) {
      return s.st_size;
    }

    return 0;
  }
Example #12
0
  //: Time of last status change. (creation, chmod, ...)
  time_t FileInfo::created() const
  {
    struct stat s;
    if (do_stat(filename_, &s)) {
      return s.st_ctime;
    }

    return 0;
  }
Example #13
0
  //: Time of last data modification. See 'man stat(2)'
  time_t FileInfo::modified() const
  {
    struct stat s;
    if (do_stat(filename_, &s)) {
      return s.st_mtime;
    }

    return 0;
  }
Example #14
0
CAMLprim value unix_lstat_64(value path)
{
  struct _stat64 buf;
  __int64 st_ino;
  if (!do_stat(1, 1, String_val(path), caml_string_length(path), NULL, &st_ino, &buf)) {
    uerror("lstat", path);
  }
  return stat_aux(1, st_ino, &buf);
}
Example #15
0
int main(int argc, char *argv[])
{
	int i;

	for (i = 1; i < argc; i++)
		do_stat(argv[i]);

	return 0;
}
Example #16
0
  //: Time of last access
  time_t FileInfo::accessed() const
  {
    struct stat s;
    if (do_stat(filename_, &s)) {
      return s.st_atime;
    }

    return 0;
  }
void file_sync_service(int fd, void *cookie)
{
    syncmsg msg;
    char name[1025];
    unsigned namelen;

    char *buffer = malloc(SYNC_DATA_MAX);
    if(buffer == 0) goto fail;

    for(;;) {
        D("sync: waiting for command\n");

        if(readx(fd, &msg.req, sizeof(msg.req))) {
            fail_message(fd, "command read failure");
            break;
        }
        namelen = ltohl(msg.req.namelen);
        if(namelen > 1024) {
            fail_message(fd, "invalid namelen");
            break;
        }
        if(readx(fd, name, namelen)) {
            fail_message(fd, "filename read failure");
            break;
        }
        name[namelen] = 0;

        msg.req.namelen = 0;
        D("sync: '%s' '%s'\n", (char*) &msg.req, name);

        switch(msg.req.id) {
        case ID_STAT:
            if(do_stat(fd, name)) goto fail;
            break;
        case ID_LIST:
            if(do_list(fd, name)) goto fail;
            break;
        case ID_SEND:
            if(do_send(fd, name, buffer)) goto fail;
            break;
        case ID_RECV:
            if(do_recv(fd, name, buffer)) goto fail;
            break;
        case ID_QUIT:
            goto fail;
        default:
            fail_message(fd, "unknown command");
            goto fail;
        }
    }

fail:
    if(buffer != 0) free(buffer);
    D("sync: done\n");
    adb_close(fd);
}
Example #18
0
CAMLprim value unix_fstat_64(value handle)
{
  int ret;
  struct _stat64 buf;
  __int64 st_ino;
  if (!do_stat(0, 1, NULL, 0, Handle_val(handle), &st_ino, &buf)) {
    uerror("fstat", Nothing);
  }
  return stat_aux(1, st_ino, &buf);
}
Example #19
0
int sys_fstat(int fp, struct stat *sb)
{
	if(!sb)
		return -EINVAL;
	struct file *f = get_file_pointer((task_t *)current_task, fp);
	if(!f) return -EBADF;
	do_stat(f->inode, sb);
	fput((task_t *)current_task, fp, 0);
	return 0;
}
Example #20
0
int _ty_statat(int fd, const char *path, ty_file_info *info, bool follow)
{
    assert(path && path[0]);
    assert(info);

    if (fd < 0)
        fd = AT_FDCWD;

    return do_stat(fd, path, info, follow);
}
Example #21
0
int sys_fstat(int fp, struct stat *sb)
{
	if(!sb)
		return -EINVAL;
	struct file *f = file_get(fp);
	if(!f) return -EBADF;
	do_stat(f->inode, sb);
	file_put(f);
	return 0;
}
Example #22
0
File: stat.c Project: drewt/Telos
long sys_fstat(int fd, struct stat *s)
{
	struct inode *inode;
	if (vm_verify(&current->mm, s, sizeof(*s), VM_WRITE))
		return -EFAULT;
	if (fd >= NR_FILES || !current->filp[fd]
			|| !(inode = current->filp[fd]->f_inode))
		return -EBADF;
	do_stat(inode, s);
	return 0;
}
Example #23
0
int sys_stat(char *f, struct stat *statbuf, int lin)
{
	if(!f || !statbuf) return -EINVAL;
	struct inode *i;
	i = (struct inode *) (lin ? lget_idir(f, 0) : get_idir(f, 0));
	if(!i)
		return -ENOENT;
	do_stat(i, statbuf);
	iput(i);
	return 0;
}
Example #24
0
CAMLprim value unix_lstat(value path)
{
  struct _stat64 buf;
  __int64 st_ino;

  caml_unix_check_path(path, "lstat");
  if (!do_stat(1, 0, String_val(path), NULL, &st_ino, &buf)) {
    uerror("lstat", path);
  }
  return stat_aux(0, st_ino, &buf);
}
int uffs_fstat(int fd, struct uffs_stat *buf)
{
	int ret;
	uffs_Object *obj;

	CHK_OBJ_LOCK(fd, obj, -1);

	ret = do_stat(obj, buf);
	uffs_GlobalFsLockUnlock();

	return ret;
}
Example #26
0
static int
remote_is_dir(struct sftp_conn *conn, char *path)
{
	Attrib *a;

	/* XXX: report errors? */
	if ((a = do_stat(conn, path, 1)) == NULL)
		return(0);
	if (!(a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS))
		return(0);
	return(a->perm & S_IFDIR);
}
Example #27
0
static int
fudge_stat(const char *path, struct stat *st)
{
    Attrib *a;

    if (!(a = do_stat(cur.conn, (char *)path, 0)))
        return(-1);

    attrib_to_stat(a, st);

    return(0);
}
Example #28
0
int sys_stat(char *f, struct stat *statbuf, bool lin)
{
	if(!f || !statbuf) return -EINVAL;
	struct inode *i;
	int res;
	i = (struct inode *) (lin ? fs_path_resolve_inode(f, RESOLVE_NOLINK, &res) : fs_path_resolve_inode(f, 0, &res));

	if(!i)
		return res;
	do_stat(i, statbuf);
	vfs_icache_put(i);
	return 0;
}
Example #29
0
int main (int argc, char *argv[]) {
    if (argc < 2) {
        print_doc(argv[0]);
        return EINVAL;
    }

    if (strncmp(argv[1],"put",3) == 0) {
        if (argc < 4) {
            print_doc(argv[0]);
            return EINVAL;
        }
        const char *key = argv[2];
        const char *src = argv[3];
        return do_put(key, src);
    } else if (strncmp(argv[1], "get", 3) == 0) {
        if (argc < 4) {
            print_doc(argv[0]);
            return EINVAL;
        }
        const char *key = argv[2];
        const char *outpath = argv[3];
        return do_get(key, outpath);
    } else if (strncmp(argv[1], "remove", 6) == 0) {
        if (argc < 3) {
            print_doc(argv[0]);
            return EINVAL;
        }
        const char *key = argv[2];
        return do_remove(key);
    } else if (strncmp(argv[1], "search", 6) == 0) {
        if (argc < 4) {
            print_doc(argv[0]);
            return EINVAL;
        }
        const char *key = argv[2];
        const char *outpath = argv[3];
        return do_search(key, outpath);
    } else if (strncmp(argv[1], "stat", 4) == 0) {
        if (argc < 3) {
            print_doc(argv[0]);
            return EINVAL;
        }
        const char *key = argv[2];
        return do_stat(key);
    } else {
        print_doc(argv[0]);
        return EINVAL;
    }

    return 0;
}
Example #30
0
File: main.c Project: OPSF/uClinux
static char *get_local_name(struct file_list *flist,char *name)
{
	STRUCT_STAT st;
	int e;

	if (verbose > 2)
		rprintf(FINFO,"get_local_name count=%d %s\n",
			flist->count, NS(name));

	if (!name)
		return NULL;

	if (do_stat(name,&st) == 0) {
		if (S_ISDIR(st.st_mode)) {
			if (!push_dir(name)) {
				rsyserr(FERROR, errno, "push_dir#1 %s failed",
					full_fname(name));
				exit_cleanup(RERR_FILESELECT);
			}
			return NULL;
		}
		if (flist->count > 1) {
			rprintf(FERROR,"ERROR: destination must be a directory when copying more than 1 file\n");
			exit_cleanup(RERR_FILESELECT);
		}
		return name;
	}

	if (flist->count <= 1 && ((e = strlen(name)) <= 1 || name[e-1] != '/'))
		return name;

	if (do_mkdir(name,0777 & ~orig_umask) != 0) {
		rsyserr(FERROR, errno, "mkdir %s failed", full_fname(name));
		exit_cleanup(RERR_FILEIO);
	}
	if (verbose > 0)
		rprintf(FINFO, "created directory %s\n", safe_fname(name));

	if (dry_run) {
		dry_run++;
		return NULL;
	}

	if (!push_dir(name)) {
		rsyserr(FERROR, errno, "push_dir#2 %s failed",
			full_fname(name));
		exit_cleanup(RERR_FILESELECT);
	}

	return NULL;
}