* Got rid of the duality of FS_WRITE_STAT_* vs. B_STAT_* flags (removed

the former ones).
* Removed extraneous white space.
* net_server settings are now also updated when the size of the 
  file changed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24552 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-03-24 12:04:47 +00:00
parent 1879dc35bf
commit 5e2ef462ec
13 changed files with 576 additions and 603 deletions
+3 -12
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2004-2007, Haiku Inc. All Rights Reserved. * Copyright 2004-2008, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _FS_INTERFACE_H #ifndef _FS_INTERFACE_H
@@ -26,18 +26,9 @@ typedef void *fs_volume;
typedef void *fs_cookie; typedef void *fs_cookie;
typedef void *fs_vnode; typedef void *fs_vnode;
/* passed to write_stat() */ /* additional flags passed to write_stat() (see NodeMonitor.h for the others) */
enum write_stat_mask { // NOTE: Changing the constants here or in NodeMonitor.h will break
FS_WRITE_STAT_MODE = 0x0001,
FS_WRITE_STAT_UID = 0x0002,
FS_WRITE_STAT_GID = 0x0004,
FS_WRITE_STAT_SIZE = 0x0008,
FS_WRITE_STAT_ATIME = 0x0010,
FS_WRITE_STAT_MTIME = 0x0020,
FS_WRITE_STAT_CRTIME = 0x0040
// NOTE: Changing these constants will break
// src/kits/storage/LibBeAdapter.cpp:_kern_write_stat(). // src/kits/storage/LibBeAdapter.cpp:_kern_write_stat().
};
/* passed to write_fs_info() */ /* passed to write_fs_info() */
#define FS_WRITE_FSINFO_NAME 0x0001 #define FS_WRITE_FSINFO_NAME 0x0001
@@ -874,17 +874,6 @@
#define fs_cookie fssh_fs_cookie #define fs_cookie fssh_fs_cookie
#define fs_vnode fssh_fs_vnode #define fs_vnode fssh_fs_vnode
/* passed to write_stat() */
#define write_stat_mask fssh_write_stat_mask
#define FS_WRITE_STAT_MODE FSSH_FS_WRITE_STAT_MODE
#define FS_WRITE_STAT_UID FSSH_FS_WRITE_STAT_UID
#define FS_WRITE_STAT_GID FSSH_FS_WRITE_STAT_GID
#define FS_WRITE_STAT_SIZE FSSH_FS_WRITE_STAT_SIZE
#define FS_WRITE_STAT_ATIME FSSH_FS_WRITE_STAT_ATIME
#define FS_WRITE_STAT_MTIME FSSH_FS_WRITE_STAT_MTIME
#define FS_WRITE_STAT_CRTIME FSSH_FS_WRITE_STAT_CRTIME
/* passed to write_fs_info() */ /* passed to write_fs_info() */
#define FS_WRITE_FSINFO_NAME FSSH_FS_WRITE_FSINFO_NAME #define FS_WRITE_FSINFO_NAME FSSH_FS_WRITE_FSINFO_NAME
+2 -11
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2004-2007, Haiku Inc. All Rights Reserved. * Copyright 2004-2008, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _FSSH_FS_INTERFACE_H #ifndef _FSSH_FS_INTERFACE_H
@@ -28,16 +28,7 @@ typedef void *fssh_fs_volume;
typedef void *fssh_fs_cookie; typedef void *fssh_fs_cookie;
typedef void *fssh_fs_vnode; typedef void *fssh_fs_vnode;
/* passed to write_stat() */ /* additional flags passed to write_stat() */
enum fssh_write_stat_mask {
FSSH_FS_WRITE_STAT_MODE = 0x0001,
FSSH_FS_WRITE_STAT_UID = 0x0002,
FSSH_FS_WRITE_STAT_GID = 0x0004,
FSSH_FS_WRITE_STAT_SIZE = 0x0008,
FSSH_FS_WRITE_STAT_ATIME = 0x0010,
FSSH_FS_WRITE_STAT_MTIME = 0x0020,
FSSH_FS_WRITE_STAT_CRTIME = 0x0040
};
/* passed to write_fs_info() */ /* passed to write_fs_info() */
#define FSSH_FS_WRITE_FSINFO_NAME 0x0001 #define FSSH_FS_WRITE_FSINFO_NAME 0x0001
+3 -3
View File
@@ -220,7 +220,7 @@ dosfs_wstat(void *_vol, void *_node, const struct stat *st, uint32 mask)
return EPERM; return EPERM;
} }
if (mask & FS_WRITE_STAT_MODE) { if (mask & B_STAT_MODE) {
DPRINTF(0, ("setting file mode to %o\n", st->st_mode)); DPRINTF(0, ("setting file mode to %o\n", st->st_mode));
if (st->st_mode & S_IWUSR) if (st->st_mode & S_IWUSR)
node->mode &= ~FAT_READ_ONLY; node->mode &= ~FAT_READ_ONLY;
@@ -229,7 +229,7 @@ dosfs_wstat(void *_vol, void *_node, const struct stat *st, uint32 mask)
dirty = true; dirty = true;
} }
if (mask & FS_WRITE_STAT_SIZE) { if (mask & B_STAT_SIZE) {
DPRINTF(0, ("setting file size to %Lx\n", st->st_size)); DPRINTF(0, ("setting file size to %Lx\n", st->st_size));
if (node->mode & FAT_SUBDIR) { if (node->mode & FAT_SUBDIR) {
dprintf("dosfs_wstat: can't set file size of directory!\n"); dprintf("dosfs_wstat: can't set file size of directory!\n");
@@ -250,7 +250,7 @@ dosfs_wstat(void *_vol, void *_node, const struct stat *st, uint32 mask)
} }
} }
if (mask & FS_WRITE_STAT_MTIME) { if (mask & B_STAT_MODIFICATION_TIME) {
DPRINTF(0, ("setting modification time\n")); DPRINTF(0, ("setting modification time\n"));
node->st_time = st->st_mtime; node->st_time = st->st_mtime;
dirty = true; dirty = true;
@@ -7,13 +7,13 @@
# include <fs_info.h> # include <fs_info.h>
# include <NodeMonitor.h> # include <NodeMonitor.h>
typedef dev_t nspace_id; typedef dev_t nspace_id;
# define WSTAT_MODE FS_WRITE_STAT_MODE # define WSTAT_MODE B_STAT_MODE
# define WSTAT_UID FS_WRITE_STAT_UID # define WSTAT_UID B_STAT_UID
# define WSTAT_GID FS_WRITE_STAT_GID # define WSTAT_GID B_STAT_GID
# define WSTAT_SIZE FS_WRITE_STAT_SIZE # define WSTAT_SIZE B_STAT_SIZE
# define WSTAT_ATIME FS_WRITE_STAT_ATIME # define WSTAT_ATIME B_STAT_ACCESS_TIME
# define WSTAT_MTIME FS_WRITE_STAT_MTIME # define WSTAT_MTIME B_STAT_MODIFICATION_TIME
# define WSTAT_CRTIME FS_WRITE_STAT_CRTIME # define WSTAT_CRTIME B_STAT_CREATION_TIME
#else #else
# include "fsproto.h" # include "fsproto.h"
@@ -684,7 +684,7 @@ fs_wstat(void *_vol, void *_node, struct stat *st, long mask)
} }
#ifdef __HAIKU__ #ifdef __HAIKU__
if ( mask & FS_WRITE_STAT_SIZE ) { if ( mask & B_STAT_SIZE ) {
#else #else
if (mask & WSTAT_SIZE) { if (mask & WSTAT_SIZE) {
#endif #endif
@@ -715,7 +715,7 @@ fs_wstat(void *_vol, void *_node, struct stat *st, long mask)
} }
#ifdef __HAIKU__ #ifdef __HAIKU__
if (mask & FS_WRITE_STAT_MTIME) { if (mask & B_STAT_MODIFICATION_TIME) {
#else #else
if (mask & WSTAT_MTIME) { if (mask & WSTAT_MTIME) {
#endif #endif
+3 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved. * Copyright 2006-2008, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -342,8 +342,8 @@ Settings::Update(BMessage* message)
int32 fields; int32 fields;
if (opcode == B_STAT_CHANGED if (opcode == B_STAT_CHANGED
&& message->FindInt32("fields", &fields) == B_OK && message->FindInt32("fields", &fields) == B_OK
&& (fields & FS_WRITE_STAT_MTIME) == 0) { && (fields & (B_STAT_MODIFICATION_TIME | B_STAT_SIZE)) == 0) {
// only update when the modified time has changed // only update when the modified time or size has changed
return B_OK; return B_OK;
} }
+6 -6
View File
@@ -2499,24 +2499,24 @@ devfs_write_stat(fs_volume _fs, fs_vnode _vnode, const struct stat *stat,
stat)); stat));
// we cannot change the size of anything // we cannot change the size of anything
if (statMask & FS_WRITE_STAT_SIZE) if (statMask & B_STAT_SIZE)
return B_BAD_VALUE; return B_BAD_VALUE;
RecursiveLocker locker(&fs->lock); RecursiveLocker locker(&fs->lock);
if (statMask & FS_WRITE_STAT_MODE) { if (statMask & B_STAT_MODE) {
vnode->stream.type = (vnode->stream.type & ~S_IUMSK) vnode->stream.type = (vnode->stream.type & ~S_IUMSK)
| (stat->st_mode & S_IUMSK); | (stat->st_mode & S_IUMSK);
} }
if (statMask & FS_WRITE_STAT_UID) if (statMask & B_STAT_UID)
vnode->uid = stat->st_uid; vnode->uid = stat->st_uid;
if (statMask & FS_WRITE_STAT_GID) if (statMask & B_STAT_GID)
vnode->gid = stat->st_gid; vnode->gid = stat->st_gid;
if (statMask & FS_WRITE_STAT_MTIME) if (statMask & B_STAT_MODIFICATION_TIME)
vnode->modification_time = stat->st_mtime; vnode->modification_time = stat->st_mtime;
if (statMask & FS_WRITE_STAT_CRTIME) if (statMask & B_STAT_CREATION_TIME)
vnode->creation_time = stat->st_crtime; vnode->creation_time = stat->st_crtime;
notify_stat_changed(fs->id, vnode->id, statMask); notify_stat_changed(fs->id, vnode->id, statMask);
+5 -5
View File
@@ -1,10 +1,10 @@
/* /*
** Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the Haiku License. * Distributed under the terms of the MIT License.
*/ */
#include <fs_interface.h> #include <NodeMonitor.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <syscalls.h> #include <syscalls.h>
@@ -27,7 +27,7 @@ chmod(const char *path, mode_t mode)
stat.st_mode = mode; stat.st_mode = mode;
status = _kern_write_stat(-1, path, true, &stat, sizeof(struct stat), status = _kern_write_stat(-1, path, true, &stat, sizeof(struct stat),
FS_WRITE_STAT_MODE); B_STAT_MODE);
RETURN_AND_SET_ERRNO(status); RETURN_AND_SET_ERRNO(status);
} }
@@ -41,7 +41,7 @@ fchmod(int fd, mode_t mode)
stat.st_mode = mode; stat.st_mode = mode;
status = _kern_write_stat(fd, NULL, false, &stat, sizeof(struct stat), status = _kern_write_stat(fd, NULL, false, &stat, sizeof(struct stat),
FS_WRITE_STAT_MODE); B_STAT_MODE);
RETURN_AND_SET_ERRNO(status); RETURN_AND_SET_ERRNO(status);
} }
+6 -6
View File
@@ -1,10 +1,10 @@
/* /*
** Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the Haiku License. * Distributed under the terms of the MIT License.
*/ */
#include <fs_interface.h> #include <NodeMonitor.h>
#include <unistd.h> #include <unistd.h>
#include <syscalls.h> #include <syscalls.h>
@@ -28,7 +28,7 @@ chown(const char *path, uid_t owner, gid_t group)
stat.st_uid = owner; stat.st_uid = owner;
stat.st_gid = group; stat.st_gid = group;
status = _kern_write_stat(-1, path, true, &stat, sizeof(struct stat), status = _kern_write_stat(-1, path, true, &stat, sizeof(struct stat),
FS_WRITE_STAT_UID | FS_WRITE_STAT_GID); B_STAT_UID | B_STAT_GID);
RETURN_AND_SET_ERRNO(status); RETURN_AND_SET_ERRNO(status);
} }
@@ -43,7 +43,7 @@ lchown(const char *path, uid_t owner, gid_t group)
stat.st_uid = owner; stat.st_uid = owner;
stat.st_gid = group; stat.st_gid = group;
status = _kern_write_stat(-1, path, false, &stat, sizeof(struct stat), status = _kern_write_stat(-1, path, false, &stat, sizeof(struct stat),
FS_WRITE_STAT_UID | FS_WRITE_STAT_GID); B_STAT_UID | B_STAT_GID);
RETURN_AND_SET_ERRNO(status); RETURN_AND_SET_ERRNO(status);
} }
@@ -58,7 +58,7 @@ fchown(int fd, uid_t owner, gid_t group)
stat.st_uid = owner; stat.st_uid = owner;
stat.st_gid = group; stat.st_gid = group;
status = _kern_write_stat(fd, NULL, false, &stat, sizeof(struct stat), status = _kern_write_stat(fd, NULL, false, &stat, sizeof(struct stat),
FS_WRITE_STAT_UID | FS_WRITE_STAT_GID); B_STAT_UID | B_STAT_GID);
RETURN_AND_SET_ERRNO(status); RETURN_AND_SET_ERRNO(status);
} }
+5 -4
View File
@@ -1,10 +1,11 @@
/* /*
** Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the Haiku License. * Distributed under the terms of the MIT License.
*/ */
#include <fs_interface.h> #include <fs_interface.h>
#include <NodeMonitor.h>
#include <unistd.h> #include <unistd.h>
#include <syscalls.h> #include <syscalls.h>
@@ -27,7 +28,7 @@ truncate(const char *path, off_t newSize)
stat.st_size = newSize; stat.st_size = newSize;
status = _kern_write_stat(-1, path, true, &stat, sizeof(struct stat), status = _kern_write_stat(-1, path, true, &stat, sizeof(struct stat),
FS_WRITE_STAT_SIZE); B_STAT_SIZE);
RETURN_AND_SET_ERRNO(status); RETURN_AND_SET_ERRNO(status);
} }
@@ -41,7 +42,7 @@ ftruncate(int fd, off_t newSize)
stat.st_size = newSize; stat.st_size = newSize;
status = _kern_write_stat(fd, NULL, false, &stat, sizeof(struct stat), status = _kern_write_stat(fd, NULL, false, &stat, sizeof(struct stat),
FS_WRITE_STAT_SIZE); B_STAT_SIZE);
RETURN_AND_SET_ERRNO(status); RETURN_AND_SET_ERRNO(status);
} }
+4 -4
View File
@@ -1,10 +1,10 @@
/* /*
** Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the Haiku License. * Distributed under the terms of the MIT License.
*/ */
#include <fs_interface.h> #include <NodeMonitor.h>
#include <utime.h> #include <utime.h>
#include <time.h> #include <time.h>
@@ -33,7 +33,7 @@ utime(const char *path, const struct utimbuf *times)
stat.st_atime = stat.st_mtime = time(NULL); stat.st_atime = stat.st_mtime = time(NULL);
status = _kern_write_stat(-1, path, true, &stat, sizeof(struct stat), status = _kern_write_stat(-1, path, true, &stat, sizeof(struct stat),
FS_WRITE_STAT_MTIME | FS_WRITE_STAT_ATIME); B_STAT_MODIFICATION_TIME | B_STAT_ACCESS_TIME);
RETURN_AND_SET_ERRNO(status); RETURN_AND_SET_ERRNO(status);
} }
+2 -1
View File
@@ -24,6 +24,7 @@
#include "fssh_errno.h" #include "fssh_errno.h"
#include "fssh_errors.h" #include "fssh_errors.h"
#include "fssh_module.h" #include "fssh_module.h"
#include "fssh_node_monitor.h"
#include "fssh_stat.h" #include "fssh_stat.h"
#include "fssh_string.h" #include "fssh_string.h"
#include "fssh_type_constants.h" #include "fssh_type_constants.h"
@@ -348,7 +349,7 @@ command_chmod(int argc, const char* const* argv)
} }
fssh_status_t error = _kern_write_stat(-1, file, false, &st, sizeof(st), fssh_status_t error = _kern_write_stat(-1, file, false, &st, sizeof(st),
FSSH_FS_WRITE_STAT_MODE); FSSH_B_STAT_MODE);
if (error != FSSH_B_OK) { if (error != FSSH_B_OK) {
fprintf(stderr, "Error: Failed to change mode of \"%s\"!\n", file); fprintf(stderr, "Error: Failed to change mode of \"%s\"!\n", file);
return error; return error;