2 * Copyright (C) 1997, 1998, 1999, 2001, 2007 Free Software Foundation, Inc.
3 * Copyright (C) 2013 Steven McDonald <steven@steven-mcdonald.id.au>
5 * ftpfs translator written by Miles Bader <miles@gnu.org>
6 * Modified for trovefs by Steven McDonald <steven@steven-mcdonald.id.au>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
13 * This software is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
27 #include <hurd/netfs.h>
32 netfs_attempt_link (struct iouser *user, struct node *dir, struct node *file, char *name, int excl)
34 fprintf (stderr, "a\n");
39 netfs_attempt_create_file (struct iouser *user, struct node *dir, char *name, mode_t mode, struct node **node)
41 fprintf (stderr, "b\n");
46 netfs_attempt_chown (struct iouser *cred, struct node *node, uid_t uid, uid_t gid)
48 fprintf (stderr, "c\n");
53 netfs_node_norefs (struct node *node)
55 fprintf (stderr, "d\n");
60 netfs_attempt_mksymlink (struct iouser *cred, struct node *node, char *name)
62 fprintf (stderr, "e\n");
67 netfs_attempt_unlink (struct iouser *user, struct node *dir, char *name)
69 fprintf (stderr, "f\n");
74 netfs_attempt_syncfs (struct iouser *cred, int wait)
80 netfs_attempt_lookup (struct iouser *user, struct node *dir, char *name, struct node **node)
82 fprintf (stderr, "h\n");
87 netfs_attempt_chauthor (struct iouser *cred, struct node *node, uid_t author)
89 fprintf (stderr, "i\n");
94 netfs_attempt_mkdir (struct iouser *user, struct node *dir, char *name, mode_t mode)
96 fprintf (stderr, "j\n");
101 netfs_attempt_mkfile (struct iouser *user, struct node *dir, mode_t mode, struct node **node)
103 fprintf (stderr, "k\n");
108 netfs_attempt_readlink (struct iouser *user, struct node *node, char *buf)
110 fprintf (stderr, "l\n");
115 netfs_attempt_sync (struct iouser *cred, struct node *node, int wait)
117 fprintf (stderr, "m\n");
122 netfs_attempt_statfs (struct iouser *cred, struct node *node, fsys_statfsbuf_t *st)
124 fprintf (stderr, "n\n");
129 netfs_validate_stat (struct node *node, struct iouser *cred)
131 return trovefs_refresh_node (node);
135 netfs_attempt_chmod (struct iouser *cred, struct node *node, mode_t mode)
137 fprintf (stderr, "p\n");
142 netfs_attempt_set_size (struct iouser *cred, struct node *node, loff_t size)
144 fprintf (stderr, "q\n");
149 netfs_attempt_rmdir (struct iouser *user, struct node *dir, char *name)
151 fprintf (stderr, "r\n");
155 #define DIRENTS_CHUNK_SIZE (8*1024)
156 #define DIRENT_ALIGN 4
157 #define DIRENT_NAME_OFFS offsetof (struct dirent, d_name)
158 #define DIRENT_LEN(name_len) ((DIRENT_NAME_OFFS + (name_len) + 1 + (DIRENT_ALIGN - 1)) & ~(DIRENT_ALIGN - 1))
160 netfs_get_dirents (struct iouser *cred, struct node *dir, int first_entry, int max_entries, char **data, mach_msg_type_number_t *data_len, vm_size_t max_data_len, int *data_entries)
162 error_t err = trovefs_refresh_node (dir);
167 struct trovefs_dir *realdir = dir->nn->dir_entry->dir;
172 struct trovefs_dir_entry *e;
173 e = realdir->ordered;
175 while (first_entry-- > 0)
184 if (max_entries != 0)
186 size_t size = (max_data_len == 0 || max_data_len > DIRENTS_CHUNK_SIZE ? DIRENTS_CHUNK_SIZE : max_data_len);
187 *data = mmap (0, size, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
188 err = ((void *) *data == (void *) -1) ? errno : 0;
195 while ((max_entries == -1 || count < max_entries) && e)
198 size_t name_len = strlen (e->name);
199 size_t sz = DIRENT_LEN (name_len);
200 int entry_type = e->stat_timestamp ? IFTODT (e->stat.st_mode) : DT_UNKNOWN;
202 if ((p - *data) + sz > size)
204 if (max_data_len > 0)
208 vm_address_t extension = (vm_address_t)(*data + size);
209 err = vm_allocate (mach_task_self (), &extension, DIRENTS_CHUNK_SIZE, 0);
212 size += DIRENTS_CHUNK_SIZE;
216 hdr.d_namlen = name_len;
217 hdr.d_fileno = e->stat.st_ino;
219 hdr.d_type = entry_type;
221 memcpy (p, &hdr, DIRENT_NAME_OFFS);
222 strcpy (p + DIRENT_NAME_OFFS, e->name);
230 munmap (*data, size);
233 vm_address_t alloc_end = (vm_address_t)(*data + size);
234 vm_address_t real_end = round_page (p);
235 if (alloc_end > real_end)
236 munmap ((caddr_t) real_end, alloc_end - real_end);
237 *data_len = p - *data;
238 *data_entries = count;
252 netfs_attempt_chflags (struct iouser *cred, struct node *node, int flags)
254 fprintf (stderr, "t\n");
259 netfs_attempt_write (struct iouser *cred, struct node *node, loff_t offset, size_t *len, void *data)
261 fprintf (stderr, "u\n");
266 netfs_attempt_read (struct iouser *cred, struct node *node, loff_t offset, size_t *len, void *data)
268 fprintf (stderr, "v\n");
273 netfs_report_access (struct iouser *cred, struct node *node, int *types)
275 fprintf (stderr, "w\n");
280 netfs_attempt_mkdev (struct iouser *cred, struct node *node, mode_t type, dev_t indexes)
282 fprintf (stderr, "x\n");
287 netfs_attempt_utimes (struct iouser *cred, struct node *node, struct timespec *atime, struct timespec *mtime)
289 fprintf (stderr, "y\n");
294 netfs_check_open_permissions (struct iouser *user, struct node *node, int flags, int newnode)
300 netfs_attempt_rename (struct iouser *user, struct node *fromdir, char *fromname, struct node *todir, char *toname, int excl)
302 fprintf (stderr, "=\n");