search for: statbuf

Displaying 20 results from an estimated 326 matches for "statbuf".

2014 Jun 12
2
[PATCH] fuse: UID 0 should override all permissions checks (RHBZ#1106548).
...), 15 deletions(-) diff --git a/src/fuse.c b/src/fuse.c index dd63729..292ebee 100644 --- a/src/fuse.c +++ b/src/fuse.c @@ -301,21 +301,42 @@ mount_local_access (const char *path, int mask) fuse = fuse_get_context (); - if (mask & R_OK) - ok = ok && - ( fuse->uid == statbuf.st_uid ? statbuf.st_mode & S_IRUSR - : fuse->gid == statbuf.st_gid ? statbuf.st_mode & S_IRGRP - : statbuf.st_mode & S_IROTH); - if (mask & W_OK) - ok = ok && - ( fuse->uid == statbuf.st_uid ? statbuf.st_mode & S_IWUSR - : fuse->gid =...
2014 Sep 22
2
[PATCH] New APIs: Implement stat calls that return nanosecond timestamps (RHBZ#1144891).
...stat.c index 939fe08..a784914 100644 --- a/daemon/stat.c +++ b/daemon/stat.c @@ -30,11 +30,64 @@ #include "daemon.h" #include "actions.h" -guestfs_int_stat * -do_stat (const char *path) +static guestfs_int_statns * +stat_to_statns (guestfs_int_statns *ret, const struct stat *statbuf) +{ + if (ret == NULL) { + ret = malloc (sizeof *ret); + if (ret == NULL) { + reply_with_perror ("malloc"); + return NULL; + } + } + + ret->st_dev = statbuf->st_dev; + ret->st_ino = statbuf->st_ino; + ret->st_mode = statbuf->st_mode; + ret->st...
2014 Jan 15
1
[PATCH] fuse: clear stat structs (RHBZ#660687).
...2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fuse.c b/src/fuse.c index 288c02a..dd4f139 100644 --- a/src/fuse.c +++ b/src/fuse.c @@ -175,6 +175,7 @@ mount_local_readdir (const char *path, void *buf, fuse_fill_dir_t filler, if (ss->val[i].ino >= 0) { struct stat statbuf; + memset (&statbuf, 0, sizeof statbuf); statbuf.st_dev = ss->val[i].dev; statbuf.st_ino = ss->val[i].ino; statbuf.st_mode = ss->val[i].mode; @@ -255,6 +256,7 @@ mount_local_getattr (const char *path, struct stat *statbuf) if (r == NULL)...
2014 Jul 30
2
[PATCH 1/3] ext2: create a struct for the OCaml 't' type
...read_whole_file (const char *filename, size_t size) /* Copy a file (or directory etc) from the host. */ static void -ext2_copy_file (ext2_filsys fs, const char *src, const char *dest) +ext2_copy_file (struct ext2_data *data, const char *src, const char *dest) { errcode_t err; struct stat statbuf; @@ -551,13 +556,13 @@ ext2_copy_file (ext2_filsys fs, const char *src, const char *dest) * Note we cheat by looking at fs->device_name (which is the output * file). We could store this filename separately. */ - if (fs->device_name && statvfs (fs->device_name, &st...
2010 Mar 11
2
[PATCH FOR DISCUSSION ONLY] Rewrite libguestfs-supermin-helper in C.
...ins each directory name before we enter it. But + * we don't read that until we see a wildcard for that directory. + */ + size_t i, j; + for (i = 0; hostfiles[i] != NULL; ++i) { + char *hostfile = hostfiles[i]; + if (hostfile[0] == '.') + hostfile++; + + struct stat statbuf; + + /* Is it a wildcard? */ + if (strchr (hostfile, '*') || strchr (hostfile, '?')) { + char *dirname = strdup (hostfile); + char *patt = strrchr (dirname, '/'); + assert (patt); + *patt++ = '\0'; + + char **files = read_dir (dirname);...
2012 Mar 28
2
[PATCH v2] New APIs: mount-local and umount-local using FUSE
This version doesn't crash or cause hung processes or stuck mountpoints, so that's an improvement. Rich.
2012 Mar 27
3
[PATCH 0/3] Enable FUSE support in the API via 'mount-local' call.
This patch is just for review. It enables FUSE support in the API via two new calls, 'guestfs_mount_local' and 'guestfs_umount_local'. FUSE turns out to be very easy to deadlock (necessitating that the machine be rebooted). Running the test from the third patch is usually an effective way to demonstrate this. However I have not yet managed to produce a simple reproducer that
2016 May 12
0
[PATCH 3/4] appliance: Move code for creating supermin appliance directory to tmpdirs.c.
...path, - uid_t uid, char **kernel, char **initrd, char **appliance) { - CLEANUP_FREE char *tmpdir = guestfs_get_cachedir (g); CLEANUP_FREE char *cachedir = NULL, *lockfile = NULL, *appliancedir = NULL; - struct stat statbuf; - cachedir = safe_asprintf (g, "%s/.guestfs-%ju", tmpdir, (uintmax_t) uid); - lockfile = safe_asprintf (g, "%s/lock", cachedir); + cachedir = guestfs_int_lazy_make_supermin_appliance_dir (g); + if (cachedir == NULL) + return -1; + appliancedir = safe_asprintf (g, &q...
2012 Mar 29
3
[PATCH v3] New APIs: mount-local, mount-local-run and umount-local using FUSE
This changes the proposed API slightly. Previously 'mount-local' generating a 'mounted' event when the filesystem was ready, and from the 'mounted' event you had to effectively do a fork. Now, 'mount-local' just initializes the mountpoint and you have to call 'mount-local-run' to enter the FUSE main loop. Between these calls you can do a fork or whatever
2019 Nov 26
0
[PATCH supermin] ext2: Build symbolic links correctly (RHBZ#1770304).
..., 1 insertion(+), 7 deletions(-) diff --git a/src/ext2fs-c.c b/src/ext2fs-c.c index e8ab972..8903f74 100644 --- a/src/ext2fs-c.c +++ b/src/ext2fs-c.c @@ -782,12 +782,6 @@ ext2_copy_file (struct ext2_data *data, const char *src, const char *dest) } /* Create a symlink. */ else if (S_ISLNK (statbuf.st_mode)) { - ext2_ino_t ino; - ext2_empty_inode (data->fs, dir_ino, dirname, basename, - statbuf.st_mode, statbuf.st_uid, statbuf.st_gid, - statbuf.st_ctime, statbuf.st_atime, statbuf.st_mtime, - 0, 0, EXT2_FT_SYMLINK, &in...
2016 Jul 06
0
[PATCH] ext2: Don't load whole files into memory when copying to the appliance (RHBZ#1113065).
...py_string (filename)); - - return buf; -} - /* Copy a file (or directory etc) from the host. */ static void ext2_copy_file (struct ext2_data *data, const char *src, const char *dest) @@ -766,24 +805,14 @@ ext2_copy_file (struct ext2_data *data, const char *src, const char *dest) if (S_ISREG (statbuf.st_mode)) { /* XXX Hard links get duplicated here. */ ext2_ino_t ino; - char *buf = NULL; - - if (statbuf.st_size > 0) { - buf = read_whole_file (src, statbuf.st_size); - if (buf == NULL) - goto skip_unreadable_file; - } ext2_empty_inode (data->fs, d...
2018 Oct 30
1
Re: [PATCH nbdkit 4/4] Add floppy plugin.
...strcmp (d->d_name, "..") == 0) >>> + continue; strcmp() leaves errno alone (well, POSIX doesn't guarantee that, but no sane implementation of strcmp() would change errno during a string compare) >>> + >>> + if (lstat (d->d_name, &statbuf) == -1) { >>> + nbdkit_error ("stat: %s/%s: %m", dir, d->d_name); >>> + goto error2; >>> + } However, errno is undefined if lstat() succeeds. If it fails, you don't call readdir() again; but if it succeeds, you cannot rely on libc having l...
2018 Aug 02
0
[PATCH 3/3] file: Zero for block devices on old kernels
...bool can_punch_hole; bool can_zero_range; bool can_fallocate; }; +static bool +is_aligned(struct handle *h, uint64_t n) +{ + return n % h->sector_size == 0; +} + /* Create the per-connection handle. */ static void * file_open (int readonly) { struct handle *h; + struct stat statbuf; int flags; h = malloc (sizeof *h); @@ -150,6 +160,26 @@ file_open (int readonly) return NULL; } + if (fstat (h->fd, &statbuf) == -1) { + nbdkit_error ("fstat: %s: %m", filename); + free (h); + return NULL; + } + + h->is_block_device = S_ISBLK(statb...
2018 Aug 19
0
[PATCH v4 4/4] file: Zero for block devices on old kernels
...dle { int fd; + bool is_block_device; + int sector_size; bool can_punch_hole; bool can_zero_range; bool can_fallocate; + bool can_zeroout; }; /* Create the per-connection handle. */ @@ -129,6 +139,7 @@ static void * file_open (int readonly) { struct handle *h; + struct stat statbuf; int flags; h = malloc (sizeof *h); @@ -150,6 +161,22 @@ file_open (int readonly) return NULL; } + if (fstat (h->fd, &statbuf) == -1) { + nbdkit_error ("fstat: %s: %m", filename); + free (h); + return NULL; + } + + h->is_block_device = S_ISBLK(statb...
2018 Aug 03
0
[PATCH v2 4/4] file: Zero for block devices on old kernels
...dle { int fd; + bool is_block_device; + int sector_size; bool can_punch_hole; bool can_zero_range; bool can_fallocate; + bool can_zeroout; }; /* Create the per-connection handle. */ @@ -129,6 +139,7 @@ static void * file_open (int readonly) { struct handle *h; + struct stat statbuf; int flags; h = malloc (sizeof *h); @@ -150,6 +161,22 @@ file_open (int readonly) return NULL; } + if (fstat (h->fd, &statbuf) == -1) { + nbdkit_error ("fstat: %s: %m", filename); + free (h); + return NULL; + } + + h->is_block_device = S_ISBLK(statb...
2019 Feb 19
2
Re: [PATCH nbdkit 4/4] Add linuxdisk plugin.
...i = 0; i < nr_files; ++i) { > + hardlinked = last_file && compare_inodes (last_file, &files[i]) == 0; > + > + if (!hardlinked) { > + /* Normal case: creating a new inode. */ > + last_file = &files[i]; > + assert (!S_ISDIR (files[i].statbuf.st_mode)); > + > + if (e2copyfile (fs, &files[i]) == -1) > + return -1; > + > + if (linuxdisk_debug_filesystem) > + nbdkit_debug ("%s: <%" PRIu32 ">/%s -> <%" PRIu32 ">", > +...
2017 Jul 14
0
[PATCH 03/27] daemon: Reimplement ‘file’ API in OCaml.
...size, return pwrite_fd (fd, content, size, offset, device, 1); } -/* This runs the 'file' command. */ -char * -do_file (const char *path) -{ - CLEANUP_FREE char *buf = NULL; - const char *display_path = path; - const int is_dev = STRPREFIX (path, "/dev/"); - struct stat statbuf; - - if (!is_dev) { - buf = sysroot_path (path); - if (!buf) { - reply_with_perror ("malloc"); - return NULL; - } - path = buf; - - /* For non-dev, check this is a regular file, else just return the - * file type as a string (RHBZ#582484). - */ - if (l...
2013 Dec 12
3
[PATCH] fuse: provide a stub "flush" implementation (RHBZ#660687).
It seems that FUSE can invoke flush to make sure the pending changes (e.g. to the attributes) of a file are set. Since a missing flush implementation is handled as if it were returning ENOSYS, this can cause issues later. To overcome this, just provide a stub implementation which does nothing, since we have nothing to do and don't want to have FUSE error out. Furthermore, uncomment the
2009 Jun 03
3
How to get file info of a directory in linux kernel space?
...*************************************/ #include <unistd.h> #include <sys/stat.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <dirent.h> void printdir(char *dir, int depth){ DIR *dp; struct dirent *entry; struct stat statbuf; if((dp = opendir(dir)) == NULL){ fprintf(stderr,"cannot open directory: %s\n",dir); return; } chdir(dir); while((entry = readdir(dp)) != NULL){ lstat(entry->d_name,&statbuf); if(S_ISDIR(statbuf.st_mode)){ if(strc...
2009 Jun 03
3
How to get file info of a directory in linux kernel space?
...*************************************/ #include <unistd.h> #include <sys/stat.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <dirent.h> void printdir(char *dir, int depth){ DIR *dp; struct dirent *entry; struct stat statbuf; if((dp = opendir(dir)) == NULL){ fprintf(stderr,"cannot open directory: %s\n",dir); return; } chdir(dir); while((entry = readdir(dp)) != NULL){ lstat(entry->d_name,&statbuf); if(S_ISDIR(statbuf.st_mode)){ if(strc...