Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/v7fs core symlink operation moved to v7fs_file_util.c...
details: https://anonhg.NetBSD.org/src/rev/ebef65460212
branches: trunk
changeset: 767342:ebef65460212
user: uch <uch%NetBSD.org@localhost>
date: Sat Jul 16 12:35:40 2011 +0000
description:
core symlink operation moved to v7fs_file_util.c and introduce V7FSBSD_MAXSYMLINKLEN for makefs
diffstat:
sys/fs/v7fs/v7fs.h | 4 ++--
sys/fs/v7fs/v7fs_file.h | 3 ++-
sys/fs/v7fs/v7fs_file_util.c | 37 +++++++++++++++++++++++++++++++++++--
sys/fs/v7fs/v7fs_vnops.c | 27 ++++-----------------------
4 files changed, 43 insertions(+), 28 deletions(-)
diffs (146 lines):
diff -r a5ae070e8f7e -r ebef65460212 sys/fs/v7fs/v7fs.h
--- a/sys/fs/v7fs/v7fs.h Sat Jul 16 12:35:32 2011 +0000
+++ b/sys/fs/v7fs/v7fs.h Sat Jul 16 12:35:40 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: v7fs.h,v 1.1 2011/06/27 11:52:24 uch Exp $ */
+/* $NetBSD: v7fs.h,v 1.2 2011/07/16 12:35:40 uch Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -175,6 +175,6 @@
/* Don't apear original V7 filesystem. NetBSD. */
#define V7FSBSD_IFFIFO 0010000 /* Named pipe. */
-#define V7FSBSD_MAXSYMLINKS 8
+#define V7FSBSD_MAXSYMLINKLEN V7FS_BSIZE
#endif /*!_V7FS_H_ */
diff -r a5ae070e8f7e -r ebef65460212 sys/fs/v7fs/v7fs_file.h
--- a/sys/fs/v7fs/v7fs_file.h Sat Jul 16 12:35:32 2011 +0000
+++ b/sys/fs/v7fs/v7fs_file.h Sat Jul 16 12:35:40 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: v7fs_file.h,v 1.1 2011/06/27 11:52:24 uch Exp $ */
+/* $NetBSD: v7fs_file.h,v 1.2 2011/07/16 12:35:40 uch Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -60,5 +60,6 @@
const char *);
bool v7fs_file_lookup_by_number(struct v7fs_self *, struct v7fs_inode *,
v7fs_ino_t, char *);
+int v7fs_file_symlink(struct v7fs_self *, struct v7fs_inode *, const char *);
__END_DECLS
#endif /*!_V7FS_INODE_H_ */
diff -r a5ae070e8f7e -r ebef65460212 sys/fs/v7fs/v7fs_file_util.c
--- a/sys/fs/v7fs/v7fs_file_util.c Sat Jul 16 12:35:32 2011 +0000
+++ b/sys/fs/v7fs/v7fs_file_util.c Sat Jul 16 12:35:40 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: v7fs_file_util.c,v 1.1 2011/06/27 11:52:24 uch Exp $ */
+/* $NetBSD: v7fs_file_util.c,v 1.2 2011/07/16 12:35:40 uch Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: v7fs_file_util.c,v 1.1 2011/06/27 11:52:24 uch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: v7fs_file_util.c,v 1.2 2011/07/16 12:35:40 uch Exp $");
#ifdef _KERNEL
#include <sys/systm.h>
#include <sys/param.h>
@@ -77,6 +77,39 @@
}
int
+v7fs_file_symlink(struct v7fs_self *fs, struct v7fs_inode *p,
+ const char *target)
+{
+ int error;
+ size_t len = strlen(target) + 1;
+
+ if (len > V7FSBSD_MAXSYMLINKLEN) {/* limited target 512byte pathname */
+ DPRINTF("too long pathname.");
+ return ENAMETOOLONG;
+ }
+
+ if ((error = v7fs_datablock_expand(fs, p, len))) {
+ return error;
+ }
+
+ v7fs_daddr_t blk = p->addr[0]; /* 1block only. */
+ void *buf;
+ if (!(buf = scratch_read(fs, blk))) {
+ return EIO;
+ }
+
+ strncpy(buf, target, V7FS_BSIZE);
+ if (!fs->io.write(fs->io.cookie, buf, blk)) {
+ scratch_free(fs, buf);
+ return EIO;
+ }
+ scratch_free(fs, buf);
+ v7fs_inode_writeback(fs, p);
+
+ return 0;
+}
+
+int
v7fs_file_rename(struct v7fs_self *fs, struct v7fs_inode *parent_from,
const char *from, struct v7fs_inode *parent_to, const char *to)
{
diff -r a5ae070e8f7e -r ebef65460212 sys/fs/v7fs/v7fs_vnops.c
--- a/sys/fs/v7fs/v7fs_vnops.c Sat Jul 16 12:35:32 2011 +0000
+++ b/sys/fs/v7fs/v7fs_vnops.c Sat Jul 16 12:35:40 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: v7fs_vnops.c,v 1.3 2011/07/13 12:28:57 uch Exp $ */
+/* $NetBSD: v7fs_vnops.c,v 1.4 2011/07/16 12:35:40 uch Exp $ */
/*-
* Copyright (c) 2004, 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.3 2011/07/13 12:28:57 uch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.4 2011/07/16 12:35:40 uch Exp $");
#if defined _KERNEL_OPT
#include "opt_v7fs.h"
#endif
@@ -1130,7 +1130,7 @@
*a->a_retval = 30; /* ~1G */
break;
case _PC_SYMLINK_MAX:
- *a->a_retval = MAXPATHLEN;
+ *a->a_retval = V7FSBSD_MAXSYMLINKLEN;
break;
case _PC_2_SYMLINKS:
*a->a_retval = 1;
@@ -1224,26 +1224,7 @@
struct v7fs_node *newnode = (*a->a_vpp)->v_data;
struct v7fs_inode *p = &newnode->inode;
-
- if ((error = v7fs_datablock_expand(fs, p, len))) {
- v7fs_inode_deallocate(fs, ino);
- error = ENOSPC;
- goto unlock_exit;
- }
- v7fs_daddr_t blk = p->addr[0]; /* 1block only. */
- void *buf;
- if (!(buf = scratch_read(fs, blk))) {
- v7fs_inode_deallocate(fs, ino);
- error = EIO;
- goto unlock_exit;
- }
- strncpy(buf, from, V7FS_BSIZE);
- if (!fs->io.write(fs->io.cookie, buf, blk)) {
- scratch_free(fs, buf);
- error = EIO;
- goto unlock_exit;
- }
- scratch_free(fs, buf);
+ v7fs_file_symlink(fs, p, from);
uvm_vnp_setsize(*a->a_vpp, v7fs_inode_filesize(p));
newnode->update_ctime = true;
Home |
Main Index |
Thread Index |
Old Index