#define V2_INODE_SIZE usizeof (d2_inode) /* bytes in V2 dsk ino */
#define V2_INDIRECTS(b) ((b)/V2_ZONE_NUM_SIZE) /* # zones/indir block */
#define V2_INODES_PER_BLOCK(b) ((b)/V2_INODE_SIZE)/* # V2 dsk inodes/blk */
+
+#define MFS_MIN(a,b) mfs_min_f(__FILE__,__LINE__,(a), (b))
/* Copy the link name's last component */
r = sys_datacopy(FS_PROC_NR, (vir_bytes) fs_m_in.REQ_PATH,
SELF, (vir_bytes) string,
- (phys_bytes) fs_m_in.REQ_PATH_LEN);
+ (phys_bytes) MFS_MIN(fs_m_in.REQ_PATH_LEN, sizeof(string)));
/* Temporarily open the file. */
if ( (rip = get_inode(fs_dev, fs_m_in.REQ_LINKED_FILE)) == NIL_INODE) {
/* Copy the last component */
r = sys_datacopy(FS_PROC_NR, (vir_bytes) fs_m_in.REQ_PATH,
SELF, (vir_bytes) string,
- (phys_bytes) fs_m_in.REQ_PATH_LEN);
+ (phys_bytes) MFS_MIN(fs_m_in.REQ_PATH_LEN, sizeof(string)));
if (r != OK) return r;
/* Copy the last component of the old name */
r = sys_datacopy(FS_PROC_NR, (vir_bytes) fs_m_in.REQ_PATH,
SELF, (vir_bytes) old_name,
- (phys_bytes) fs_m_in.REQ_PATH_LEN);
+ (phys_bytes) MFS_MIN(fs_m_in.REQ_PATH_LEN, sizeof(old_name)));
if (r != OK) return r;
/* Copy the last component of the new name */
if (oflags & O_CREAT) {
/* Copy the last component */
err_code = sys_datacopy(FS_PROC_NR, (vir_bytes) fs_m_in.REQ_PATH,
- SELF, (vir_bytes) lastc, (phys_bytes) fs_m_in.REQ_PATH_LEN);
+ SELF, (vir_bytes) lastc,
+ (phys_bytes) MFS_MIN(fs_m_in.REQ_PATH_LEN,
+ sizeof(lastc)));
if (err_code != OK) return err_code;
/* Copy the last component */
err_code = sys_datacopy(FS_PROC_NR, (vir_bytes) fs_m_in.REQ_PATH,
- SELF, (vir_bytes) lastc, (phys_bytes) fs_m_in.REQ_PATH_LEN);
+ SELF, (vir_bytes) lastc, (phys_bytes) MFS_MIN(fs_m_in.REQ_PATH_LEN, sizeof(lastc)));
if (err_code != OK) return err_code;
/* Copy the last component and set up caller's user and group id */
err_code = sys_datacopy(FS_PROC_NR, (vir_bytes) fs_m_in.REQ_PATH, SELF,
- (vir_bytes) lastc, (phys_bytes) fs_m_in.REQ_PATH_LEN);
+ (vir_bytes) lastc,
+ (phys_bytes) MFS_MIN(fs_m_in.REQ_PATH_LEN, sizeof(lastc)));
if (err_code != OK) return err_code;
/* Copy the last component and set up caller's user and group id */
err_code = sys_datacopy(FS_PROC_NR, (vir_bytes) fs_m_in.REQ_PATH, SELF,
(vir_bytes) lastc, (phys_bytes)
- MIN(fs_m_in.REQ_PATH_LEN, NAME_MAX));
+ MFS_MIN(fs_m_in.REQ_PATH_LEN, sizeof(lastc)));
if (err_code != OK) return err_code;
/* Copy the link name's last component */
r = sys_datacopy(FS_PROC_NR, (vir_bytes) fs_m_in.REQ_PATH,
SELF, (vir_bytes) string,
- (phys_bytes) fs_m_in.REQ_PATH_LEN);
+ (phys_bytes) MFS_MIN(fs_m_in.REQ_PATH_LEN, sizeof(string)));
if (r != OK) return r;
*===========================================================================*/
PUBLIC int lookup()
{
- char string[NAME_MAX];
+ char string[PATH_MAX];
struct inode *rip;
int s_error, flags;
/* Copy the pathname and set up caller's user and group id */
err_code = sys_datacopy(FS_PROC_NR, (vir_bytes) fs_m_in.REQ_PATH, SELF,
- (vir_bytes) user_path, (phys_bytes) fs_m_in.REQ_PATH_LEN);
+ (vir_bytes) user_path,
+ (phys_bytes) MFS_MIN(fs_m_in.REQ_PATH_LEN, sizeof(string)));
if (err_code != OK) return err_code;
if (err_code != OK || (flags & PATH_PENULTIMATE)) {
s_error = sys_datacopy(SELF_E, (vir_bytes) string, FS_PROC_NR,
(vir_bytes) fs_m_in.REQ_USER_ADDR, (phys_bytes)
- MIN(strlen(string)+1, NAME_MAX));
+ MFS_MIN(strlen(string)+1, NAME_MAX));
if (s_error != OK) return s_error;
}
/* 'bp' now points to a directory block with space. 'dp' points to slot. */
(void) memset(dp->d_name, 0, (size_t) NAME_MAX); /* clear entry */
- for (i = 0; string[i] && i < NAME_MAX; i++) dp->d_name[i] = string[i];
+ for (i = 0; i < NAME_MAX && string[i]; i++) dp->d_name[i] = string[i];
sp = ldir_ptr->i_sp;
dp->d_ino = conv4(sp->s_native, (int) *numb);
bp->b_dirt = DIRTY;
return parse_path(path, string, LAST_DIR);
}
+
_PROTOTYPE( void zero_block, (struct buf *bp) );
_PROTOTYPE( int write_map, (struct inode *, off_t, zone_t, int) );
-/* select.c */
-_PROTOTYPE( int do_select, (void) );
-_PROTOTYPE( int select_callback, (struct filp *, int ops) );
-_PROTOTYPE( void select_forget, (int fproc) );
-_PROTOTYPE( void select_timeout_check, (timer_t *) );
-_PROTOTYPE( void init_select, (void) );
-_PROTOTYPE( void select_unsuspend_by_endpt, (int proc) );
-_PROTOTYPE( int select_notified, (int major, int minor, int ops) );
-
-/* timers.c */
-_PROTOTYPE( void fs_set_timer, (timer_t *tp, int delta, tmr_func_t watchdog, int arg));
-_PROTOTYPE( void fs_expire_timers, (clock_t now) );
-_PROTOTYPE( void fs_cancel_timer, (timer_t *tp) );
-_PROTOTYPE( void fs_init_timer, (timer_t *tp) );
-
-/* cdprobe.c */
-_PROTOTYPE( int cdprobe, (void) );
return( (time_t) (boottime + (uptime/HZ)));
}
-
+int mfs_min_f(char *file, int line, int v1, int v2)
+{
+ if(v2 >= v1) return v1;
+ printf("mfs:%s:%d: truncated %d to %d\n",
+ file, line, v1, v2);
+ return v2;
+}
register char *rpu, *rpm;
int r;
+ if(len >= sizeof(user_fullpath)) {
+ panic(__FILE__, "fetch_name: len too much for user_fullpath", len);
+ }
+
/* Check name length for validity. */
if (len <= 0) {
err_code = EINVAL;
FS_PROC_NR, (vir_bytes) user_fullpath, (phys_bytes) len);
}
+ if(user_fullpath[len-1] != '\0') {
+ int i;
+ printf("fetch_name: name not null-terminated: ");
+ for(i = 0; i < len; i++) {
+ printf("%c", user_fullpath[i]);
+ }
+ printf("\n");
+ user_fullpath[len-1] = '\0';
+ }
+
return(r);
}