search for: s_isblk

Displaying 20 results from an estimated 109 matches for "s_isblk".

2010 Apr 15
1
[PATCH] ocfs2: avoid direct write if we fall back to buffered v2
...egment_checks(iov, &nr_segs, &ocount, - VERIFY_READ); - if (ret) - goto out_dio; + ret = generic_segment_checks(iov, &nr_segs, &ocount, + VERIFY_READ); + if (ret) + goto out_dio; - count = ocount; - ret = generic_write_checks(file, ppos, &count, - S_ISBLK(inode->i_mode)); - if (ret) - goto out_dio; + count = ocount; + ret = generic_write_checks(file, ppos, &count, + S_ISBLK(inode->i_mode)); + if (ret) + goto out_dio; + if (direct_io) { written = generic_file_direct_write(iocb, iov, &nr_segs, *ppos, ppos, count...
2009 Nov 14
2
[PATCH] btrfs-progs: Check mount status of multidevice filesystems
...limits.h> #include "kerncompat.h" #include "radix-tree.h" #include "ctree.h" @@ -586,46 +588,105 @@ error: return ret; } +int is_loop_device (const char *device) { + struct stat statbuf; + + if(stat(device, &statbuf) < 0) + return -errno; + + return (S_ISBLK(statbuf.st_mode) && + major(statbuf.st_rdev) == LOOP_MAJOR); +} + +int is_same_blk_file(const char* a, const char* b) +{ + struct stat st_buf_a, st_buf_b; + char real_a[PATH_MAX]; + char real_b[PATH_MAX]; + + if(!realpath(a, real_a) || + !realpath(b, real_b)) + { + return -errno; + } +...
2015 Jan 15
1
[PATCH] mknod: filter modes in mkfifo, mknod_b, mknod_c (RHBZ#1182463).
...ith @@ -6192,7 +6197,9 @@ The mode actually set is affected by the umask." }; InitScratchFS, Always, TestResult ( [["mknod_b"; "0o777"; "99"; "66"; "/mknod_b"]; ["stat"; "/mknod_b"]], - "S_ISBLK (ret->mode) && (ret->mode & 0777) == 0755"), [] + "S_ISBLK (ret->mode) && (ret->mode & 0777) == 0755"), []; + InitScratchFS, Always, TestLastFail ( + [["mknod_b"; "0o10777"; "99"; "66"; &qu...
2010 Jun 15
3
about rsyncing of block devices
Hiya, I can see it's a regular subject on this list. I, like others wanted to use rsync to synchronise two block devices (as it happens one lvm volume and one nbd device served by qemu-img on a remote host from a qcow2 disk image so that I can keep the old versions) As I couldn't find any report of it being done successfully, I'm just sharing my findings as it might benefit others.
2013 Feb 12
10
[PATCH] Btrfs-progs: check out if the swap device
...ap device or not. + * Returns 1 if the swap device, < 0 on error or 0 if not the swap device. + */ +int is_swap_device(const char *file) +{ + FILE *f; + struct stat st_buf; + char buf[1024]; + char *cp; + dev_t rdev; + int ret = 0; + + if (stat(file, &st_buf) < 0) + return -errno; + if (!S_ISBLK(st_buf.st_mode)) + return 0; + + rdev = st_buf.st_rdev; + + if ((f = fopen("/proc/swaps", "r")) == NULL) + return -errno; + + /* skip the first line */ + if (fgets(buf, sizeof(buf), f) == NULL) + goto out; + + while (fgets(buf, sizeof(buf), f) != NULL) { + if ((cp = strchr(b...
2017 Aug 08
1
Re: [PATCH 3/6] daemon: Refine check for Device and Dev_or_Path parameters (RHBZ#1477623).
On Thursday, 3 August 2017 19:13:48 CEST Richard W.M. Jones wrote: > + fprintf (stderr, "mode = %o\n", statbuf.st_mode); > + if (S_ISBLK (statbuf.st_mode)) > + /* continue */; > + else if (S_ISDIR (statbuf.st_mode)) { > + fprintf (stderr, "S_ISDIR\n"); The two unconditional fprintf() look like debugging leftovers. > + fd = open (device, O_RDONLY|O_CLOEXEC); > + if (fd == -1) { > + if (verbos...
2020 Aug 07
0
[nbdkit PATCH 1/4] file: Forbid non-regular, non-block file names
...1 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/file/file.c b/plugins/file/file.c index dc99f992..e049864a 100644 --- a/plugins/file/file.c +++ b/plugins/file/file.c @@ -189,7 +189,16 @@ file_open (int readonly) return NULL; } - h->is_block_device = S_ISBLK (statbuf.st_mode); + if (S_ISBLK (statbuf.st_mode)) + h->is_block_device = true; + else if (S_ISREG (statbuf.st_mode)) + h->is_block_device = false; + else { + nbdkit_error ("file is not regular or block device: %s", filename); + close (h->fd); + free (h); +...
2009 Jul 11
2
Initialize count in aio_write before generic_write_checks
...igues <rgoldwyn at suse.de> diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index a5887df..5b9c8af 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -1841,6 +1841,7 @@ relock: if (ret) goto out_dio; + count = ocount; ret = generic_write_checks(file, ppos, &count, S_ISBLK(inode->i_mode)); if (ret) -- Goldwyn
2010 Aug 04
1
[PATCH] Correctly detect the size of a block device over SSH
...push(@command, $host); - push(@command, "stat -c %s $path; cat $path"); + + # Return the size of the remote path on the first line, followed by its + # contents. + # The bit arithmetic with the output of stat is a translation into shell + # of the S_ISBLK macro. If the remote device is a block device, stat + # will simply return the size of the block device inode. In this case, + # we use the output of blockdev --getsize64 instead. + push(@command, + "dev=$path; ". + 'if [[ $(((0x$(stat -L -c...
2018 Aug 02
0
[PATCH 3/3] file: Zero for block devices on old kernels
...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(statbuf.st_mode); + +#ifdef BLKSSZGET + if (h->is_block_device) { + if (ioctl (h->fd, BLKSSZGET, &h->sector_size)) { + nbdkit_error ("ioctl(BLKSSZGET): %s: %m", filename); + free (h); + return NULL; + } + } +#else + h->sector_size = 4096; /* Safe g...
2002 Jun 26
1
using block devices as harddisks
...-urN bochs-1.4.orig/iodev/harddrv.cc bochs-1.4/iodev/harddrv.cc --- bochs-1.4.orig/iodev/harddrv.cc Mon Mar 25 02:47:14 2002 +++ bochs-1.4/iodev/harddrv.cc Wed Jun 26 09:42:51 2002 @@ -2779,6 +2779,20 @@ if (ret) { BX_PANIC(("fstat() returns error!")); } + if (S_ISBLK(stat_buf.st_mode)) + { +/* it's a block device. st_size will be 0, so set it to the correct size. */ + if (ioctl(fd_table[i],BLKGETSIZE,&(stat_buf.st_size))==-1) + BX_PANIC(("size of block device %s can't be read",pathname)); + if (stat_buf.st_size > (0x...
2006 Mar 21
2
[PATCH] initramfs: CPIO unpacking fix
...nit do_name(void) if (dry_run) return 0; if (S_ISREG(mode)) { + sys_unlink(collected); if (maybe_link() >= 0) { wfd = sys_open(collected, O_WRONLY|O_CREAT, mode); if (wfd >= 0) { @@ -263,6 +264,7 @@ static int __init do_name(void) sys_chmod(collected, mode); } else if (S_ISBLK(mode) || S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) { + sys_unlink(collected); if (maybe_link() == 0) { sys_mknod(collected, mode, rdev); sys_chown(collected, uid, gid); @@ -291,6 +293,7 @@ static int __init do_copy(void) static int __init do_symlink(void) { collected[...
2018 Aug 19
0
[PATCH v4 4/4] file: Zero for block devices on old kernels
...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(statbuf.st_mode); + h->sector_size = 4096; /* Start with safe guess */ + +#ifdef BLKSSZGET + if (h->is_block_device) { + if (ioctl (h->fd, BLKSSZGET, &h->sector_size)) + nbdkit_debug ("cannot get sector size: %s: %m", filename); + } +#endif + #ifdef FALLOC_FL_...
2018 Aug 03
0
[PATCH v2 4/4] file: Zero for block devices on old kernels
...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(statbuf.st_mode); + h->sector_size = 4096; /* Start with safe guess */ + +#ifdef BLKSSZGET + if (h->is_block_device) { + if (ioctl (h->fd, BLKSSZGET, &h->sector_size)) + nbdkit_debug ("cannot get sector size: %s: %m", filename); + } +#endif + #ifdef FALLOC_FL_...
2014 Dec 24
0
[PATCH 1/8] extlinux/main.c: support unmounted ext2/3/4 filesystem
...e(path, &st, &devname); - if (devfd < 0) - return 1; + /* Support dir, ext2, ext3 and ext4 filesystem (device or file block) */ + if S_ISDIR(st.st_mode) { + devfd = open_device(path, &st, &devname); + if (devfd < 0) + return 1; + } else if (S_ISBLK(st.st_mode) || S_ISREG(st.st_mode)) { + if ((devfd = open(path, O_RDWR | O_SYNC)) < 0) { + fprintf(stderr, "%s: cannot open device %s\n", program, devname); + return -1; + } + } else { + fprintf(stderr, "%s: unsupported file type: %s\n...
2015 Sep 10
1
[PATCH] launch: libvirt: Better error when bridge / virbr0 doesn't exist (RHBZ#1262127).
...tfs_pop_error_handler (g); + if (g->enable_network && check_bridge_exists (g, data->network_bridge) == -1) + goto cleanup; + /* Locate and/or build the appliance. */ TRACE0 (launch_build_libvirt_appliance_start); @@ -1988,6 +1992,49 @@ is_blk (const char *path) return S_ISBLK (statbuf.st_mode); } +static int +is_dir (const char *path) +{ + struct stat statbuf; + + if (stat (path, &statbuf) == -1) + return 0; + return S_ISDIR (statbuf.st_mode); +} + +/* Used to check the network_bridge exists, or give a useful error + * message. + */ +static int +check_bridg...
2009 May 29
1
[PATCH v2] klibc-utils: add simple ls
...; max_nlinks) + max_nlinks = bytes; + + if ((bytes = snprintf(NULL, 0, "%ju", (uintmax_t) st->st_uid)) > max_uid) + max_uid = bytes; + + if ((bytes = snprintf(NULL, 0, "%ju", (uintmax_t) st->st_gid)) > max_gid) + max_gid = bytes; + + if (S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode)) { + if ((bytes = snprintf(NULL, 0, "%u", major(st->st_rdev))) > max_maj) + max_maj = bytes; + + if ((bytes = snprintf(NULL, 0, "%u", minor(st->st_rdev))) > max_min) + max_min = bytes; + + max_size = max_maj + max_min + 1; + } + else { + if ((...
2009 May 28
1
[PATCH] klibc-utils: add minils
...; max_nlinks) + max_nlinks = bytes; + + if ((bytes = snprintf(NULL, 0, "%ju", (uintmax_t) st->st_uid)) > max_uid) + max_uid = bytes; + + if ((bytes = snprintf(NULL, 0, "%ju", (uintmax_t) st->st_gid)) > max_gid) + max_gid = bytes; + + if (S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode)) { + if ((bytes = snprintf(NULL, 0, "%u", major(st->st_rdev))) > max_maj) + max_maj = bytes; + + if ((bytes = snprintf(NULL, 0, "%u", minor(st->st_rdev))) > max_min) + max_min = bytes; + + max_size = max_maj + max_min + 1; + } + else { + if ((...
2018 Aug 02
0
[PATCH] file: Zero support for block devices and NFS 4.2
...stat statbuf; int flags; h = malloc (sizeof *h); @@ -144,6 +152,23 @@ 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(statbuf.st_mode); + + /* These flags will disabled if an operation is not supported. */ +#ifdef FALLOC_FL_PUNCH_HOLE + h->can_punch_hole = true; +#endif +#ifdef FALLOC_FL_ZERO_RANGE + h->can_zero_range = true; +#endif + h->can_fallocate = true; + return h; } @@ -164,27 +189,29 @@...
2008 Jul 03
2
iozone remove_suid oops...
...& O_DIRECT) return -EINVAL; pos = *ppos; start_pos = pos; vfs_check_frozen(inode->i_sb, SB_FREEZE_WRITE); current->backing_dev_info = inode->i_mapping->backing_dev_info; err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode)); if (err) goto out_nolock; if (count == 0) goto out_nolock; err = remove_suid(fdentry(file)); <--- -- Daniel J Blueman -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a...