You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(2) |
Feb
(39) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(4) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Ben O. <ben...@us...> - 2002-02-24 00:21:46
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv1967 Modified Files: njb_usb.c Log Message: ben: shuffle some add, move function prototypes to njb_usb.h, make functions non-static Index: njb_usb.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/njb_usb.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** njb_usb.c 10 Feb 2002 21:59:23 -0000 1.4 --- njb_usb.c 24 Feb 2002 00:21:44 -0000 1.5 *************** *** 38,78 **** #include "track.h" #include "playlist.h" - - /* forward decl's */ - static int njb_usb_connect(struct nomad_usb_data *nomad); - static int njb_usb_disconnect(struct nomad_usb_data *nomad); - static int njb_usb_open(struct nomad_usb_data *nomad, - struct njbfs_fattr *fattr); - static int njb_usb_close(struct nomad_usb_data *nomad, - struct njbfs_fattr *fattr); - static int njb_usb_write(struct nomad_usb_data *nomad, char *name, - u_int32_t offset, u_int32_t count, void *buffer); - static int njb_usb_read(struct nomad_usb_data *nomad, char *name, - u_int32_t offset, u_int32_t count, void *buffer); - static int njb_usb_rename(struct nomad_usb_data *nomad, - struct njbfs_fattr *fattr); - static int njb_usb_delete(struct nomad_usb_data *nomad, char *file); - static int njb_usb_create(struct nomad_usb_data *nomad, char *file); - static int njb_usb_check(struct nomad_usb_data *njb); - static int njb_usb_capture(struct nomad_usb_data *njb); - static int njb_usb_handshake(struct nomad_usb_data *njb); - static int njb_usb_release(struct nomad_usb_data *njb); - static int njb_usb_control(struct nomad_usb_data *njb, unsigned int pipe, - int request, int requesttype, int value, - int index, void *data, int size, int retries); - static int njb_usb_verify_last_command(struct nomad_usb_data *njb); - static int njb_usb_update_library_counter(struct nomad_usb_data *njb); - static track_t *njb_usb_update_track_tag(struct nomad_usb_data *njb, - struct njbfs_fattr *fattr, - u_int32_t * trackid); - static int njb_usb_get_disk_usage(struct nomad_usb_data *njb, - u_int64_t * total, u_int64_t * free); - #ifdef DEBUG void dump_data(unsigned char *data, int count); #endif --- 38,122 ---- #include "track.h" #include "playlist.h" + #include "proc.h" #ifdef DEBUG void dump_data(unsigned char *data, int count); #endif + /** + * Check the internal state of the NJB connection. + * The NJB USB structure and the device should be plugged in. + * These are sanity checks. It is never assumed that a NJB + * structure is missing, this function makes it only harder to + * bypass the internal NJB connection management. + * + * @param njb the NJB USB structure + * @return 0 if success, otherwise < 0 + */ + int njb_usb_check(struct nomad_usb_data *njb) + { + if (!njb) { + err("check: driver not installed"); + return -ENXIO; + } + if (!(njb->nomad_dev)) { + err("check: jukebox not connected"); + return -ENODEV; + } + return 0; + } + + /** + * Send NJB control message. On the USB, all communications are + * initiated by the host through the control pipe. A request packet + * is sent, followed by a data phase for that request, if there is + * data associated with the request. The setup and data phases are + * done on the control pipe, with the setup packet indicating the + * direction flow for the data phase. Additional data may be sent + * after the control message via the bulk data pipes in response to a + * request. + * + * @param njb the NJB USB structure + * @param pipe the control pipe + * @param request the request + * @param requesttype the type of the request + * @param value a value for the request + * @param index an index for the request + * @param data the data buffer for the request (not NULL) + * @param size the size of the data buffer + * @param retries how many times the control message shall be retried + */ + int + njb_usb_control(struct nomad_usb_data *njb, unsigned int pipe, + int request, int requesttype, int value, int index, + void *data, int size, int retries) + { + int status; + + if ((status = njb_usb_check(njb)) < 0) + return status; + + down(&(njb->lock)); + while (retries) { + status = + usb_control_msg(njb->nomad_dev, pipe, request, + requesttype, value, index, data, size, + USB_CONTROL_TIMEOUT); + if (status == -ETIMEDOUT) { + dbg("control: got a timeout, retrying..."); + retries--; + } else if (status < 0) { + err("control: error, result = %d", + le32_to_cpu(status)); + retries = 0; + } else { + retries = 0; + } + } + up(&(njb->lock)); + + return 0; + } *************** *** 84,88 **** * @param 0 if success, otherwise < 0 */ ! static int njb_usb_connect(struct nomad_usb_data *njb) { int status; --- 128,132 ---- * @param 0 if success, otherwise < 0 */ ! int njb_usb_connect(struct nomad_usb_data *njb) { int status; *************** *** 104,108 **** * @param 0 if success, otherwise < 0 */ ! static int njb_usb_disconnect(struct nomad_usb_data *njb) { int status; --- 148,152 ---- * @param 0 if success, otherwise < 0 */ ! int njb_usb_disconnect(struct nomad_usb_data *njb) { int status; *************** *** 123,127 **** * @param fattr the file attributes */ ! static int njb_usb_open(struct nomad_usb_data *njb, struct njbfs_fattr *fattr) { --- 167,171 ---- * @param fattr the file attributes */ ! int njb_usb_open(struct nomad_usb_data *njb, struct njbfs_fattr *fattr) { *************** *** 257,261 **** * Close NJB on USB. */ ! static int njb_usb_close(struct nomad_usb_data *njb, struct njbfs_fattr *fattr) { --- 301,305 ---- * Close NJB on USB. */ ! int njb_usb_close(struct nomad_usb_data *njb, struct njbfs_fattr *fattr) { *************** *** 323,327 **** * Read block from USB NJB */ ! static int njb_usb_read(struct nomad_usb_data *njb, char *name, u_int32_t offset, u_int32_t count, void *buffer) --- 367,371 ---- * Read block from USB NJB */ ! int njb_usb_read(struct nomad_usb_data *njb, char *name, u_int32_t offset, u_int32_t count, void *buffer) *************** *** 402,406 **** * @return 0 if success, otherwise < 0 */ ! static int njb_usb_write(struct nomad_usb_data *njb, char *name, u_int32_t offset, u_int32_t count, void *buffer) --- 446,450 ---- * @return 0 if success, otherwise < 0 */ ! int njb_usb_write(struct nomad_usb_data *njb, char *name, u_int32_t offset, u_int32_t count, void *buffer) *************** *** 479,483 **** */ ! static int njb_usb_rename(struct nomad_usb_data *njb, struct njbfs_fattr *fattr) { --- 523,527 ---- */ ! int njb_usb_rename(struct nomad_usb_data *njb, struct njbfs_fattr *fattr) { *************** *** 500,504 **** * Delete a file from the NJB */ ! static int njb_usb_delete(struct nomad_usb_data *nomad, char *file) { info("TODO: usb delete"); --- 544,548 ---- * Delete a file from the NJB */ ! int njb_usb_delete(struct nomad_usb_data *nomad, char *file) { info("TODO: usb delete"); *************** *** 510,514 **** * Create a file on the NJB */ ! static int njb_usb_create(struct nomad_usb_data *njb, char *file) { info("TODO: create"); --- 554,558 ---- * Create a file on the NJB */ ! int njb_usb_create(struct nomad_usb_data *njb, char *file) { info("TODO: create"); *************** *** 519,596 **** /* ----------------------- NJB functions -------------------------- */ - /** - * Check the internal state of the NJB connection. - * The NJB USB structure and the device should be plugged in. - * These are sanity checks. It is never assumed that a NJB - * structure is missing, this function makes it only harder to - * bypass the internal NJB connection management. - * - * @param njb the NJB USB structure - * @return 0 if success, otherwise < 0 - */ - int njb_usb_check(struct nomad_usb_data *njb) - { - if (!njb) { - err("check: driver not installed"); - return -ENXIO; - } - if (!(njb->nomad_dev)) { - err("check: jukebox not connected"); - return -ENODEV; - } - return 0; - } - /** - * Send NJB control message. On the USB, all communications are - * initiated by the host through the control pipe. A request packet - * is sent, followed by a data phase for that request, if there is - * data associated with the request. The setup and data phases are - * done on the control pipe, with the setup packet indicating the - * direction flow for the data phase. Additional data may be sent - * after the control message via the bulk data pipes in response to a - * request. - * - * @param njb the NJB USB structure - * @param pipe the control pipe - * @param request the request - * @param requesttype the type of the request - * @param value a value for the request - * @param index an index for the request - * @param data the data buffer for the request (not NULL) - * @param size the size of the data buffer - * @param retries how many times the control message shall be retried - */ - static int - njb_usb_control(struct nomad_usb_data *njb, unsigned int pipe, - int request, int requesttype, int value, int index, - void *data, int size, int retries) - { - int status; - - if ((status = njb_usb_check(njb)) < 0) - return status; - - down(&(njb->lock)); - while (retries) { - status = - usb_control_msg(njb->nomad_dev, pipe, request, - requesttype, value, index, data, size, - USB_CONTROL_TIMEOUT); - if (status == -ETIMEDOUT) { - dbg("control: got a timeout, retrying..."); - retries--; - } else if (status < 0) { - err("control: error, result = %d", - le32_to_cpu(status)); - retries = 0; - } else { - retries = 0; - } - } - up(&(njb->lock)); - - return 0; - } /** --- 563,567 ---- *************** *** 604,608 **** * */ ! static int njb_usb_capture(struct nomad_usb_data *njb) { int status; --- 575,579 ---- * */ ! int njb_usb_capture(struct nomad_usb_data *njb) { int status; *************** *** 642,646 **** * @return 0 if success, otherwise < 0 */ ! static int njb_usb_release(struct nomad_usb_data *njb) { int status; --- 613,617 ---- * @return 0 if success, otherwise < 0 */ ! int njb_usb_release(struct nomad_usb_data *njb) { int status; *************** *** 672,676 **** * @return 0 if success, otherwise < 0 */ ! static int njb_usb_verify_last_command(struct nomad_usb_data *njb) { int status; --- 643,647 ---- * @return 0 if success, otherwise < 0 */ ! int njb_usb_verify_last_command(struct nomad_usb_data *njb) { int status; *************** *** 699,703 **** * @return 0 if success, otherwise < 0 */ ! static int njb_usb_ping(struct nomad_usb_data *njb, njbid_t * njbid) { unsigned char data[58]; --- 670,674 ---- * @return 0 if success, otherwise < 0 */ ! int njb_usb_ping(struct nomad_usb_data *njb, njbid_t * njbid) { unsigned char data[58]; *************** *** 755,759 **** * @return 0 if success, otherwise < 0 */ ! static int njb_usb_set_library_counter(struct nomad_usb_data *njb, u_int64_t count) { --- 726,730 ---- * @return 0 if success, otherwise < 0 */ ! int njb_usb_set_library_counter(struct nomad_usb_data *njb, u_int64_t count) { *************** *** 790,794 **** * @return 0 if success, otherwise < 0 */ ! static int njb_usb_get_library_counter(struct nomad_usb_data *njb, njblibctr_t * lcount) --- 761,765 ---- * @return 0 if success, otherwise < 0 */ ! int njb_usb_get_library_counter(struct nomad_usb_data *njb, njblibctr_t * lcount) *************** *** 834,838 **** * @return 0 if success, otherwise < 0 */ ! static int njb_usb_handshake(struct nomad_usb_data *njb) { int status; --- 805,809 ---- * @return 0 if success, otherwise < 0 */ ! int njb_usb_handshake(struct nomad_usb_data *njb) { int status; *************** *** 919,923 **** * @return 0 if success, otherwise < 0 */ ! static int njb_usb_update_library_counter(struct nomad_usb_data *njb) { int status; --- 890,894 ---- * @return 0 if success, otherwise < 0 */ ! int njb_usb_update_library_counter(struct nomad_usb_data *njb) { int status; *************** *** 962,966 **** * @return 0 if everything is ok or <0 if there was an error */ ! static int njb_usb_get_track_tag_header(struct nomad_usb_data *njb, njbttaghdr_t * header, int cmd) --- 933,937 ---- * @return 0 if everything is ok or <0 if there was an error */ ! int njb_usb_get_track_tag_header(struct nomad_usb_data *njb, njbttaghdr_t * header, int cmd) *************** *** 1009,1013 **** ! inline static int njb_usb_get_first_track_tag_header(struct nomad_usb_data *njb, njbttaghdr_t * header) --- 980,984 ---- ! inline int njb_usb_get_first_track_tag_header(struct nomad_usb_data *njb, njbttaghdr_t * header) *************** *** 1017,1021 **** } ! inline static int njb_usb_get_next_track_tag_header(struct nomad_usb_data *njb, njbttaghdr_t * header) --- 988,992 ---- } ! inline int njb_usb_get_next_track_tag_header(struct nomad_usb_data *njb, njbttaghdr_t * header) *************** *** 1031,1035 **** * previously "Get Track Tag Header" request. */ ! static track_t *njb_usb_get_track_tag(struct nomad_usb_data *njb, njbttaghdr_t * header) { --- 1002,1006 ---- * previously "Get Track Tag Header" request. */ ! track_t *njb_usb_get_track_tag(struct nomad_usb_data *njb, njbttaghdr_t * header) { *************** *** 1070,1073 **** --- 1041,1045 ---- if (status < 0) { err("get_track_tag: njb control error"); + kfree(data); return NULL; } *************** *** 1114,1118 **** * @return status */ ! static int njb_usb_get_disk_usage(struct nomad_usb_data *njb, u_int64_t * total, u_int64_t * free) --- 1086,1090 ---- * @return status */ ! int njb_usb_get_disk_usage(struct nomad_usb_data *njb, u_int64_t * total, u_int64_t * free) *************** *** 1160,1164 **** */ ! static int njb_usb_new_track_tag(struct nomad_usb_data *njb, void *tag, njbttaghdr_t * header) --- 1132,1136 ---- */ ! int njb_usb_new_track_tag(struct nomad_usb_data *njb, void *tag, njbttaghdr_t * header) *************** *** 1243,1247 **** * @return status */ ! static int njb_usb_replace_track_tag(struct nomad_usb_data *njb, void *tag, njbttaghdr_t * header) --- 1215,1219 ---- * @return status */ ! int njb_usb_replace_track_tag(struct nomad_usb_data *njb, void *tag, njbttaghdr_t * header) *************** *** 1310,1314 **** * @return a valid new track, or NULL if an error occured */ ! static track_t *njb_usb_update_track_tag(struct nomad_usb_data *njb, struct njbfs_fattr *fattr, u_int32_t * trackid) --- 1282,1286 ---- * @return a valid new track, or NULL if an error occured */ ! track_t *njb_usb_update_track_tag(struct nomad_usb_data *njb, struct njbfs_fattr *fattr, u_int32_t * trackid) *************** *** 1498,1502 **** * @return 0 if everything is ok or <0 if there was an error */ ! static int njb_usb_get_playlist_header(struct nomad_usb_data *njb, njbplhdr_t * header, int cmd) --- 1470,1474 ---- * @return 0 if everything is ok or <0 if there was an error */ ! int njb_usb_get_playlist_header(struct nomad_usb_data *njb, njbplhdr_t * header, int cmd) *************** *** 1547,1551 **** * */ ! static playlist_t *njb_usb_get_playlist(struct nomad_usb_data *njb, njbplhdr_t * header) { --- 1519,1523 ---- * */ ! playlist_t *njb_usb_get_playlist(struct nomad_usb_data *njb, njbplhdr_t * header) { |
From: Ben O. <ben...@us...> - 2002-02-24 00:20:21
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv889 Modified Files: cache.c Log Message: Ben: add njbfs_cache_add_node (used in the njbfs_create process) Also make cache_empty actually zero out the cache so another read will call back down into lookup() Index: cache.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/cache.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** cache.c 10 Feb 2002 21:59:23 -0000 1.4 --- cache.c 24 Feb 2002 00:17:14 -0000 1.5 *************** *** 27,34 **** #include <linux/types.h> #include <linux/init.h> - #include <linux/smp_lock.h> #include <linux/fs.h> #include <linux/usb.h> #include <linux/slab.h> #include <asm/system.h> #include <asm/uaccess.h> --- 27,34 ---- #include <linux/types.h> #include <linux/init.h> #include <linux/fs.h> #include <linux/usb.h> #include <linux/slab.h> + #include <linux/smp_lock.h> #include <asm/system.h> #include <asm/uaccess.h> *************** *** 113,116 **** --- 113,138 ---- } + int njbfs_cache_addnode(struct njbfs_sb_info *info, + char *dirname, struct njbfs_dirlist_node *n) + { + struct njbfs_hashlist_node *p; + + unsigned long hsh = njbfs_cache_hash(dirname); + + for(p = dir_cache.hash[hsh]; p; p = p->next) { + if ( strcmp(p->directory.name, dirname) == 0 ) + break; + } + + if ( !p ) + return -EINVAL; + + n->next = p->directory.head; + n->prev = NULL; + p->directory.head = n; + return 0; + } + + int njbfs_cache_add(struct njbfs_sb_info *info, char *name, struct njbfs_directory **dir) *************** *** 144,148 **** strcpy(p->directory.name, name); - info("cache_add: loading directory '%s'....", name); if ((res = njbfs_loaddir(info, name, &p->directory)) < 0) { err("cache_add: couldn't load directory"); --- 166,169 ---- *************** *** 200,203 **** --- 221,226 ---- njbfs_cache_deldir(p); } + dir_cache.len[i] = 0; + dir_cache.hash[i] = NULL; return 0; } |
From: Ben O. <ben...@us...> - 2002-02-24 00:20:01
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv1582 Modified Files: inode.c Log Message: Ben: use fattr->size instead of fattr->f_size, remove virtual_dir, clean-up the fattr cache Index: inode.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/inode.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** inode.c 10 Feb 2002 21:59:23 -0000 1.5 --- inode.c 24 Feb 2002 00:19:58 -0000 1.6 *************** *** 77,82 **** { struct inode *res; - res = new_inode(sb); if (!res) return NULL; --- 77,82 ---- { struct inode *res; res = new_inode(sb); + if (!res) return NULL; *************** *** 96,99 **** --- 96,100 ---- insert_inode_hash(res); + fattr->inode = res; return res; } *************** *** 112,116 **** inode->i_blksize = fattr->f_blksize; inode->i_blocks = fattr->f_blocks; ! inode->i_size = fattr->f_size; } --- 113,117 ---- inode->i_blksize = fattr->f_blksize; inode->i_blocks = fattr->f_blocks; ! inode->i_size = fattr->size; } *************** *** 177,183 **** info->njb = &nomad_instance; - info->virtual_mode = 0; - strcpy(info->virtual_dir, ""); - init_MUTEX(&info->sem); --- 178,181 ---- *************** *** 244,247 **** --- 242,246 ---- proc_njb_destroy(); #endif + njbfs_destroy_fattr_cache(); usb_nomad_cleanup(); |
From: Ben O. <ben...@us...> - 2002-02-24 00:19:03
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv1244 Modified Files: dir.c Log Message: Ben: changes to njbfs_get_attr calls intentionally disable proc_rename (wasn't working) add real support for njbfs_create Index: dir.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/dir.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dir.c 15 Feb 2002 20:03:04 -0000 1.4 --- dir.c 24 Feb 2002 00:19:00 -0000 1.5 *************** *** 22,25 **** --- 22,26 ---- */ + #include <linux/slab.h> #include <linux/module.h> #include <linux/kernel.h> *************** *** 35,38 **** --- 36,40 ---- #include "njbfs.h" #include "njbfs_proc.h" + #include "njbfs_dir.h" static int njbfs_lookup_validate(struct dentry *, int); *************** *** 216,227 **** struct njbfs_sb_info *info = (struct njbfs_sb_info *) sb->u.generic_sbp; ! struct njbfs_fattr fattr; struct inode *inode; ! int res; ! dbg("dname:%s", dentry->d_name.name); ! if ((res = njbfs_get_attr(dentry, &fattr, ! (struct njbfs_sb_info *) dir->i_sb->u. ! generic_sbp)) < 0) { inode = NULL; dentry->d_op = &njbfs_dentry_operations; --- 218,230 ---- struct njbfs_sb_info *info = (struct njbfs_sb_info *) sb->u.generic_sbp; ! struct njbfs_fattr *fattr; struct inode *inode; ! int res = 0; ! /* ben: I'm not sure where -ERESTARTSYS could be returned ! from, so this is kinda broken... */ ! ! fattr = njbfs_get_attr(dentry, info); ! if (!fattr) { inode = NULL; dentry->d_op = &njbfs_dentry_operations; *************** *** 235,241 **** return NULL; } - fattr.f_ino = iunique(dentry->d_sb, 2); - inode = njbfs_iget(dir->i_sb, &fattr); if (inode) { dentry->d_op = &njbfs_dentry_operations; --- 238,245 ---- return NULL; } + + fattr->f_ino = iunique(dentry->d_sb, 2); + inode = njbfs_iget(dir->i_sb, fattr); if (inode) { dentry->d_op = &njbfs_dentry_operations; *************** *** 250,263 **** struct njbfs_sb_info *info = (struct njbfs_sb_info *) dentry->d_sb->u.generic_sbp; ! struct njbfs_fattr fattr; struct inode *inode; ! ! if (njbfs_get_attr(dentry, &fattr, info) < 0) { info("njbfs_get_attr failed"); return -1; } ! fattr.f_ino = iunique(dentry->d_sb, 2); ! inode = njbfs_iget(dentry->d_sb, &fattr); if (!inode) return -EACCES; --- 254,268 ---- struct njbfs_sb_info *info = (struct njbfs_sb_info *) dentry->d_sb->u.generic_sbp; ! struct njbfs_fattr *fattr; struct inode *inode; ! ! fattr = njbfs_get_attr(dentry, info); ! if ( !fattr ) { info("njbfs_get_attr failed"); return -1; } ! fattr->f_ino = iunique(dentry->d_sb, 2); ! inode = njbfs_iget(dentry->d_sb, fattr); if (!inode) return -EACCES; *************** *** 275,278 **** --- 280,287 ---- int res; + /* ben: can't think of a great use for mkdir now. */ + info("sorry, no making of directories."); + return -EINVAL; + njbfs_get_name(dentry, buf); if ((res = njbfs_proc_mkdir(info, buf)) < 0) { *************** *** 286,302 **** static int njbfs_create(struct inode *dir, struct dentry *dentry, int mode) { struct njbfs_sb_info *info = (struct njbfs_sb_info *) dentry->d_sb->u.generic_sbp; ! char buf[NJBFS_MAXPATHLEN]; int res; ! njbfs_get_name(dentry, buf); ! if ((res = njbfs_proc_create(info, buf)) < 0) { err("create failed"); return res; } ! njbfs_cache_invalidate(dentry->d_parent); ! return njbfs_instantiate(dentry); } --- 295,348 ---- static int njbfs_create(struct inode *dir, struct dentry *dentry, int mode) { + struct inode *inode; + struct njbfs_fattr *fattr; + struct njbfs_dirlist_node *p; struct njbfs_sb_info *info = (struct njbfs_sb_info *) dentry->d_sb->u.generic_sbp; ! static char buf[NJBFS_MAXPATHLEN]; int res; ! strncpy(buf, dentry->d_name.name, dentry->d_name.len); ! buf[dentry->d_name.len] = '\0'; ! ! if ((res = njbfs_proc_create(info, buf, &fattr)) < 0) { err("create failed"); return res; } + SAFE_STRDUP(fattr->fname, buf); ! p = kmalloc(sizeof(struct njbfs_dirlist_node), GFP_KERNEL); ! if (!p ) { ! err("couldn't kmalloc dirlist_node"); ! return -ENOMEM; ! } ! ! /* give us a dirlist node with the exact requested filename */ ! res = njbfs_get_dirlist_node_from_fattr(p, ! fattr, LOADDIR_EXACTNAME); ! if ( res < 0 ) { ! err("couldn't create dirlist_node!"); ! return res; ! } ! ! /* get the directory name under which we are trying to ! create the file, and add the dirlist_node to ! this directories cache */ ! njbfs_get_dirname(dentry, buf); ! res = njbfs_cache_addnode(info, buf, p); ! if ( res < 0 ) { ! err("couldn't add the created file to the cache"); ! kfree(p); ! return res; ! } ! ! fattr->f_ino = iunique(dentry->d_sb, 2); ! inode = njbfs_iget(dentry->d_sb, fattr); ! if ( !inode ) { ! return -EINVAL; ! } ! ! d_instantiate(dentry, inode); ! return 0; } *************** *** 324,327 **** --- 370,381 ---- (struct njbfs_sb_info *) old_dentry->d_sb->u.generic_sbp; int res; + + /* + ben: this code is still mostly broken... + I don't know if I broke it or what. + I think it might never have worked right. + */ + info("njbfs: sorry, this feature is broken for now."); + return -EINVAL; if (new_dentry->d_inode) { |
From: Ben O. <ben...@us...> - 2002-02-24 00:15:51
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv758 Modified Files: automount.c Log Message: Ben: remove need for virtual directory Index: automount.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/automount.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** automount.c 10 Feb 2002 21:59:23 -0000 1.2 --- automount.c 24 Feb 2002 00:15:47 -0000 1.3 *************** *** 28,46 **** int main(int argc, char **argv) { - - char *virtualdirectory; /* "tracks", "playlists", "artists", "albums" */ - - if ((argc < 2) || - (strcmp("tracks", argv[1]) && - strcmp("playlists", argv[1]) && - strcmp("artists", argv[1]) && strcmp("albums", argv[1]))) { - - fprintf(stderr, - "Need virtual directory name here: 'tracks', 'playlists', 'albums' or 'artists'\n"); - exit(-1); - } - - virtualdirectory = argv[1]; - printf("-fstype=njbfs,dir=%s none\n", virtualdirectory); return 0; } --- 28,31 ---- |
From: Ben O. <ben...@us...> - 2002-02-24 00:15:16
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv554 Added Files: njbfs_dir.c njbfs_cache.c njbfs_dir.h proc.h Log Message: First add of files that support internal fattr cache and new, monolithic directory structure --- NEW FILE: njbfs_dir.c --- #include <linux/module.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/types.h> #include <linux/init.h> #include <linux/smp_lock.h> #include <linux/fs.h> #include <linux/usb.h> #include <linux/time.h> #include <linux/ctype.h> #include <asm/system.h> #include <asm/uaccess.h> #include <asm/errno.h> #include "njbfs.h" #include "njbfs_cache.h" #include "njbfs_dir.h" /* with an empty jukebox, we'll keep querying and querying. or maybe get an error. I'm not sure. This is also not the right place for this comment. But hey. */ #define CHECK_FATTR_CACHE(info) \ if ( !track_list_head ) { \ int status; \ status = init_fattr_cache(info); \ if ( status ) \ return status; \ } /** * Initialize root directory */ void njbfs_init_root_dirent(struct njbfs_sb_info *server, struct njbfs_fattr *fattr) { memset(fattr, 0, sizeof(*fattr)); fattr->f_nlink = 1; fattr->f_uid = server->mnt.uid; fattr->f_gid = server->mnt.gid; fattr->f_blksize = NJBFS_BLOCKSIZE; fattr->f_ino = 2; fattr->inode = NULL; fattr->f_mtime = CURRENT_TIME; fattr->f_mode = S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH | S_IFDIR | server->mnt.dir_mode; fattr->size = NJBFS_BLOCKSIZE; fattr->f_blocks = 0; } static void translate_bad_chars(char *ch) { while (*ch) { switch (*ch) { case '/': *ch = '_'; case '*': *ch = '_'; case '?': *ch = '_'; } ch++; } } int njbfs_get_dirlist_node_from_fattr(struct njbfs_dirlist_node *p, struct njbfs_fattr *fattr, int whereami) { char buf[NJBFS_MAXPATHLEN]; char *ch, *codec, *album, *artist, *title; /* do we use the exact file name? If we don't have enough info, yeah. */ if ((!fattr->artist) || (!fattr->title) || (!fattr->codec) || (!fattr->album)) { if (fattr->fname) { SAFE_STRDUP(p->entry.name, fattr->fname); } else { return -EINVAL; } } SAFE_STRDUP(album, fattr->album); SAFE_STRDUP(artist, fattr->artist); SAFE_STRDUP(codec, fattr->codec); SAFE_STRDUP(title, fattr->title); /* codec to lower case (MP3 ->mp3) */ ch = fattr->codec; while ((*ch = tolower(*ch)) != 0) ch++; translate_bad_chars(album); translate_bad_chars(artist); translate_bad_chars(title); /* set the filename conditionally, based on what directory we're in. */ switch(whereami) { case LOADDIR_AN_ALBUM: case LOADDIR_ARTIST_ALBUM: sprintf(buf, NJBFS_FILENAME_ALBUMDIR(artist, album, title, fattr->tracknum, codec)); break; case LOADDIR_AN_ALBUM_MULTIPLE: sprintf(buf, NJBFS_FILENAME_MULTIPLEALBUMDIR(artist, album, title, fattr->tracknum, codec)); break; case LOADDIR_TRACKS: sprintf(buf, NJBFS_FILENAME_TRACKSDIR(artist, album, title, fattr->tracknum, codec)); break; case LOADDIR_ARTIST_ALLTRACKS: sprintf(buf, NJBFS_FILENAME_ALLTRACKSDIR(artist, album, title, fattr->tracknum, codec)); break; case LOADDIR_A_GENRE: sprintf(buf, NJBFS_FILENAME_GENREDIR(artist, album, title, fattr->tracknum, codec)); break; case LOADDIR_EXACTNAME: sprintf(buf, fattr->fname); break; default: sprintf(buf, NJBFS_FILENAME_GENERIC(artist, album, title, fattr->tracknum, codec)); break; } SAFE_STRDUP(p->entry.name, buf); p->entry.fattr = fattr; /* attributes */ p->entry.size = fattr->size; p->entry.blocksize = NJBFS_BLOCKSIZE; p->entry.blocks = (p->entry.size + (NJBFS_BLOCKSIZE - 1)) >> (NJBFS_BLOCKSIZE_BITS - 1); p->entry.mode |= S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; p->entry.atime = CURRENT_TIME; return 0; } /* * Load the given fattr list into the directory */ int njbfs_load_fattr_list(struct njbfs_fattr_list *list, int whereami, struct njbfs_directory *dir) { int status; struct njbfs_dirlist_node *p; for ( ; list != NULL; list = list->next ) { p = (struct njbfs_dirlist_node *) kmalloc(sizeof(struct njbfs_dirlist_node), GFP_KERNEL); if (!p) { err("loaddir: kmalloc error"); return -ENOMEM; } memset(p, 0, sizeof(struct njbfs_dirlist_node)); status = njbfs_get_dirlist_node_from_fattr(p, list->fattr, whereami); if (status < 0) { err ("loaddir: unable to get dirlist node from fattr"); kfree(p); return -EIO; } p->prev = NULL; p->next = dir->head; dir->head = p; } return 0; } /* gets a dirlist node (and creates a fattr struct) for our virtual directories */ static void njbfs_dirlist_node_directories(struct njbfs_dirlist_node *p, struct njbfs_sb_info *info) { struct njbfs_fattr *f; f = kmalloc(sizeof(struct njbfs_fattr), GFP_KERNEL); if ( !f ) return; memset(f, 0, sizeof(struct njbfs_fattr)); f->f_mode = p->entry.mode = info->mnt.dir_mode | S_IFDIR; f->f_uid = info->mnt.uid; f->f_gid = info->mnt.gid; f->size = p->entry.size = NJBFS_BLOCKSIZE; f->f_atime = p->entry.atime = CURRENT_TIME; f->f_mtime = CURRENT_TIME; f->f_ctime = CURRENT_TIME; add_fattr_to_list(&virtual_list_head, f); p->entry.fattr = f; } int njbfs_load_rootdir(struct njbfs_sb_info *info, struct njbfs_directory *dir) { int i; struct njbfs_dirlist_node *p; for(i=0; i<4; i++) { p = (struct njbfs_dirlist_node *) kmalloc(sizeof(struct njbfs_dirlist_node), GFP_KERNEL); if (!p) { err("loaddir: kmalloc error"); return -ENOMEM; } memset(p, 0, sizeof(struct njbfs_dirlist_node)); switch ( i ) { case 0: SAFE_STRDUP(p->entry.name, "artists"); break; case 1: SAFE_STRDUP(p->entry.name, "albums"); break; case 2: SAFE_STRDUP(p->entry.name, "genres"); break; case 3: SAFE_STRDUP(p->entry.name, "tracks"); break; } njbfs_dirlist_node_directories(p, info); p->prev = NULL; p->next = dir->head; dir->head = p; } return 0; } /** * Get "track" directory entries from NJB */ int njbfs_load_trackdir(struct njbfs_sb_info *info, struct njbfs_directory *dir) { CHECK_FATTR_CACHE(info); return njbfs_load_fattr_list(track_list_head, LOADDIR_TRACKS, dir); } /** * Get "/albums" directory entries from NJB cache */ int njbfs_load_albumsdir(struct njbfs_sb_info *info, struct njbfs_directory *dir) { struct njbfs_dirlist_node *p; struct njbfs_album_list *list; CHECK_FATTR_CACHE(info); for ( list = album_list_head; list != NULL; list = list->next ) { p = (struct njbfs_dirlist_node *) kmalloc(sizeof(struct njbfs_dirlist_node), GFP_KERNEL); if (!p) { err("loaddir: kmalloc error"); return -ENOMEM; } memset(p, 0, sizeof(struct njbfs_dirlist_node)); SAFE_STRDUP(p->entry.name, list->album->name); njbfs_dirlist_node_directories(p,info); p->prev = NULL; p->next = dir->head; dir->head = p; } return 0; } /** * Get "/artists" directory entries from NJB cache */ int njbfs_load_artistsdir(struct njbfs_sb_info *info, struct njbfs_directory *dir) { struct njbfs_dirlist_node *p; struct njbfs_artist_list *list; CHECK_FATTR_CACHE(info); for ( list = artist_list_head; list != NULL; list = list->next ) { p = (struct njbfs_dirlist_node *) kmalloc(sizeof(struct njbfs_dirlist_node), GFP_KERNEL); if (!p) { err("loaddir: kmalloc error"); return -ENOMEM; } memset(p, 0, sizeof(struct njbfs_dirlist_node)); SAFE_STRDUP(p->entry.name, list->artist->name); njbfs_dirlist_node_directories(p, info); p->prev = NULL; p->next = dir->head; dir->head = p; } return 0; } /** * Get "/genres" directory entries from NJB cache */ int njbfs_load_genresdir(struct njbfs_sb_info *info, struct njbfs_directory *dir) { struct njbfs_dirlist_node *p; struct njbfs_genre_list *list; CHECK_FATTR_CACHE(info); for ( list = genre_list_head; list != NULL; list = list->next ) { p = (struct njbfs_dirlist_node *) kmalloc(sizeof(struct njbfs_dirlist_node), GFP_KERNEL); if (!p) { err("loaddir: kmalloc error"); return -ENOMEM; } memset(p, 0, sizeof(struct njbfs_dirlist_node)); SAFE_STRDUP(p->entry.name, list->genre->name); njbfs_dirlist_node_directories(p,info); p->prev = NULL; p->next = dir->head; dir->head = p; } return 0; } /** * Get "/genre/hamster music" directory entries from NJB */ int njbfs_load_a_genredir(struct njbfs_sb_info *info, struct njbfs_directory *dir, char *genre) { struct njbfs_genre *g; CHECK_FATTR_CACHE(info); g = njbfs_get_genre(genre); if (! g) { err("failed to find genre in hash tables!"); return -EINVAL; } return njbfs_load_fattr_list(g->tracks, LOADDIR_A_GENRE, dir); } /** * Get "/artists/Tom Waits" directory entries from NJB cache */ int njbfs_load_an_artistdir(struct njbfs_sb_info *info, struct njbfs_directory *dir, char *artistname) { struct njbfs_dirlist_node *p; struct njbfs_artist *artist; struct njbfs_album_list *list; CHECK_FATTR_CACHE(info); artist = njbfs_get_artist(artistname); if ( ! artist ) return -EINVAL; for ( list = artist->albums; list != NULL; list = list->next ) { p = (struct njbfs_dirlist_node *) kmalloc(sizeof(struct njbfs_dirlist_node), GFP_KERNEL); if (!p) { err("loaddir: kmalloc error"); return -ENOMEM; } memset(p, 0, sizeof(struct njbfs_dirlist_node)); SAFE_STRDUP(p->entry.name,list->album->name); njbfs_dirlist_node_directories(p, info); p->prev = NULL; p->next = dir->head; dir->head = p; } /* add the "__all__" (all tracks) dir */ p = (struct njbfs_dirlist_node *) kmalloc(sizeof(struct njbfs_dirlist_node), GFP_KERNEL); if (!p) { err("loaddir: kmalloc error"); return -ENOMEM; } memset(p, 0, sizeof(struct njbfs_dirlist_node)); SAFE_STRDUP(p->entry.name, NJBFS_ALLTRACKS_DIR); njbfs_dirlist_node_directories(p, info); p->prev = NULL; p->next = dir->head; dir->head = p; return 0; } /** * Get "/artist/Tom Waits/Rain Dogs" directory entries from NJB */ int njbfs_load_artist_alltracks(struct njbfs_sb_info *info, struct njbfs_directory *dir, char *artist) { struct njbfs_artist *a; CHECK_FATTR_CACHE(info); a = njbfs_get_artist(artist); if (! artist) { err("failed to find artist in hash tables!"); return -EINVAL; } return njbfs_load_fattr_list(a->tracks, LOADDIR_ARTIST_ALLTRACKS, dir); } /** * Get "/artist/Tom Waits/Rain Dogs" directory entries from NJB */ int njbfs_load_artist_albumdir(struct njbfs_sb_info *info, struct njbfs_directory *dir, char *album, char *artist) { struct njbfs_album *a; CHECK_FATTR_CACHE(info); a = njbfs_get_album(album, artist); if (! album) { err("failed to find album in hash tables!"); return -EINVAL; } return njbfs_load_fattr_list(a->tracks, LOADDIR_ARTIST_ALBUM, dir); } /** * Get "/albums/Rain Dogs" directory entries from NJB */ int njbfs_load_an_albumdir(struct njbfs_sb_info *info, struct njbfs_directory *dir, char *title) { struct njbfs_album_list *list, *tmp; int status = 0, count = 0, whereami; CHECK_FATTR_CACHE(info); list = njbfs_get_albums(title); if (! list) { err("failed to find album in hash tables!"); return -EINVAL; } /* count the number of albums so we know if we're dealing with multiple albums or not. (and change whereami accordingly) */ tmp = list; while (list) { count++; list = list->next; } if (count > 1) whereami = LOADDIR_AN_ALBUM_MULTIPLE; else whereami = LOADDIR_AN_ALBUM; list = tmp; while (list) { status = njbfs_load_fattr_list(list->album->tracks, whereami, dir); if ( status ) break; list = list->next; } list = tmp; while (list) { tmp = list; list = list->next; kfree(tmp); } return status; } /* parses up a full pathname, returns an integer indicating the type of directory, and info is filled with malloc'ed information. */ int __loaddir_whereami(char *name, char **info, char **info2) { char *work, *p; char *ar = NULL, *al = NULL, *gn = NULL; *info = NULL; if ( strcmp(name, "/") == 0 ) return LOADDIR_ROOT; else if ( strcmp(name, "/artists") == 0 ) return LOADDIR_ARTISTS; else if ( strcmp(name, "/albums") == 0 ) return LOADDIR_ALBUMS; else if ( strcmp(name, "/tracks") == 0 ) return LOADDIR_TRACKS; else if ( strcmp(name, "/genres") == 0 ) return LOADDIR_GENRES; else { SAFE_STRDUP_ZERO(work, name); if ( strncmp(name, "/artists", 8) == 0) { p = strtok(work, "/"); ar = strtok(NULL, "/"); al = strtok(NULL, "/"); if ( al ) { if ( strcmp(al, NJBFS_ALLTRACKS_DIR) == 0 ) { SAFE_STRDUP_ZERO(*info, ar); kfree(work); return LOADDIR_ARTIST_ALLTRACKS; } SAFE_STRDUP_ZERO(*info, al); SAFE_STRDUP_ZERO(*info2, ar); kfree(work); return LOADDIR_ARTIST_ALBUM; } else if ( ar ) { SAFE_STRDUP_ZERO(*info, ar); kfree(work); return LOADDIR_AN_ARTIST; } else { kfree(work); return 0; } } else if ( strncmp(name, "/albums", 7) == 0) { p = strtok(work, "/"); al = strtok(NULL, "/"); if ( al ) { SAFE_STRDUP_ZERO(*info, al); kfree(work); return LOADDIR_AN_ALBUM; } else { kfree(work); return 0; } } else if ( strncmp (name, "/genres", 7) == 0) { p = strtok(work, "/"); gn = strtok(NULL, "/"); if ( gn ) { SAFE_STRDUP_ZERO(*info, gn); kfree(work); return LOADDIR_A_GENRE; } else { kfree(work); return 0; } } } return 0; } /* here's the main entry point from cache_add. figures out where we are in the njbfs heirarchy and calls the appropriate function. */ int njbfs_loaddir(struct njbfs_sb_info *info, char *name, struct njbfs_directory *dir) { char *xinfo, *yinfo; int ret; int status = __loaddir_whereami(name, &xinfo, &yinfo); switch(status) { case LOADDIR_ROOT: return njbfs_load_rootdir(info, dir); case LOADDIR_ARTISTS: return njbfs_load_artistsdir(info,dir); case LOADDIR_ALBUMS: return njbfs_load_albumsdir(info,dir); case LOADDIR_GENRES: return njbfs_load_genresdir(info,dir); case LOADDIR_TRACKS: return njbfs_load_trackdir(info,dir); case LOADDIR_AN_ARTIST: ret = njbfs_load_an_artistdir(info, dir, xinfo); kfree(xinfo); return(ret); case LOADDIR_ARTIST_ALLTRACKS: ret = njbfs_load_artist_alltracks(info, dir,xinfo); kfree(xinfo); return ret; case LOADDIR_AN_ALBUM: ret = njbfs_load_an_albumdir(info, dir, xinfo); kfree(xinfo); return(ret); case LOADDIR_ARTIST_ALBUM: ret = njbfs_load_artist_albumdir(info, dir, xinfo, yinfo); kfree(xinfo); kfree(yinfo); return(ret); case LOADDIR_A_GENRE: ret = njbfs_load_a_genredir(info, dir, xinfo); kfree(xinfo); return(ret); default: return(-1); } } --- NEW FILE: njbfs_cache.c --- /* * Nomad Jukebox filesystem for Linux. * * Copyright (C) 2001 Jörg Prante <joe...@gm...> * Copyright (C) 2002 Ben Osheroff <be...@gi...> * * based on ftpfs by Florin Malita <fm...@ya...> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /** * Processing the directives from the VFS and delegate them to the * NJB USB subsystem */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/types.h> #include <linux/init.h> #include <linux/smp_lock.h> #include <linux/fs.h> #include <linux/usb.h> #include <linux/time.h> #include <linux/ctype.h> #include <asm/system.h> #include <asm/uaccess.h> #include <asm/errno.h> #include "njbfs.h" #include "track.h" #include "proc.h" #include "njbfs_cache.h" /* linked lists that we use as our primary cache mechanism. */ struct njbfs_fattr_list *track_list_head = NULL; struct njbfs_album_list *album_list_head = NULL; struct njbfs_artist_list *artist_list_head = NULL; struct njbfs_genre_list *genre_list_head = NULL; /* here is a listing of "virtual" fattr structures... ie they are only directories in our fs, not actual tracks. */ struct njbfs_fattr_list *virtual_list_head = NULL; /* forward decl */ static struct njbfs_fattr *get_fattr_from_track(struct njbfs_sb_info *info, track_t * track); /* BEGIN HASHTABLE FUNCTIONS. Unfortuneately, the hashing functions in cache.c are not quite generic enough (too directory-specific) for our purposes here. */ njbfs_hash_element **artist_hash = NULL; njbfs_hash_element **album_hash = NULL; njbfs_hash_element **genre_hash = NULL; unsigned long njbfs_generic_hash(char *name) { unsigned long hash = 0; int i; for (i = 0; i < strlen(name); i++) hash += name[i]; return hash % NJBFS_GENERIC_HASH_SIZE; } static int njbfs_init_hashtables() { int size = sizeof(njbfs_hash_element *) * NJBFS_GENERIC_HASH_SIZE; artist_hash = kmalloc(size, GFP_KERNEL); album_hash = kmalloc(size, GFP_KERNEL); genre_hash = kmalloc(size, GFP_KERNEL); if ( !artist_hash || !album_hash || !genre_hash ) return -ENOMEM; memset(artist_hash, 0, size); memset(album_hash, 0, size); memset(genre_hash, 0, size); return 0; } static void __njbfs_destroy_hashtable(njbfs_hash_element **table) { njbfs_hash_element *el, *last; int i; if ( !table) return; for (i = 0; i < NJBFS_GENERIC_HASH_SIZE; i++) { el = table[i]; while (el) { last = el; el = el->next; kfree(last); } } kfree(table); } void njbfs_destroy_hashtables() { __njbfs_destroy_hashtable(artist_hash); __njbfs_destroy_hashtable(album_hash); __njbfs_destroy_hashtable(genre_hash); artist_hash = album_hash = genre_hash = NULL; } /* this assumes you've already determined that the element isn't in the hash table. ie will add duplicates if you're not careful. */ static int njbfs_add_hash_generic(njbfs_hash_element **table, char *id, void *data) { njbfs_hash_element *element; unsigned long hash; if ( !table ) return -1; hash = njbfs_generic_hash(id); element = NULL; element = kmalloc(sizeof (njbfs_hash_element), GFP_KERNEL); if ( !element ) { err("couldn't kmalloc hash_element"); return -ENOMEM; } element->next = table[hash]; element->data = data; element->id = id; table[hash] = element; return 0; } static void* njbfs_get_hash_generic(njbfs_hash_element **table, char *id) { njbfs_hash_element *walk; unsigned long hash; if ( !table ) return NULL; hash = njbfs_generic_hash(id); if ( ! table[hash] ) { return NULL; } else { walk = table[hash]; for(walk = table[hash]; walk != NULL; walk = walk->next) { if ( strcmp(walk->id, id) == 0) return walk->data; } } return NULL; } struct njbfs_artist *njbfs_get_artist(char *name) { return njbfs_get_hash_generic(artist_hash, name); } /* albums are the one item in our world not guaranteed to be unique.... we don't want to allocate "__unknown__" to just one artist. so we have to use a special hash function that guarantees uniquity. */ struct njbfs_album *njbfs_get_album(char *name, char *artist) { struct njbfs_album *a; njbfs_hash_element **table = album_hash; njbfs_hash_element *walk; unsigned long hash; if ( !table ) return NULL; hash = njbfs_generic_hash(name); if ( ! table[hash] ) return NULL; walk = table[hash]; for(walk = table[hash]; walk != NULL; walk = walk->next) { if ( strcmp(walk->id, name) == 0) { a = walk->data; if ( a->artist && !strcmp(a->artist->name, artist) ) return walk->data; } } return NULL; } /* this returns a (kmalloc'ed) album list of all albums matching the specified name. Please free when done. Used when listing /albums/<unknown> or another non-unique album name. */ struct njbfs_album_list *njbfs_get_albums(char *name) { struct njbfs_album_list *a = NULL, *b; njbfs_hash_element **table = album_hash; njbfs_hash_element *walk; unsigned long hash; if ( !table ) return NULL; hash = njbfs_generic_hash(name); if ( ! table[hash] ) return NULL; walk = table[hash]; for(walk = table[hash]; walk != NULL; walk = walk->next) { if ( strcmp(walk->id, name) == 0) { b = kmalloc(sizeof(struct njbfs_album_list), GFP_KERNEL); if ( !b ) return NULL; b->album = walk->data; b->next = a; a = b; } } return a; } struct njbfs_genre *njbfs_get_genre(char *name) { return njbfs_get_hash_generic(genre_hash, name); } struct njbfs_artist *njbfs_add_artist(char *name) { struct njbfs_artist_list *artist_list; struct njbfs_artist *artist; artist_list = kmalloc(sizeof(struct njbfs_artist_list), GFP_KERNEL); if ( !artist_list ) { err("couldn't kmalloc njbfs_artist"); return NULL; } artist = kmalloc(sizeof(struct njbfs_artist), GFP_KERNEL); if ( !artist ) { err("couldn't kmalloc njbfs_artist"); return NULL; } /* init the artist structure */ artist->name = name; artist->albums = NULL; artist->tracks = NULL; artist_list->artist = artist; /* add to the big linked list */ artist_list->next = artist_list_head; artist_list_head = artist_list; /* add to the hash table */ if ( njbfs_add_hash_generic(artist_hash, name, artist) ) return NULL; return artist; } struct njbfs_album *njbfs_add_album(char *name, struct njbfs_artist *artist) { struct njbfs_album_list *album_list; struct njbfs_album *album; album_list = kmalloc(sizeof(struct njbfs_album_list), GFP_KERNEL); if ( !album_list ) { err("couldn't kmalloc njbfs_album"); return NULL; } album = kmalloc(sizeof(struct njbfs_album), GFP_KERNEL); if ( !album ) { err("couldn't kmalloc njbfs_album"); return NULL; } /* init the album structure */ album->name = name; album->artist = artist; album->tracks = NULL; /* add to the big linked list */ album_list->album = album; album_list->next = album_list_head; album_list_head = album_list; /* add to the artist's albums. we re-use album_list here. I realized I probably could've stolen all this from libnjb. Damn. */ album_list = kmalloc(sizeof(struct njbfs_album_list), GFP_KERNEL); if ( !album_list ) { err("couldn't kmalloc njbfs_album"); return NULL; } album_list->album = album; if ( !artist->albums ) { album_list->next = NULL; artist->albums = album_list; } else { album_list->next = artist->albums; artist->albums = album_list; } /* add to the hash table */ if ( njbfs_add_hash_generic(album_hash, name, album) ) return NULL; return album; } struct njbfs_genre *njbfs_add_genre(char *name) { struct njbfs_genre_list *genre_list; struct njbfs_genre *genre; genre_list = kmalloc(sizeof(struct njbfs_genre_list), GFP_KERNEL); if ( !genre_list ) { err("Couldn't kmalloc genre_list"); return NULL; } genre = kmalloc(sizeof(struct njbfs_genre), GFP_KERNEL); if ( !genre ) { err("Couldn't kmalloc genre"); return NULL; } genre->name = name; genre->tracks = NULL; genre_list->genre = genre; genre_list->next = genre_list_head; genre_list_head = genre_list; /* add to the hash table */ if ( njbfs_add_hash_generic(genre_hash, name, genre) ) return NULL; return genre; } struct njbfs_fattr_list* add_fattr_to_list(struct njbfs_fattr_list **list, struct njbfs_fattr *fattr) { struct njbfs_fattr_list * list_element = kmalloc(sizeof(struct njbfs_fattr_list), GFP_KERNEL); if ( ! list_element ){ err("couldn't kmalloc njbfs_fattr_list"); return NULL; } list_element->next = *list; list_element->fattr = fattr; *list = list_element; return (list_element); } /* Add a particular fattr structure to all of our cache structures (lists, hashtables) This is the main entry point for adding a track into the cache. */ int njbfs_add_fattr(struct njbfs_fattr *fattr) { struct njbfs_fattr_list *list; struct njbfs_artist *njbfs_artist; struct njbfs_album *njbfs_album; struct njbfs_genre *njbfs_genre; list = kmalloc(sizeof(struct njbfs_fattr_list), GFP_KERNEL); if ( !list ) { err("Couldn't kmalloc fattr_lists"); return -ENOMEM; } /* try to get the associated artist */ njbfs_artist = njbfs_get_artist(fattr->artist); if ( !njbfs_artist ) { njbfs_artist = njbfs_add_artist(fattr->artist); if ( !njbfs_artist ) return -ENOMEM; } /* now try to find the album it belongs to. */ njbfs_album = njbfs_get_album(fattr->album, fattr->artist); if ( !njbfs_album) { njbfs_album = njbfs_add_album(fattr->album, njbfs_artist); if ( !njbfs_album ) return -ENOMEM; } /* and the genre, do be do be do */ njbfs_genre = njbfs_get_genre(fattr->genre); if ( !njbfs_genre ) { njbfs_genre = njbfs_add_genre(fattr->genre); if ( !njbfs_album ) return -ENOMEM; } if ( !add_fattr_to_list(&njbfs_album->tracks, fattr) ) return -ENOMEM; if ( !add_fattr_to_list(&njbfs_artist->tracks, fattr) ) return -ENOMEM; if ( !add_fattr_to_list(&njbfs_genre->tracks, fattr) ) return -ENOMEM; if ( !add_fattr_to_list(&track_list_head, fattr) ) return -ENOMEM; return 0; } /* remove a fattr pointer from a single linked list */ void njbfs_remove_fattr_from_list(struct njbfs_fattr_list **list, struct njbfs_fattr *fattr) { struct njbfs_fattr_list *last, *cur; if (!list || !*list) return; if ( (*list)->fattr == fattr ) { *list = (*list)->next; return; } else { last = *list; cur = (*list)->next; while ( cur ) { if (cur->fattr == fattr) { last->next = cur->next; return; } last = cur; cur = cur->next; } } } void njbfs_remove_fattr(struct njbfs_fattr *fattr) { struct njbfs_artist *njbfs_artist; struct njbfs_album *njbfs_album; struct njbfs_genre *njbfs_genre; /* try to get the associated artist */ njbfs_artist = njbfs_get_hash_generic(artist_hash, fattr->artist); if ( njbfs_artist ) njbfs_remove_fattr_from_list(&njbfs_artist->tracks, fattr); /* now try to find the album it belongs to. */ njbfs_album = njbfs_get_hash_generic(album_hash, fattr->album); if ( njbfs_album) njbfs_remove_fattr_from_list(&njbfs_album->tracks, fattr); /* and the genre, do be do be do */ njbfs_genre = njbfs_get_hash_generic(genre_hash, fattr->genre); if ( njbfs_genre ) njbfs_remove_fattr_from_list(&njbfs_genre->tracks, fattr); njbfs_remove_fattr_from_list(&track_list_head, fattr); return; } void njbfs_destroy_fattr_cache() { struct njbfs_fattr *fattr; struct njbfs_fattr_list *fattr_list; struct njbfs_artist *artist; struct njbfs_artist_list *artist_list; struct njbfs_album_list *album_list; struct njbfs_album *album; struct njbfs_genre_list *genre_list; struct njbfs_genre *genre; void *last; /* first free all the file attribute structures and the tracks linked list */ fattr_list = track_list_head; while(fattr_list) { fattr = fattr_list->fattr; kfree(fattr->fname); kfree(fattr->codec); kfree(fattr->title); kfree(fattr->artist); kfree(fattr->album); kfree(fattr->genre); track_destroy(fattr->track); last = fattr_list; fattr_list = fattr_list->next; kfree(last); } track_list_head = NULL; /* now destroy the virtual directories linked list */ fattr_list = virtual_list_head; while(fattr_list) { fattr = fattr_list->fattr; kfree(fattr->fname); last = fattr_list; fattr_list = fattr_list->next; kfree(last); } virtual_list_head = NULL; /* now the artist list */ artist_list = artist_list_head; while(artist_list) { artist = artist_list->artist; /* strip away the "shells" */ album_list = artist->albums; while (album_list) { last = album_list; album_list = album_list->next; kfree(last); } fattr_list = artist->tracks; while ( fattr_list ) { last = fattr_list; fattr_list = fattr_list->next; kfree(last); } kfree(artist); last = artist_list; artist_list = artist_list->next; kfree(last); } artist_list_head = NULL; /* and the albums */ album_list = album_list_head; while(album_list) { album = album_list->album; fattr_list = album->tracks; while ( fattr_list ) { last = fattr_list; fattr_list = fattr_list->next; kfree(last); } kfree(album); last = album_list; album_list = album_list->next; kfree(last); } album_list_head = NULL; /* and the genres */ genre_list = genre_list_head; while(genre_list) { genre = genre_list->genre; fattr_list = genre->tracks; while ( fattr_list ) { last = fattr_list; fattr_list = fattr_list->next; kfree(last); } kfree(genre); last = genre_list; genre_list = genre_list->next; kfree(last); } album_list_head = NULL; /* now the hashtables */ njbfs_destroy_hashtables(); } int init_fattr_cache(struct njbfs_sb_info *info) { struct nomad_usb_data *njb = info->njb; struct njbfs_fattr *fattr; njbttaghdr_t header; track_t *track; int status; /* sanity check: have we been through this already? */ if ( track_list_head ) return 0; if ( njbfs_init_hashtables() ) { err("couldn't initialize hashtables!"); return -ENOMEM; } /* capture njb */ status = njb_usb_capture(njb); if (status < 0) { err("loaddir: capture failed, status=%d", status); return -EIO; } status = njb_usb_get_first_track_tag_header(njb, &header); while (status != -ENOENT) { track = njb_usb_get_track_tag(njb, &header); if (track == NULL) break; fattr = get_fattr_from_track(info, track); if ( !fattr ) { err("Bad track: Nomad track_id %d", track->header.trackid); status = njb_usb_release(njb); return -EIO; } status = njbfs_add_fattr(fattr); if ( status ) break; status = njb_usb_get_next_track_tag_header(njb, &header); } /* release njb */ status = njb_usb_release(njb); if (status < 0) { err("loaddir: release failed, status=%d", status); return -EIO; } return 0; } /** * Get a fattr struct from a track structure */ static struct njbfs_fattr *get_fattr_from_track(struct njbfs_sb_info *info, track_t * track) { struct njbfs_fattr *fattr; track_frame_t *frame; char *ch; fattr = kmalloc(sizeof (struct njbfs_fattr), GFP_KERNEL); if ( !fattr ) { err("Couldn't kmalloc fattr struct!"); return NULL; } memset(fattr, 0, sizeof(struct njbfs_fattr)); track->cur = track->first; frame = track->cur; while (frame != NULL) { if (!strcmp(FR_ARTIST, frame->label)) { SAFE_STRDUP_NULL(fattr->artist, (char *) frame->data); } else if (!strcmp(FR_FNAME, frame->label)) { SAFE_STRDUP_NULL(fattr->fname, (char *) frame->data); } else if (!strcmp(FR_TITLE, frame->label)) { SAFE_STRDUP_NULL(fattr->title, (char *) frame->data); } else if (!strcmp(FR_CODEC, frame->label)) { SAFE_STRDUP_NULL(fattr->codec, (char *) frame->data); } else if (!strcmp(FR_ALBUM, frame->label)) { SAFE_STRDUP_NULL(fattr->album, (char *) frame->data); } else if (!strcmp(FR_GENRE, frame->label)) { SAFE_STRDUP_NULL(fattr->genre, (char *) frame->data); } else if (!strcmp(FR_SIZE, frame->label)) { fattr->size = get_track_size(frame); } else if (!strcmp(FR_TRACK, frame->label)) { memcpy(&fattr->tracknum, frame->data, 4); } frame = track_getframe(track); } /* codec to lower case (MP3 ->mp3) */ ch = fattr->codec; while ((*ch = tolower(*ch)) != 0) ch++; fattr->f_ino = 0; fattr->inode = NULL; fattr->f_mode = info->mnt.file_mode; fattr->f_uid = info->mnt.uid; fattr->f_gid = info->mnt.gid; fattr->f_atime = fattr->f_mtime = CURRENT_TIME; fattr->f_blksize = NJBFS_BLOCKSIZE; fattr->f_blocks = (fattr->size + (NJBFS_BLOCKSIZE - 1)) >> (NJBFS_BLOCKSIZE_BITS - 1); fattr->fileid = track->header.trackid; fattr->track = track; return fattr; } --- NEW FILE: njbfs_dir.h --- #ifndef _NJBFS_DIR_H #define _NJBFS_DIR_H int njbfs_get_dirlist_node_from_fattr(struct njbfs_dirlist_node *p, struct njbfs_fattr *fattr, int whereami); /* oh, yes, these could be an enum. Used when we're loading up a directory. */ #define LOADDIR_ROOT 1 #define LOADDIR_ARTISTS 2 #define LOADDIR_ALBUMS 3 #define LOADDIR_AN_ARTIST 4 #define LOADDIR_AN_ALBUM 5 #define LOADDIR_ARTIST_ALLTRACKS 6 #define LOADDIR_GENRES 7 #define LOADDIR_A_GENRE 8 #define LOADDIR_TRACKS 9 #define LOADDIR_EXACTNAME 10 /* used when "create" needs a temp dirlist node */ #define LOADDIR_AN_ALBUM_MULTIPLE 11 /* used when an album name is non-unique */ #define LOADDIR_ARTIST_ALBUM 12 /* for /artist/album/foo */ #endif --- NEW FILE: proc.h --- #ifndef _NJB_PROC_H_ #define _NJB_PROC_H_ #include "nomad_usb.h" extern int njb_usb_connect(struct nomad_usb_data *nomad); extern int njb_usb_disconnect(struct nomad_usb_data *nomad); extern int njb_usb_open(struct nomad_usb_data *nomad, struct njbfs_fattr *fattr); extern int njb_usb_close(struct nomad_usb_data *nomad, struct njbfs_fattr *fattr); extern int njb_usb_write(struct nomad_usb_data *nomad, char *name, u_int32_t offset, u_int32_t count, void *buffer); extern int njb_usb_read(struct nomad_usb_data *nomad, char *name, u_int32_t offset, u_int32_t count, void *buffer); extern int njb_usb_rename(struct nomad_usb_data *nomad, struct njbfs_fattr *fattr); extern int njb_usb_delete(struct nomad_usb_data *nomad, char *file); extern int njb_usb_create(struct nomad_usb_data *nomad, char *file); extern int njb_usb_check(struct nomad_usb_data *njb); extern int njb_usb_capture(struct nomad_usb_data *njb); extern int njb_usb_handshake(struct nomad_usb_data *njb); extern int njb_usb_release(struct nomad_usb_data *njb); extern int njb_usb_control(struct nomad_usb_data *njb, unsigned int pipe, int request, int requesttype, int value, int index, void *data, int size, int retries); extern int njb_usb_verify_last_command(struct nomad_usb_data *njb); extern int njb_usb_update_library_counter(struct nomad_usb_data *njb); extern track_t *njb_usb_update_track_tag(struct nomad_usb_data *njb, struct njbfs_fattr *fattr, u_int32_t * trackid); extern int njb_usb_get_disk_usage(struct nomad_usb_data *njb, u_int64_t * total, u_int64_t * free); #define UNKNOWN_STRING "__unknown__" #endif |
From: Ben O. <ben...@us...> - 2002-02-24 00:14:06
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv387 Modified Files: INSTALL Log Message: Ben: change install notes to reflect single directory structure Index: INSTALL =================================================================== RCS file: /cvsroot/njbfs/njbfs/INSTALL,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** INSTALL 23 Dec 2001 05:59:08 -0000 1.3 --- INSTALL 24 Feb 2002 00:14:04 -0000 1.4 *************** *** 28,52 **** automountable '/mnt/njbfs' directory. ! If you're not up to playing with the automounter (you really should :), here are the mount commands to mount your NJB. ! ! mount -t njbfs -o dir=tracks none /mnt/njbfs/tracks ! mount -t njbfs -o dir=playlists none /mnt/njbfs/playlists ! mount -t njbfs -o dir=albums none /mnt/njbfs/albums ! mount -t njbfs -o dir=artists none /mnt/njbfs/artists ! And for those who do not like typing those long commands, put these in your /etc/fstab ! none /mnt/njbfs/tracks njbfs dir=tracks 0 0 ! none /mnt/njbfs/playlists njbfs dir=playlists 0 0 ! none /mnt/njbfs/albums njbfs dir=albums 0 0 ! none /mnt/njbfs/artists njbfs dir=artists 0 0 ! [Note: Most Linux distros will try to mount all entries in /etc/fstab on boot. You may or may not like the results.] If you have 'usbmgr' running, I recommend automatic installation of 'njbfs' ! when you plug the device into the computer. Edit '/etc/usbmgr/usbmgr.conf' as root ! and add # Nomad Jukebox [Creative] --- 28,48 ---- automountable '/mnt/njbfs' directory. ! If you're not up to playing with the automounter ! (you really should :), here are the mount commands to mount your NJB. ! mount -t njbfs none /mnt/njbfs ! And for those who do not like typing those long commands, ! put this in your /etc/fstab: + none /mnt/njbfs njbfs defaults 0 0 ! [Note: Most Linux distros will try to mount all entries in ! /etc/fstab on boot. You may or may not like the results.] If you have 'usbmgr' running, I recommend automatic installation of 'njbfs' ! when you plug the device into the computer. ! Edit '/etc/usbmgr/usbmgr.conf' as root and add: # Nomad Jukebox [Creative] *************** *** 60,64 **** ============== ! umount /mnt/njbfs/tracks as root should unmount the njbfs, and --- 56,60 ---- ============== ! umount /mnt/njbfs as root should unmount the njbfs, and |
From: Ben O. <ben...@us...> - 2002-02-19 06:32:59
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv25421 Modified Files: Tag: ben proc.c Log Message: ben: -change njb_set_inode .. to njb_set_pos and use it for the current resting point, not the last resting point -enable large read-aheads, which gets us up to .45Mb/s in some cases. -different locking (read_lock) in id3_writetag Index: proc.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/proc.c,v retrieving revision 1.6.2.1 retrieving revision 1.6.2.2 diff -C2 -d -r1.6.2.1 -r1.6.2.2 *** proc.c 15 Feb 2002 20:07:32 -0000 1.6.2.1 --- proc.c 19 Feb 2002 06:32:56 -0000 1.6.2.2 *************** *** 70,74 **** extern int njb_usb_write(struct nomad_usb_data *njb, char *name, u_int32_t offset, u_int32_t count, void *buffer); ! extern int njb_usb_read(struct nomad_usb_data *njb, char *name, u_int32_t offset, u_int32_t count, void *buffer); extern int njb_usb_rename(struct nomad_usb_data *njb, --- 70,74 ---- extern int njb_usb_write(struct nomad_usb_data *njb, char *name, u_int32_t offset, u_int32_t count, void *buffer); ! extern int njb_usb_read(struct nomad_usb_data *njb, u_int32_t offset, u_int32_t count, void *buffer); extern int njb_usb_rename(struct nomad_usb_data *njb, *************** *** 127,136 **** } ! void njb_inode_set_lastread(struct inode *i, u_int32_t offset) { i->u.ext2_i.i_faddr = offset; } ! u_int32_t njb_inode_get_lastread(struct inode *i) { return i->u.ext2_i.i_faddr; --- 127,136 ---- } ! void njb_set_pos(struct inode *i, u_int32_t offset) { i->u.ext2_i.i_faddr = offset; } ! u_int32_t njb_get_pos(struct inode *i) { return i->u.ext2_i.i_faddr; *************** *** 478,481 **** --- 478,500 ---- } + int njbfs_read_lock(struct inode *i) + { + struct njbfs_sb_info *info = i->i_sb->u.generic_sbp; + if ( njb_interruption_inode == 0 || + njb_interruption_inode != i->i_ino ) { + return njbfs_lock(info); + } + return 0; + } + + void njbfs_read_unlock(struct inode *i) + { + struct njbfs_sb_info *info = i->i_sb->u.generic_sbp; + if ( njb_interruption_inode == 0 || + njb_interruption_inode != i->i_ino ) { + njbfs_unlock(info); + } + } + static int _njbfs_get_attr(struct dentry *dentry, *************** *** 644,648 **** njb_inode_mark_closed(inode); ! njb_inode_set_lastread(inode, 0); /* don't open yet.. --- 663,667 ---- njb_inode_mark_closed(inode); ! njb_set_pos(inode, 0); /* don't open yet.. *************** *** 689,693 **** info->njb->current_dentry = NULL; njb_inode_mark_closed(inode); ! njb_inode_set_lastread(inode, 0); njbfs_unlock(info); return status; --- 708,712 ---- info->njb->current_dentry = NULL; njb_inode_mark_closed(inode); ! njb_set_pos(inode, 0); njbfs_unlock(info); return status; *************** *** 737,741 **** int i; ! njbfs_get_attr(dentry, &fattr, info, 0); memset(buffer, 0, NJBFS_BLOCKSIZE); --- 756,762 ---- int i; ! njbfs_read_lock(dentry->d_inode); ! njbfs_get_attr_nolock(dentry, &fattr, info, 0); ! njbfs_read_unlock(dentry->d_inode); memset(buffer, 0, NJBFS_BLOCKSIZE); *************** *** 795,798 **** --- 816,856 ---- /* + a simple read routine that throws away its data. + */ + + /* taken from the libnjb project */ + #define MAX_READ 0x0000FE00 + + static int __njbfs_push(struct inode *i, u_int32_t offset, u_int32_t count) + { + struct njbfs_sb_info *info = + (struct njbfs_sb_info *) i->i_sb->u.generic_sbp; + + u_int32_t bytes = 0; + u_int32_t thisread; + + char *buf; + + while ( offset < NJBFS_ID3SIZE ) { + offset += NJBFS_BLOCKSIZE; + count -= NJBFS_BLOCKSIZE; + } + + while ( count > 0 ) { + thisread = count < MAX_READ ? count : MAX_READ; + + buf = kmalloc(thisread, GFP_KERNEL); + bytes = njb_usb_read(info->njb, offset - NJBFS_ID3SIZE, thisread, buf); + kfree(buf); + + count -= bytes; + offset += bytes; + } + + njb_set_pos(i, offset); + return 0; + } + + /* reads from the current position in a file on the jukebox until the file pointer rests comfortably at the offset *************** *** 804,807 **** --- 862,867 ---- */ + #define PROFILE + int njbfs_read_until(struct file *f, unsigned int fileid, char *name, u_int32_t until, char *buffer) { *************** *** 809,826 **** read_descriptor_t desc; struct inode *i = f->f_dentry->d_inode; - struct njbfs_sb_info *info = - (struct njbfs_sb_info *) i->i_sb->u.generic_sbp; ! u_int32_t tmp; ! int bytes; ! /* set the position of our next read */ ! ppos = njb_inode_get_lastread(i) + NJBFS_BLOCKSIZE; ! while (until - njb_inode_get_lastread(i) > NJBFS_BLOCKSIZE) { /* this lets the read (that gets called from generic_file_read) ! bypass our semaphores */ ! njb_interruption_inode = i->i_ino; ! desc.written = 0; desc.count = NJBFS_BLOCKSIZE; --- 869,896 ---- read_descriptor_t desc; struct inode *i = f->f_dentry->d_inode; ! #ifdef PROFILE ! time_t start = CURRENT_TIME; ! int start_byte = njb_get_pos(i); ! #endif ! if ( until == njb_get_pos(i) ) { ! /* everything's groovy */ ! return 0; ! } + if ( njb_interruption_inode == i->i_ino ) { + __njbfs_push(i, njb_get_pos(i), until - njb_get_pos(i)); + return 0; + } + + njb_interruption_inode = i->i_ino; + ppos = njb_get_pos(i); + + /* set the position of our next read */ + while (ppos < until) { /* this lets the read (that gets called from generic_file_read) ! bypass our semaphore */ ! desc.written = 0; desc.count = NJBFS_BLOCKSIZE; *************** *** 828,856 **** desc.error = 0; - tmp = ppos; - /* this may or may not call down into our read routine, depending on the state of the cache. */ do_generic_file_read(f, &ppos, &desc, njbfs_file_read_actor); ! if ( tmp != njb_inode_get_lastread(i) ! && ((long) tmp - NJBFS_ID3SIZE >= 0) ) { ! /* got the page from cache. (didn't call down ! into readpage) great. ! unfortuneately, we still have to ! push the dumb jukebox along. */ ! ! #if 0 ! dbg("pushing the nomad forward at %u",(unsigned int) ! tmp - NJBFS_ID3SIZE); ! #endif ! bytes = ! njb_usb_read(info->njb, name, ! (u_int32_t) tmp - NJBFS_ID3SIZE, ! (u_int32_t) NJBFS_BLOCKSIZE, (void *) buffer); ! ! } ! njb_inode_set_lastread(i, tmp); } njb_interruption_inode = 0; return 0; --- 898,916 ---- desc.error = 0; /* this may or may not call down into our read routine, depending on the state of the cache. */ do_generic_file_read(f, &ppos, &desc, njbfs_file_read_actor); ! } + if ( until != njb_get_pos(i) ) { + /* this means that we got cache hits at the end of our push */ + + __njbfs_push(i, njb_get_pos(i), until - njb_get_pos(i)); } + + #ifdef PROFILE + printk("pushed %d bytes in %d seconds\n", + until - start_byte, CURRENT_TIME - start); + #endif njb_interruption_inode = 0; return 0; *************** *** 861,883 **** */ - int njbfs_read_lock(struct inode *i) - { - struct njbfs_sb_info *info = i->i_sb->u.generic_sbp; - if ( njb_interruption_inode == 0 || - njb_interruption_inode != i->i_ino ) { - return njbfs_lock(info); - } - return 0; - } - - void njbfs_read_unlock(struct inode *i) - { - struct njbfs_sb_info *info = i->i_sb->u.generic_sbp; - if ( njb_interruption_inode == 0 || - njb_interruption_inode != i->i_ino ) { - njbfs_unlock(info); - } - } - /** * Read from a file. This is a function called from the VFS --- 921,924 ---- *************** *** 918,927 **** /* fake the top id3 tag */ create_id3_tag(dentry, buffer); ! njb_inode_set_lastread(inode, 0); dbg("faked the id3 header."); return NJBFS_BLOCKSIZE; } else if (offset < NJBFS_ID3SIZE) { /* pass back all zeros */ ! njb_inode_set_lastread(inode, offset); memset(buffer, 0, NJBFS_BLOCKSIZE); dbg("faked the 2nd block."); --- 959,968 ---- /* fake the top id3 tag */ create_id3_tag(dentry, buffer); ! njb_set_pos(inode, 0); dbg("faked the id3 header."); return NJBFS_BLOCKSIZE; } else if (offset < NJBFS_ID3SIZE) { /* pass back all zeros */ ! njb_set_pos(inode, offset + NJBFS_BLOCKSIZE); memset(buffer, 0, NJBFS_BLOCKSIZE); dbg("faked the 2nd block."); *************** *** 952,956 **** /* mark the inode as closed (usually njbfs_close does this) */ njb_inode_mark_closed(njb->current_dentry->d_inode); ! njb_inode_set_lastread(njb->current_dentry->d_inode, 0); if ( --- 993,997 ---- /* mark the inode as closed (usually njbfs_close does this) */ njb_inode_mark_closed(njb->current_dentry->d_inode); ! njb_set_pos(njb->current_dentry->d_inode, 0); if ( *************** *** 964,970 **** } } - /* give the jukebox a second to breathe before we open the next file */ - wait_ms(50); - } } --- 1005,1008 ---- *************** *** 994,998 **** if ( (bytes = ! njb_usb_read(info->njb, name, (u_int32_t) offset - NJBFS_ID3SIZE, (u_int32_t) count, (void *) buffer)) < 0) { err("read: couldn't read data from %s", name); --- 1032,1036 ---- if ( (bytes = ! njb_usb_read(info->njb, (u_int32_t) offset - NJBFS_ID3SIZE, (u_int32_t) count, (void *) buffer)) < 0) { err("read: couldn't read data from %s", name); *************** *** 1000,1004 **** return bytes; } ! njb_inode_set_lastread(inode, offset); njbfs_read_unlock(inode); --- 1038,1042 ---- return bytes; } ! njb_set_pos(inode, offset + bytes); njbfs_read_unlock(inode); |
From: Ben O. <ben...@us...> - 2002-02-19 06:26:50
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv25109 Modified Files: Tag: ben njb_usb.c Log Message: ben: njb_usb_read uses count to kmalloc instead of IBUF_SIZE. Also remove useless 'name' argument Index: njb_usb.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/njb_usb.c,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -C2 -d -r1.4.2.1 -r1.4.2.2 *** njb_usb.c 15 Feb 2002 20:07:32 -0000 1.4.2.1 --- njb_usb.c 19 Feb 2002 06:26:47 -0000 1.4.2.2 *************** *** 50,54 **** static int njb_usb_write(struct nomad_usb_data *nomad, char *name, u_int32_t offset, u_int32_t count, void *buffer); ! static int njb_usb_read(struct nomad_usb_data *nomad, char *name, u_int32_t offset, u_int32_t count, void *buffer); static int njb_usb_rename(struct nomad_usb_data *nomad, --- 50,54 ---- static int njb_usb_write(struct nomad_usb_data *nomad, char *name, u_int32_t offset, u_int32_t count, void *buffer); ! static int njb_usb_read(struct nomad_usb_data *nomad, u_int32_t offset, u_int32_t count, void *buffer); static int njb_usb_rename(struct nomad_usb_data *nomad, *************** *** 345,350 **** */ static int ! njb_usb_read(struct nomad_usb_data *njb, char *name, ! u_int32_t offset, u_int32_t count, void *buffer) { int status; --- 345,349 ---- */ static int ! njb_usb_read(struct nomad_usb_data *njb, u_int32_t offset, u_int32_t count, void *buffer) { int status; *************** *** 353,357 **** unsigned int actual_length; unsigned char param[8]; ! int size = IBUF_SIZE + 68; unsigned char *dest; int i; --- 352,356 ---- unsigned int actual_length; unsigned char param[8]; ! int size = count + 68; unsigned char *dest; int i; *************** *** 398,401 **** --- 397,401 ---- ("read: bulk read error, actual_length = %d, status = %d", actual_length, status); + return -EIO; } *************** *** 410,414 **** kfree(data); ! return actual_length - 68; } --- 410,414 ---- kfree(data); ! return actual_length - 68; } |
From: Ben O. <ben...@us...> - 2002-02-15 20:54:51
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv27132 Modified Files: Tag: ben nomad_usb.h Log Message: Ben: fix branch Index: nomad_usb.h =================================================================== RCS file: /cvsroot/njbfs/njbfs/nomad_usb.h,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** nomad_usb.h 10 Feb 2002 21:59:23 -0000 1.4 --- nomad_usb.h 15 Feb 2002 20:54:45 -0000 1.4.2.1 *************** *** 83,89 **** --- 83,91 ---- unsigned char id[16]; /* NJB ID */ char idstring[33]; /* NJB ID String */ + struct dentry *current_dentry; /* the entry currently being read */ u_int64_t total; /* result of last get usage call */ u_int64_t free; /* result of last get usage call */ int captured; /* if device is captured */ int session_updated; + struct njbfs_sb_info *sb; /* super-block info structure */ }; |
From: Ben O. <ben...@us...> - 2002-02-15 20:27:23
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv19758 Modified Files: Tag: ben njbfs.h Log Message: Ben: fix branch Index: njbfs.h =================================================================== RCS file: /cvsroot/njbfs/njbfs/njbfs.h,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** njbfs.h 10 Feb 2002 21:59:23 -0000 1.4 --- njbfs.h 15 Feb 2002 20:27:17 -0000 1.4.2.1 *************** *** 20,23 **** --- 20,26 ---- #define NJBFS_BLOCKSIZE_BITS 12 /* 2^x = blocksize */ + #define NJBFS_ID3SIZE 8192 /* size of the false tag at the top */ + #define NJBFS_FOOTERSIZE 4096 /* size of the zeroed footers at the bottom */ + struct njbfs_mount_data { int version; *************** *** 36,39 **** --- 39,45 ---- #define NJBFS_MODE_ARTISTS 4 + char *njbfs_strdup(char *in); + #define SAFE_STRDUP(x, y) if ( !(x=njbfs_strdup(y)) ) return -ENOMEM; + struct njbfs_sb_info { struct njbfs_mount_data mnt; *************** *** 58,61 **** --- 64,68 ---- unsigned long f_blksize; unsigned long f_blocks; + int open; u_int32_t fileid; /* file id of the NJB */ /* file name parsing */ *************** *** 68,73 **** u_int32_t length; /* optional frame: length in seconds */ u_int32_t tracknum; /* optional frame: album track number */ track_t *track; /* track */ ! }; --- 75,81 ---- u_int32_t length; /* optional frame: length in seconds */ u_int32_t tracknum; /* optional frame: album track number */ + u_int32_t year; /* optional frame: album track number */ track_t *track; /* track */ ! off_t real_size; /* the size that got reported from the njb */ }; |
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv13004 Modified Files: Tag: ben cache.c dir.c file.c inode.c njb_usb.c njbfs_cache.h njbfs_proc.h nomad.c proc.c Log Message: First add to the 'ben' branch. Included: -ID3 tag faking (speeds musicmatch) -read_until: seeks now work correctly by moving the jukebox forward to the correct offset. -use down_interruptible instead of down. Hard locks less. -ability to close another file down when one is opened -njbfs_get_attr_nolock -set title, artist, album, genre, tracknum in getattr Index: cache.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/cache.c,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** cache.c 10 Feb 2002 21:59:23 -0000 1.4 --- cache.c 15 Feb 2002 20:07:32 -0000 1.4.2.1 *************** *** 27,34 **** #include <linux/types.h> #include <linux/init.h> - #include <linux/smp_lock.h> #include <linux/fs.h> #include <linux/usb.h> #include <linux/slab.h> #include <asm/system.h> #include <asm/uaccess.h> --- 27,34 ---- #include <linux/types.h> #include <linux/init.h> #include <linux/fs.h> #include <linux/usb.h> #include <linux/slab.h> + #include <linux/smp_lock.h> #include <asm/system.h> #include <asm/uaccess.h> Index: dir.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/dir.c,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -C2 -d -r1.3 -r1.3.2.1 *** dir.c 10 Feb 2002 21:59:23 -0000 1.3 --- dir.c 15 Feb 2002 20:07:32 -0000 1.3.2.1 *************** *** 27,33 **** #include <linux/types.h> #include <linux/init.h> - #include <linux/smp_lock.h> #include <linux/fs.h> #include <linux/usb.h> #include <asm/system.h> #include <asm/uaccess.h> --- 27,33 ---- #include <linux/types.h> #include <linux/init.h> #include <linux/fs.h> #include <linux/usb.h> + #include <linux/smp_lock.h> #include <asm/system.h> #include <asm/uaccess.h> *************** *** 164,168 **** f->f_pos = 2; default: ! njbfs_lock(info); res = njbfs_cache_get(info, buf, &dir); njbfs_unlock(info); --- 164,172 ---- f->f_pos = 2; default: ! if (njbfs_lock(info)) { ! njbfs_disconnect(info); ! return -EINTR; ! } ! res = njbfs_cache_get(info, buf, &dir); njbfs_unlock(info); *************** *** 223,227 **** if ((res = njbfs_get_attr(dentry, &fattr, (struct njbfs_sb_info *) dir->i_sb->u. ! generic_sbp)) < 0) { inode = NULL; dentry->d_op = &njbfs_dentry_operations; --- 227,232 ---- if ((res = njbfs_get_attr(dentry, &fattr, (struct njbfs_sb_info *) dir->i_sb->u. ! generic_sbp, 0) < 0)) { ! inode = NULL; dentry->d_op = &njbfs_dentry_operations; *************** *** 253,257 **** struct inode *inode; ! if (njbfs_get_attr(dentry, &fattr, info) < 0) { info("njbfs_get_attr failed"); return -1; --- 258,262 ---- struct inode *inode; ! if (njbfs_get_attr(dentry, &fattr, info, 0) < 0) { info("njbfs_get_attr failed"); return -1; Index: file.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/file.c,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** file.c 10 Feb 2002 21:59:23 -0000 1.2 --- file.c 15 Feb 2002 20:07:32 -0000 1.2.2.1 *************** *** 54,58 **** do { ! result = njbfs_read(dentry, offset, count, buffer); if (result < 0) { err("read error"); --- 54,58 ---- do { ! result = njbfs_read(f, dentry, offset, count, buffer); if (result < 0) { err("read error"); Index: inode.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/inode.c,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -C2 -d -r1.5 -r1.5.2.1 *** inode.c 10 Feb 2002 21:59:23 -0000 1.5 --- inode.c 15 Feb 2002 20:07:32 -0000 1.5.2.1 *************** *** 176,179 **** --- 176,180 ---- info->njb = &nomad_instance; + info->njb->sb = info; info->virtual_mode = 0; Index: njb_usb.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/njb_usb.c,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** njb_usb.c 10 Feb 2002 21:59:23 -0000 1.4 --- njb_usb.c 15 Feb 2002 20:07:32 -0000 1.4.2.1 *************** *** 38,44 **** #include "track.h" #include "playlist.h" ! ! /* forward decl's */ static int njb_usb_connect(struct nomad_usb_data *nomad); --- 38,44 ---- #include "track.h" #include "playlist.h" + #include "njbfs_proc.h" ! #define dbg err /* forward decl's */ static int njb_usb_connect(struct nomad_usb_data *nomad); *************** *** 175,180 **** } dbg("open: handshake ok"); ! ! /* Get disk usage */ status = njb_usb_get_disk_usage(njb, &total, &free); if (status < 0) { --- 175,180 ---- } dbg("open: handshake ok"); ! ! /* Get disk usage */ status = njb_usb_get_disk_usage(njb, &total, &free); if (status < 0) { *************** *** 207,210 **** --- 207,211 ---- } else if (fattr->fileid > 0) { + dbg("attempting to open '%s'..", fattr->title); /* Open for read track */ *************** *** 215,219 **** return status; } ! status = njb_usb_handshake(njb); if (status < 0) { --- 216,220 ---- return status; } ! #if 0 status = njb_usb_handshake(njb); if (status < 0) { *************** *** 222,225 **** --- 223,227 ---- return status; } + #endif /* *************** *** 247,251 **** if (status < 0) err("open: verify error, status = %d", status); - } --- 249,252 ---- *************** *** 255,262 **** /** ! * Close NJB on USB. */ static int ! njb_usb_close(struct nomad_usb_data *njb, struct njbfs_fattr *fattr) { int status; --- 256,263 ---- /** ! * Close a file NJB on USB. */ static int ! _njb_usb_close(struct nomad_usb_data *njb, struct njbfs_fattr *fattr) { int status; *************** *** 272,275 **** --- 273,280 ---- } + if (!njb->captured) /* then don't send */ + return NJB_NOT_CAPTURED; + + dbg("attempting to close \"%s\"", fattr->title); /* close */ retries = 3; *************** *** 285,289 **** err("close: can't send close command, status=%d", status); - wait_ms(250); retries--; } --- 290,293 ---- *************** *** 297,301 **** } - if (fattr->fileid == 0) { --- 301,304 ---- *************** *** 312,317 **** njb->isopen = 0; - - status = njb_usb_release(njb); dbg("close: jukebox closed"); --- 315,318 ---- *************** *** 319,322 **** --- 320,343 ---- } + /** + * Close a file NJB on USB. + */ + static int + njb_usb_close(struct nomad_usb_data *njb, struct njbfs_fattr *fattr) + { + int status; + if ((status = _njb_usb_close(njb, fattr))) + return status; + njb_usb_release(njb); + } + static int + njb_usb_close_no_release(struct nomad_usb_data *njb, + struct njbfs_fattr *fattr) + { + return _njb_usb_close(njb, fattr); + } + + /** + * /** *************** *** 363,367 **** if (status < 0) { err("read: njb control error"); ! /* let's run into bulk timeout and do a soft landing. */ } --- 384,390 ---- if (status < 0) { err("read: njb control error"); ! /* let's run into bulk timeout and do a soft landing. ! ben: I found that sometimes the bulk doesn't land too soft in this case. */ ! return -EIO; } *************** *** 560,564 **** * @param data the data buffer for the request (not NULL) * @param size the size of the data buffer ! * @param retries how many times the control message shall be retried */ static int --- 583,587 ---- * @param data the data buffer for the request (not NULL) * @param size the size of the data buffer ! * @param retries how mny times the control message shall be retried */ static int *************** *** 572,576 **** return status; ! down(&(njb->lock)); while (retries) { status = --- 595,601 ---- return status; ! if (down_interruptible(&(njb->lock))) ! return -EINTR; ! while (retries) { status = *************** *** 1053,1057 **** err ("get_track_tag: couldn't kmalloc track tag of size: %d", ! header->size); return NULL; } --- 1078,1082 ---- err ("get_track_tag: couldn't kmalloc track tag of size: %d", ! header->size); return NULL; } *************** *** 1199,1203 **** err ("write_track_tag: short bulk write, actual_length = %d", ! actual_length); return -EIO; } --- 1224,1228 ---- err ("write_track_tag: short bulk write, actual_length = %d", ! actual_length); return -EIO; } *************** *** 1453,1457 **** /* Check if replace? */ - if (replace) { /* replace tag track */ --- 1478,1481 ---- Index: njbfs_cache.h =================================================================== RCS file: /cvsroot/njbfs/njbfs/njbfs_cache.h,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** njbfs_cache.h 10 Feb 2002 21:59:23 -0000 1.4 --- njbfs_cache.h 15 Feb 2002 20:07:32 -0000 1.4.2.1 *************** *** 128,133 **** --- 128,135 ---- u_int32_t length; /* optional frame: length in seconds */ u_int32_t tracknum; /* optional frame: album track number */ + u_int32_t year; /* optional frame: album track number */ track_t *track; /* track */ int update_track_tag; /* should track tag be updated? 1=yes 0=no */ + off_t real_size; /* the real file size, not what we report to the system */ }; Index: njbfs_proc.h =================================================================== RCS file: /cvsroot/njbfs/njbfs/njbfs_proc.h,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -C2 -d -r1.3 -r1.3.2.1 *** njbfs_proc.h 10 Feb 2002 21:59:23 -0000 1.3 --- njbfs_proc.h 15 Feb 2002 20:07:32 -0000 1.3.2.1 *************** *** 11,20 **** struct njbfs_directory *); int njbfs_get_name(struct dentry *, char *); ! inline void njbfs_lock(struct njbfs_sb_info *); inline void njbfs_unlock(struct njbfs_sb_info *); int njbfs_get_attr(struct dentry *, struct njbfs_fattr *, ! struct njbfs_sb_info *); struct inode *njbfs_iget(struct super_block *, struct njbfs_fattr *); ! int njbfs_read(struct dentry *, unsigned long, unsigned long, char *); int njbfs_proc_mkdir(struct njbfs_sb_info *, char *); int njbfs_proc_rmdir(struct njbfs_sb_info *, char *); --- 11,20 ---- struct njbfs_directory *); int njbfs_get_name(struct dentry *, char *); ! inline int njbfs_lock(struct njbfs_sb_info *); inline void njbfs_unlock(struct njbfs_sb_info *); int njbfs_get_attr(struct dentry *, struct njbfs_fattr *, ! struct njbfs_sb_info *, int); struct inode *njbfs_iget(struct super_block *, struct njbfs_fattr *); ! int njbfs_read(struct file *file, struct dentry *, unsigned long, unsigned long, char *); int njbfs_proc_mkdir(struct njbfs_sb_info *, char *); int njbfs_proc_rmdir(struct njbfs_sb_info *, char *); Index: nomad.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/nomad.c,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -C2 -d -r1.3 -r1.3.2.1 *** nomad.c 10 Feb 2002 21:59:23 -0000 1.3 --- nomad.c 15 Feb 2002 20:07:32 -0000 1.3.2.1 *************** *** 48,52 **** #if !defined (DEBUG) && defined (CONFIG_USB_DEBUG) ! # define DEBUG #endif #include <linux/usb.h> --- 48,52 ---- #if !defined (DEBUG) && defined (CONFIG_USB_DEBUG) ! #define DEBUG #endif #include <linux/usb.h> *************** *** 516,519 **** --- 516,520 ---- nomad->info = nomad_info + id->driver_info; /* device name */ + nomad->current_dentry = NULL; nomad->present = 1; nomad->nomad_dev = dev; Index: proc.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/proc.c,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -C2 -d -r1.6 -r1.6.2.1 *** proc.c 10 Feb 2002 21:59:23 -0000 1.6 --- proc.c 15 Feb 2002 20:07:32 -0000 1.6.2.1 *************** *** 39,42 **** --- 39,44 ---- #include <linux/time.h> #include <linux/ctype.h> + #include <linux/string.h> + #include <linux/pagemap.h> #include <asm/system.h> #include <asm/uaccess.h> *************** *** 45,48 **** --- 47,51 ---- [...978 lines suppressed...] *l = simple_strtoll(str, &next, base); } else { *************** *** 1296,1299 **** --- 1694,1708 ---- return i; } + + char *njbfs_strdup(char *in) + { + char *out; + if (!in) + return NULL; + out = kmalloc(strlen(in) * sizeof(char) + 1, GFP_KERNEL); + strcpy(out, in); + return out; + } + /* end of 'sscanf' kernel compatibility hack */ |
From: Ben O. <ben...@us...> - 2002-02-15 20:03:11
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv12755 Modified Files: dir.c Log Message: Changing the include order here fixes another 2.4.9 compilation error. Index: dir.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/dir.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dir.c 10 Feb 2002 21:59:23 -0000 1.3 --- dir.c 15 Feb 2002 20:03:04 -0000 1.4 *************** *** 27,33 **** #include <linux/types.h> #include <linux/init.h> - #include <linux/smp_lock.h> #include <linux/fs.h> #include <linux/usb.h> #include <asm/system.h> #include <asm/uaccess.h> --- 27,33 ---- #include <linux/types.h> #include <linux/init.h> #include <linux/fs.h> #include <linux/usb.h> + #include <linux/smp_lock.h> #include <asm/system.h> #include <asm/uaccess.h> |
From: Ben O. <ben...@us...> - 2002-02-15 19:28:50
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv3362 Modified Files: nomad_usb.h Log Message: rollback to fix branching fuck-up Index: nomad_usb.h =================================================================== RCS file: /cvsroot/njbfs/njbfs/nomad_usb.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** nomad_usb.h 15 Feb 2002 19:09:04 -0000 1.5 --- nomad_usb.h 15 Feb 2002 19:28:47 -0000 1.6 *************** *** 83,91 **** unsigned char id[16]; /* NJB ID */ char idstring[33]; /* NJB ID String */ - struct dentry *current_dentry; /* the entry currently being read */ u_int64_t total; /* result of last get usage call */ u_int64_t free; /* result of last get usage call */ int captured; /* if device is captured */ int session_updated; - struct njbfs_sb_info *sb; /* super-block info structure */ }; --- 83,89 ---- |
From: Ben O. <ben...@us...> - 2002-02-15 19:26:29
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv2850 Modified Files: njbfs.h Log Message: Ben: rollback to fix branching fuck-up Index: njbfs.h =================================================================== RCS file: /cvsroot/njbfs/njbfs/njbfs.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** njbfs.h 15 Feb 2002 19:21:07 -0000 1.5 --- njbfs.h 15 Feb 2002 19:26:25 -0000 1.6 *************** *** 20,26 **** #define NJBFS_BLOCKSIZE_BITS 12 /* 2^x = blocksize */ - #define NJBFS_ID3SIZE 8192 /* size of the false tag at the top */ - #define NJBFS_FOOTERSIZE 4096 /* size of the zeroed footers at the bottom */ - struct njbfs_mount_data { int version; --- 20,23 ---- *************** *** 39,45 **** #define NJBFS_MODE_ARTISTS 4 - char *njbfs_strdup(char *in); - #define SAFE_STRDUP(x, y) if ( !(x=njbfs_strdup(y)) ) return -ENOMEM; - struct njbfs_sb_info { struct njbfs_mount_data mnt; --- 36,39 ---- *************** *** 64,68 **** unsigned long f_blksize; unsigned long f_blocks; - int open; u_int32_t fileid; /* file id of the NJB */ /* file name parsing */ --- 58,61 ---- *************** *** 75,81 **** u_int32_t length; /* optional frame: length in seconds */ u_int32_t tracknum; /* optional frame: album track number */ - u_int32_t year; /* optional frame: album track number */ track_t *track; /* track */ ! off_t real_size; /* the size that got reported from the njb */ }; --- 68,73 ---- u_int32_t length; /* optional frame: length in seconds */ u_int32_t tracknum; /* optional frame: album track number */ track_t *track; /* track */ ! }; |
From: Ben O. <ben...@us...> - 2002-02-15 19:23:17
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv2321 Modified Files: Tag: ben njb_usb.h Log Message: ben: first commit Index: njb_usb.h =================================================================== RCS file: /cvsroot/njbfs/njbfs/njb_usb.h,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -C2 -d -r1.3 -r1.3.2.1 *** njb_usb.h 23 Dec 2001 20:16:56 -0000 1.3 --- njb_usb.h 15 Feb 2002 19:23:15 -0000 1.3.2.1 *************** *** 139,142 **** --- 139,143 ---- #define NJB_DISKFULL_FOR_DOWNLOAD 0x90 #define NJB_FILE_PLAYONLY 0x91 + #define NJB_NOT_CAPTURED 0x92 #define NJB_UNDEFINED_ERR 0xff |
From: Ben O. <ben...@us...> - 2002-02-15 19:21:10
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv1813 Modified Files: njbfs.h Log Message: Ben: first commit Index: njbfs.h =================================================================== RCS file: /cvsroot/njbfs/njbfs/njbfs.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** njbfs.h 10 Feb 2002 21:59:23 -0000 1.4 --- njbfs.h 15 Feb 2002 19:21:07 -0000 1.5 *************** *** 20,23 **** --- 20,26 ---- #define NJBFS_BLOCKSIZE_BITS 12 /* 2^x = blocksize */ + #define NJBFS_ID3SIZE 8192 /* size of the false tag at the top */ + #define NJBFS_FOOTERSIZE 4096 /* size of the zeroed footers at the bottom */ + struct njbfs_mount_data { int version; *************** *** 36,39 **** --- 39,45 ---- #define NJBFS_MODE_ARTISTS 4 + char *njbfs_strdup(char *in); + #define SAFE_STRDUP(x, y) if ( !(x=njbfs_strdup(y)) ) return -ENOMEM; + struct njbfs_sb_info { struct njbfs_mount_data mnt; *************** *** 58,61 **** --- 64,68 ---- unsigned long f_blksize; unsigned long f_blocks; + int open; u_int32_t fileid; /* file id of the NJB */ /* file name parsing */ *************** *** 68,73 **** u_int32_t length; /* optional frame: length in seconds */ u_int32_t tracknum; /* optional frame: album track number */ track_t *track; /* track */ ! }; --- 75,81 ---- u_int32_t length; /* optional frame: length in seconds */ u_int32_t tracknum; /* optional frame: album track number */ + u_int32_t year; /* optional frame: album track number */ track_t *track; /* track */ ! off_t real_size; /* the size that got reported from the njb */ }; |
From: Ben O. <ben...@us...> - 2002-02-15 19:09:08
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv31104 Modified Files: nomad_usb.h Log Message: first commit Index: nomad_usb.h =================================================================== RCS file: /cvsroot/njbfs/njbfs/nomad_usb.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** nomad_usb.h 10 Feb 2002 21:59:23 -0000 1.4 --- nomad_usb.h 15 Feb 2002 19:09:04 -0000 1.5 *************** *** 83,89 **** --- 83,91 ---- unsigned char id[16]; /* NJB ID */ char idstring[33]; /* NJB ID String */ + struct dentry *current_dentry; /* the entry currently being read */ u_int64_t total; /* result of last get usage call */ u_int64_t free; /* result of last get usage call */ int captured; /* if device is captured */ int session_updated; + struct njbfs_sb_info *sb; /* super-block info structure */ }; |
From: Ben O. <ben...@us...> - 2002-02-10 21:59:27
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv22292 Modified Files: automount.c cache.c dir.c driver.c file.c inode.c njb_usb.c njbfs.h njbfs_cache.h njbfs_proc.h nomad.c nomad_usb.h playlist.c playlist.h proc.c symlink.c track.c track.h Log Message: run indent -kr -i 8 on the whole shebang Index: automount.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/automount.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** automount.c 4 Nov 2001 13:46:00 -0000 1.1.1.1 --- automount.c 10 Feb 2002 21:59:23 -0000 1.2 *************** *** 26,40 **** #include <string.h> ! int main(int argc, char **argv){ ! char *virtualdirectory; /* "tracks", "playlists", "artists", "albums" */ if ((argc < 2) || ! (strcmp("tracks", argv[1]) && ! strcmp("playlists", argv[1]) && ! strcmp("artists", argv[1]) && ! strcmp("albums", argv[1])) ) { ! fprintf(stderr, "Need virtual directory name here: 'tracks', 'playlists', 'albums' or 'artists'\n"); exit(-1); } --- 26,41 ---- #include <string.h> ! int main(int argc, char **argv) ! { ! char *virtualdirectory; /* "tracks", "playlists", "artists", "albums" */ if ((argc < 2) || ! (strcmp("tracks", argv[1]) && ! strcmp("playlists", argv[1]) && ! strcmp("artists", argv[1]) && strcmp("albums", argv[1]))) { ! fprintf(stderr, ! "Need virtual directory name here: 'tracks', 'playlists', 'albums' or 'artists'\n"); exit(-1); } *************** *** 44,46 **** return 0; } - --- 45,46 ---- Index: cache.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/cache.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** cache.c 4 Dec 2001 21:09:31 -0000 1.3 --- cache.c 10 Feb 2002 21:59:23 -0000 1.4 *************** *** 39,47 **** #define dir_cache info->cache ! void njbfs_cache_init(struct njbfs_sb_info *info){ memset(&dir_cache, 0, sizeof(struct njbfs_dir_cache)); } ! unsigned long njbfs_cache_hash(char *name){ unsigned long hash = 0; int i; --- 39,49 ---- #define dir_cache info->cache ! void njbfs_cache_init(struct njbfs_sb_info *info) ! { memset(&dir_cache, 0, sizeof(struct njbfs_dir_cache)); } ! unsigned long njbfs_cache_hash(char *name) ! { unsigned long hash = 0; int i; *************** *** 56,63 **** struct njbfs_dirlist_node *p, *q; ! if (!n) return -1; for (p = n->directory.head; p != NULL; p = q) { q = p->next; ! if(p->entry.name != NULL){ kfree(p->entry.name); p->entry.name = NULL; --- 58,66 ---- struct njbfs_dirlist_node *p, *q; ! if (!n) ! return -1; for (p = n->directory.head; p != NULL; p = q) { q = p->next; ! if (p->entry.name != NULL) { kfree(p->entry.name); p->entry.name = NULL; *************** *** 67,73 **** kfree(n->directory.name); ! if(n->prev != NULL) n->prev->next = n->next; ! if(n->next != NULL) n->next->prev = n->prev; return 0; --- 70,76 ---- kfree(n->directory.name); ! if (n->prev != NULL) n->prev->next = n->next; ! if (n->next != NULL) n->next->prev = n->prev; return 0; *************** *** 75,79 **** int njbfs_cache_infront(unsigned long hsh, struct njbfs_hashlist_node *n, ! struct njbfs_sb_info *info) { unsigned long h; --- 78,82 ---- int njbfs_cache_infront(unsigned long hsh, struct njbfs_hashlist_node *n, ! struct njbfs_sb_info *info) { unsigned long h; *************** *** 101,105 **** struct njbfs_hashlist_node *p; ! if (dir_cache.len[hsh] == 0) return -1; for (p = dir_cache.hash[hsh]; p->next != NULL; p = p->next); njbfs_cache_deldir(p); --- 104,109 ---- struct njbfs_hashlist_node *p; ! if (dir_cache.len[hsh] == 0) ! return -1; for (p = dir_cache.hash[hsh]; p->next != NULL; p = p->next); njbfs_cache_deldir(p); *************** *** 109,113 **** } ! int njbfs_cache_add(struct njbfs_sb_info *info, char *name, struct njbfs_directory **dir) { unsigned long hsh; --- 113,118 ---- } ! int njbfs_cache_add(struct njbfs_sb_info *info, char *name, ! struct njbfs_directory **dir) { unsigned long hsh; *************** *** 119,123 **** while (dir_cache.len[hsh] >= NJBFS_CACHE_LEN) njbfs_cache_shrink(hsh, info); ! p = (struct njbfs_hashlist_node *)kmalloc(sizeof(struct njbfs_hashlist_node), GFP_KERNEL); if (!p) { res = -1; --- 124,130 ---- while (dir_cache.len[hsh] >= NJBFS_CACHE_LEN) njbfs_cache_shrink(hsh, info); ! p = ! (struct njbfs_hashlist_node *) ! kmalloc(sizeof(struct njbfs_hashlist_node), GFP_KERNEL); if (!p) { res = -1; *************** *** 129,133 **** p->directory.valid = 1; p->directory.time = CURRENT_TIME; ! p->directory.name = (char*)kmalloc(strlen(name) + 1, GFP_KERNEL); if (!p->directory.name) { err("kmalloc error!"); --- 136,140 ---- p->directory.valid = 1; p->directory.time = CURRENT_TIME; ! p->directory.name = (char *) kmalloc(strlen(name) + 1, GFP_KERNEL); if (!p->directory.name) { err("kmalloc error!"); *************** *** 137,141 **** strcpy(p->directory.name, name); ! info("cache_add: loading directory '%s'....", name); if ((res = njbfs_loaddir(info, name, &p->directory)) < 0) { err("cache_add: couldn't load directory"); --- 144,148 ---- strcpy(p->directory.name, name); ! info("cache_add: loading directory '%s'....", name); if ((res = njbfs_loaddir(info, name, &p->directory)) < 0) { err("cache_add: couldn't load directory"); *************** *** 151,163 **** *dir = &p->directory; return 0; ! out2: kfree(p->directory.name); ! out1: kfree(p); ! out: return res; } ! int njbfs_cache_get(struct njbfs_sb_info *info, char *name, struct njbfs_directory **dir) { struct njbfs_hashlist_node *p; --- 158,171 ---- *dir = &p->directory; return 0; ! out2: kfree(p->directory.name); ! out1: kfree(p); ! out: return res; } ! int njbfs_cache_get(struct njbfs_sb_info *info, char *name, ! struct njbfs_directory **dir) { struct njbfs_hashlist_node *p; *************** *** 166,173 **** hsh = njbfs_cache_hash(name); for (p = dir_cache.hash[hsh]; p != NULL; p = p->next) ! if ((strcmp(name, p->directory.name) == 0)&&(p->directory.valid)) { ! if(CURRENT_TIME - p->directory.time > NJBFS_CACHE_TTL) { ! /* entry too old */ ! //return njbfs_cache_add(info, name, dir); } njbfs_cache_infront(hsh, p, info); --- 174,183 ---- hsh = njbfs_cache_hash(name); for (p = dir_cache.hash[hsh]; p != NULL; p = p->next) ! if ((strcmp(name, p->directory.name) == 0) ! && (p->directory.valid)) { ! if (CURRENT_TIME - p->directory.time > ! NJBFS_CACHE_TTL) { ! /* entry too old */ ! //return njbfs_cache_add(info, name, dir); } njbfs_cache_infront(hsh, p, info); *************** *** 176,185 **** } ! return njbfs_cache_add(info, name, dir); } int njbfs_cache_empty(struct njbfs_sb_info *info) { ! int i,j; struct njbfs_hashlist_node *p; --- 186,195 ---- } ! return njbfs_cache_add(info, name, dir); } int njbfs_cache_empty(struct njbfs_sb_info *info) { ! int i, j; struct njbfs_hashlist_node *p; *************** *** 196,200 **** { struct super_block *sb = dentry->d_inode->i_sb; ! struct njbfs_sb_info *info = (struct njbfs_sb_info*)sb->u.generic_sbp; char buf[NJBFS_MAXPATHLEN]; struct njbfs_hashlist_node *p; --- 206,211 ---- { struct super_block *sb = dentry->d_inode->i_sb; ! struct njbfs_sb_info *info = ! (struct njbfs_sb_info *) sb->u.generic_sbp; char buf[NJBFS_MAXPATHLEN]; struct njbfs_hashlist_node *p; *************** *** 210,212 **** } } - --- 221,222 ---- Index: dir.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/dir.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dir.c 4 Dec 2001 21:09:31 -0000 1.2 --- dir.c 10 Feb 2002 21:59:23 -0000 1.3 *************** *** 36,86 **** #include "njbfs_proc.h" ! static int njbfs_lookup_validate(struct dentry*, int); ! static int njbfs_hash_dentry(struct dentry*, struct qstr*); ! static int njbfs_compare_dentry(struct dentry*, struct qstr*, struct qstr*); ! static int njbfs_delete_dentry(struct dentry*); static struct dentry_operations njbfs_dentry_operations = { ! d_revalidate: njbfs_lookup_validate, ! d_hash: njbfs_hash_dentry, ! d_compare: njbfs_compare_dentry, ! d_delete: njbfs_delete_dentry, }; ! static int njbfs_readdir(struct file*, void*, filldir_t); ! static int njbfs_dir_open(struct inode*, struct file*); ! static struct dentry *njbfs_lookup(struct inode*, struct dentry*); ! static int njbfs_mkdir(struct inode*, struct dentry*, int); ! static int njbfs_create(struct inode*, struct dentry*, int); ! static int njbfs_rmdir(struct inode*, struct dentry*); ! static int njbfs_rename(struct inode*, struct dentry*, struct inode*, struct dentry*); ! static int njbfs_unlink(struct inode*, struct dentry*); ! struct file_operations njbfs_dir_operations = { ! read: generic_read_dir, ! readdir: njbfs_readdir, ! open: njbfs_dir_open, }; struct inode_operations njbfs_dir_inode_operations = { ! create: njbfs_create, ! lookup: njbfs_lookup, ! unlink: njbfs_unlink, ! mkdir: njbfs_mkdir, ! rmdir: njbfs_rmdir, ! rename: njbfs_rename, }; ! static int ! njbfs_lookup_validate(struct dentry* dentry, int flags) { struct inode *inode = dentry->d_inode; int valid = 0; ! if(inode){ lock_kernel(); ! if(is_bad_inode(inode)) valid = 0; unlock_kernel(); --- 36,87 ---- #include "njbfs_proc.h" ! static int njbfs_lookup_validate(struct dentry *, int); ! static int njbfs_hash_dentry(struct dentry *, struct qstr *); ! static int njbfs_compare_dentry(struct dentry *, struct qstr *, ! struct qstr *); ! static int njbfs_delete_dentry(struct dentry *); static struct dentry_operations njbfs_dentry_operations = { ! d_revalidate:njbfs_lookup_validate, ! d_hash:njbfs_hash_dentry, ! d_compare:njbfs_compare_dentry, ! d_delete:njbfs_delete_dentry, }; ! static int njbfs_readdir(struct file *, void *, filldir_t); ! static int njbfs_dir_open(struct inode *, struct file *); ! static struct dentry *njbfs_lookup(struct inode *, struct dentry *); ! static int njbfs_mkdir(struct inode *, struct dentry *, int); ! static int njbfs_create(struct inode *, struct dentry *, int); ! static int njbfs_rmdir(struct inode *, struct dentry *); ! static int njbfs_rename(struct inode *, struct dentry *, struct inode *, ! struct dentry *); ! static int njbfs_unlink(struct inode *, struct dentry *); ! struct file_operations njbfs_dir_operations = { ! read:generic_read_dir, ! readdir:njbfs_readdir, ! open:njbfs_dir_open, }; struct inode_operations njbfs_dir_inode_operations = { ! create:njbfs_create, ! lookup:njbfs_lookup, ! unlink:njbfs_unlink, ! mkdir:njbfs_mkdir, ! rmdir:njbfs_rmdir, ! rename:njbfs_rename, }; ! static int njbfs_lookup_validate(struct dentry *dentry, int flags) { struct inode *inode = dentry->d_inode; int valid = 0; ! if (inode) { lock_kernel(); ! if (is_bad_inode(inode)) valid = 0; unlock_kernel(); *************** *** 90,95 **** } ! static int ! njbfs_hash_dentry(struct dentry* dentry, struct qstr* this) { unsigned long hash; --- 91,95 ---- } ! static int njbfs_hash_dentry(struct dentry *dentry, struct qstr *this) { unsigned long hash; *************** *** 97,101 **** hash = init_name_hash(); ! for(i = 0; i < this->len; i++) hash = partial_name_hash(this->name[i], hash); this->hash = end_name_hash(hash); --- 97,101 ---- hash = init_name_hash(); ! for (i = 0; i < this->len; i++) hash = partial_name_hash(this->name[i], hash); this->hash = end_name_hash(hash); *************** *** 104,126 **** static int ! njbfs_compare_dentry(struct dentry* dentry, struct qstr* a, struct qstr* b) { int i, res = 1; ! if(a->len != b->len) goto out; ! for(i = 0; i < a->len; i++) ! if(a->name[i] != b->name[i]) goto out; res = 0; ! out: return res; } ! static int ! njbfs_delete_dentry(struct dentry* dentry) { ! if(dentry->d_inode){ ! if(is_bad_inode(dentry->d_inode)) return 1; } --- 104,125 ---- static int ! njbfs_compare_dentry(struct dentry *dentry, struct qstr *a, struct qstr *b) { int i, res = 1; ! if (a->len != b->len) goto out; ! for (i = 0; i < a->len; i++) ! if (a->name[i] != b->name[i]) goto out; res = 0; ! out: return res; } ! static int njbfs_delete_dentry(struct dentry *dentry) { ! if (dentry->d_inode) { ! if (is_bad_inode(dentry->d_inode)) return 1; } *************** *** 128,138 **** } ! static int ! njbfs_readdir(struct file* f, void* dirent, filldir_t filldir) { struct dentry *dentry = f->f_dentry; struct inode *inode = dentry->d_inode; struct super_block *sb = inode->i_sb; ! struct njbfs_sb_info *info = (struct njbfs_sb_info*)sb->u.generic_sbp; char buf[NJBFS_MAXPATHLEN]; int result, pos, res; --- 127,137 ---- } ! static int njbfs_readdir(struct file *f, void *dirent, filldir_t filldir) { struct dentry *dentry = f->f_dentry; struct inode *inode = dentry->d_inode; struct super_block *sb = inode->i_sb; ! struct njbfs_sb_info *info = ! (struct njbfs_sb_info *) sb->u.generic_sbp; char buf[NJBFS_MAXPATHLEN]; int result, pos, res; *************** *** 141,150 **** struct njbfs_dirlist_node *file; ! if(!info->mnt.mount_point[0]){ ! njbfs_get_name(f->f_vfsmnt->mnt_mountpoint, info->mnt.mount_point); } ! dbg("reading %s, f_pos=%d", dentry->d_name.name, (int)f->f_pos); ! if(njbfs_get_name(dentry, buf) < 0){ err(" njbfs_get_name failed"); return -1; --- 140,150 ---- struct njbfs_dirlist_node *file; ! if (!info->mnt.mount_point[0]) { ! njbfs_get_name(f->f_vfsmnt->mnt_mountpoint, ! info->mnt.mount_point); } ! dbg("reading %s, f_pos=%d", dentry->d_name.name, (int) f->f_pos); ! if (njbfs_get_name(dentry, buf) < 0) { err(" njbfs_get_name failed"); return -1; *************** *** 152,214 **** result = 0; ! switch((unsigned int) f->f_pos){ ! case 0: ! if(filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0) ! goto out; ! f->f_pos = 1; ! case 1: ! if(filldir(dirent, "..", 2, 1, dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) ! goto out; ! f->f_pos = 2; ! default: ! njbfs_lock(info); ! res = njbfs_cache_get(info, buf, &dir); ! njbfs_unlock(info); ! if(res < 0){ ! info(" njbfs_cache_get failed"); ! switch(res){ ! case -ERESTARTSYS: res = -EINTR; ! njbfs_disconnect(info); ! break; ! } ! return res; } ! pos = 2; ! for(file = dir->head; file != NULL; file = file->next){ ! if((pos == f->f_pos)){ ! struct qstr qname; ! unsigned long ino; ! qname.name = file->entry.name; ! qname.len = strlen(qname.name); ! ino = find_inode_number(dentry, &qname); ! if(!ino) ! ino = iunique(dentry->d_sb, 2); ! if(filldir(dirent, qname.name, qname.len, f->f_pos, ino, DT_UNKNOWN) >= 0) ! f->f_pos++; - } - pos++; } } ! out: return result; } ! static int ! njbfs_dir_open(struct inode* inode, struct file* f) { ! return 0; } ! static struct dentry* ! njbfs_lookup(struct inode* dir, struct dentry* dentry) { struct super_block *sb = dir->i_sb; ! struct njbfs_sb_info *info = (struct njbfs_sb_info*)sb->u.generic_sbp; struct njbfs_fattr fattr; struct inode *inode; --- 152,219 ---- result = 0; ! switch ((unsigned int) f->f_pos) { ! case 0: ! if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0) ! goto out; ! f->f_pos = 1; ! case 1: ! if (filldir ! (dirent, "..", 2, 1, dentry->d_parent->d_inode->i_ino, ! DT_DIR) < 0) ! goto out; ! f->f_pos = 2; ! default: ! njbfs_lock(info); ! res = njbfs_cache_get(info, buf, &dir); ! njbfs_unlock(info); ! if (res < 0) { ! info(" njbfs_cache_get failed"); ! switch (res) { ! case -ERESTARTSYS: ! res = -EINTR; ! njbfs_disconnect(info); ! break; } + return res; + } ! pos = 2; ! for (file = dir->head; file != NULL; file = file->next) { ! if ((pos == f->f_pos)) { ! struct qstr qname; ! unsigned long ino; ! qname.name = file->entry.name; ! qname.len = strlen(qname.name); ! ino = find_inode_number(dentry, &qname); ! if (!ino) ! ino = iunique(dentry->d_sb, 2); ! if (filldir ! (dirent, qname.name, qname.len, ! f->f_pos, ino, DT_UNKNOWN) >= 0) ! f->f_pos++; } + pos++; + } } ! out: return result; } ! static int njbfs_dir_open(struct inode *inode, struct file *f) { ! return 0; } ! static struct dentry *njbfs_lookup(struct inode *dir, ! struct dentry *dentry) { struct super_block *sb = dir->i_sb; ! struct njbfs_sb_info *info = ! (struct njbfs_sb_info *) sb->u.generic_sbp; struct njbfs_fattr fattr; struct inode *inode; *************** *** 216,229 **** dbg("dname:%s", dentry->d_name.name); ! if((res = njbfs_get_attr(dentry, &fattr, ! (struct njbfs_sb_info*)dir->i_sb->u.generic_sbp)) < 0){ inode = NULL; dentry->d_op = &njbfs_dentry_operations; d_add(dentry, inode); ! switch(res){ ! case -ERESTARTSYS: ! res = -EINTR; ! njbfs_disconnect(info); ! return ERR_PTR(res); } return NULL; --- 221,235 ---- dbg("dname:%s", dentry->d_name.name); ! if ((res = njbfs_get_attr(dentry, &fattr, ! (struct njbfs_sb_info *) dir->i_sb->u. ! generic_sbp)) < 0) { inode = NULL; dentry->d_op = &njbfs_dentry_operations; d_add(dentry, inode); ! switch (res) { ! case -ERESTARTSYS: ! res = -EINTR; ! njbfs_disconnect(info); ! return ERR_PTR(res); } return NULL; *************** *** 232,236 **** fattr.f_ino = iunique(dentry->d_sb, 2); inode = njbfs_iget(dir->i_sb, &fattr); ! if(inode){ dentry->d_op = &njbfs_dentry_operations; d_add(dentry, inode); --- 238,242 ---- fattr.f_ino = iunique(dentry->d_sb, 2); inode = njbfs_iget(dir->i_sb, &fattr); ! if (inode) { dentry->d_op = &njbfs_dentry_operations; d_add(dentry, inode); *************** *** 240,251 **** } ! static int ! njbfs_instantiate(struct dentry* dentry) { ! struct njbfs_sb_info *info = (struct njbfs_sb_info*)dentry->d_sb->u.generic_sbp; struct njbfs_fattr fattr; struct inode *inode; ! if(njbfs_get_attr(dentry, &fattr, info) < 0){ info("njbfs_get_attr failed"); return -1; --- 246,257 ---- } ! static int njbfs_instantiate(struct dentry *dentry) { ! struct njbfs_sb_info *info = ! (struct njbfs_sb_info *) dentry->d_sb->u.generic_sbp; struct njbfs_fattr fattr; struct inode *inode; ! if (njbfs_get_attr(dentry, &fattr, info) < 0) { info("njbfs_get_attr failed"); return -1; *************** *** 254,258 **** fattr.f_ino = iunique(dentry->d_sb, 2); inode = njbfs_iget(dentry->d_sb, &fattr); ! if(!inode) return -EACCES; --- 260,264 ---- fattr.f_ino = iunique(dentry->d_sb, 2); inode = njbfs_iget(dentry->d_sb, &fattr); ! if (!inode) return -EACCES; *************** *** 262,274 **** } ! static int ! njbfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) { ! struct njbfs_sb_info *info = (struct njbfs_sb_info*)dentry->d_sb->u.generic_sbp; char buf[NJBFS_MAXPATHLEN]; int res; njbfs_get_name(dentry, buf); ! if((res = njbfs_proc_mkdir(info, buf)) < 0){ err("mkdir failed"); return res; --- 268,280 ---- } ! static int njbfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) { ! struct njbfs_sb_info *info = ! (struct njbfs_sb_info *) dentry->d_sb->u.generic_sbp; char buf[NJBFS_MAXPATHLEN]; int res; njbfs_get_name(dentry, buf); ! if ((res = njbfs_proc_mkdir(info, buf)) < 0) { err("mkdir failed"); return res; *************** *** 278,290 **** } ! static int ! njbfs_create(struct inode* dir, struct dentry *dentry, int mode) { ! struct njbfs_sb_info *info = (struct njbfs_sb_info*)dentry->d_sb->u.generic_sbp; char buf[NJBFS_MAXPATHLEN]; int res; njbfs_get_name(dentry, buf); ! if((res = njbfs_proc_create(info, buf)) < 0){ err("create failed"); return res; --- 284,296 ---- } ! static int njbfs_create(struct inode *dir, struct dentry *dentry, int mode) { ! struct njbfs_sb_info *info = ! (struct njbfs_sb_info *) dentry->d_sb->u.generic_sbp; char buf[NJBFS_MAXPATHLEN]; int res; njbfs_get_name(dentry, buf); ! if ((res = njbfs_proc_create(info, buf)) < 0) { err("create failed"); return res; *************** *** 295,305 **** } ! static int ! njbfs_rmdir(struct inode* dir, struct dentry *dentry) { ! struct njbfs_sb_info *info = (struct njbfs_sb_info*)dentry->d_sb->u.generic_sbp; char buf[NJBFS_MAXPATHLEN]; ! if(!d_unhashed(dentry)) return -EBUSY; --- 301,311 ---- } ! static int njbfs_rmdir(struct inode *dir, struct dentry *dentry) { ! struct njbfs_sb_info *info = ! (struct njbfs_sb_info *) dentry->d_sb->u.generic_sbp; char buf[NJBFS_MAXPATHLEN]; ! if (!d_unhashed(dentry)) return -EBUSY; *************** *** 313,319 **** static int njbfs_rename(struct inode *old_dir, struct dentry *old_dentry, ! struct inode *new_dir, struct dentry *new_dentry) { ! struct njbfs_sb_info *info = (struct njbfs_sb_info*)old_dentry->d_sb->u.generic_sbp; int res; --- 319,326 ---- static int njbfs_rename(struct inode *old_dir, struct dentry *old_dentry, ! struct inode *new_dir, struct dentry *new_dentry) { ! struct njbfs_sb_info *info = ! (struct njbfs_sb_info *) old_dentry->d_sb->u.generic_sbp; int res; *************** *** 322,327 **** } ! if((res = njbfs_proc_rename(info, old_dir, old_dentry, new_dir, new_dentry)) < 0) ! return res; njbfs_cache_invalidate(old_dentry->d_parent); --- 329,336 ---- } ! if ( ! (res = ! njbfs_proc_rename(info, old_dir, old_dentry, new_dir, ! new_dentry)) < 0) return res; njbfs_cache_invalidate(old_dentry->d_parent); *************** *** 331,338 **** } ! static int ! njbfs_unlink(struct inode *dir, struct dentry *dentry) { ! struct njbfs_sb_info *info = (struct njbfs_sb_info*)dentry->d_sb->u.generic_sbp; char buf[NJBFS_MAXPATHLEN]; --- 340,347 ---- } ! static int njbfs_unlink(struct inode *dir, struct dentry *dentry) { ! struct njbfs_sb_info *info = ! (struct njbfs_sb_info *) dentry->d_sb->u.generic_sbp; char buf[NJBFS_MAXPATHLEN]; *************** *** 341,343 **** return njbfs_proc_unlink(info, buf); } - --- 350,351 ---- Index: driver.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/driver.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** driver.c 13 Nov 2001 00:56:05 -0000 1.2 --- driver.c 10 Feb 2002 21:59:23 -0000 1.3 *************** *** 30,34 **** #include <linux/fs.h> #include <linux/usb.h> ! #include <linux/proc_fs.h> /* /proc filesystem */ #include <asm/system.h> #include <asm/uaccess.h> --- 30,34 ---- #include <linux/fs.h> #include <linux/usb.h> ! #include <linux/proc_fs.h> /* /proc filesystem */ #include <asm/system.h> #include <asm/uaccess.h> *************** *** 45,49 **** /* njb_usb */ ! extern int njb_usb_ping(struct nomad_usb_data *nomad, njbid_t *njbid); static struct proc_dir_entry *proc_entry = NULL; --- 45,49 ---- /* njb_usb */ ! extern int njb_usb_ping(struct nomad_usb_data *nomad, njbid_t * njbid); static struct proc_dir_entry *proc_entry = NULL; *************** *** 55,123 **** static int njb_read_proc_driver(char *page, char **start, off_t off, ! int count, int *eof, void *data) { ! char *out = page; ! int len; ! struct nomad_usb_data *nomad = (struct nomad_usb_data *)data; ! njbid_t njbid; ! int status; ! int i; ! out += sprintf(out, "Nomad Jukebox Driver Status\n"); ! out += sprintf(out, "---------------------------\n"); ! out += sprintf(out, "NJB File System Version : %s\n", NJBFS_VERSION); ! if (!nomad) { ! err("no data"); ! goto out; ! } ! out += sprintf(out, "Connected : %s\n", CHECK(nomad->present) ); ! if (nomad->present) { ! /* ping device */ ! status = njb_usb_ping(nomad, &njbid); ! if (status == 0) { ! out += sprintf(out, "Jukebox ID : "); ! for (i = 0; i < 16; i++) { ! out += sprintf(out, "%02x ", njbid.id[i]); ! } ! out += sprintf(out, "\nFirmware : %d.%d\n", ! njbid.fwMajor, njbid.fwMinor ); ! out += sprintf(out, "Product Name : %s\n", njbid.productName ); ! switch (njbid.power) { ! case NJB_POWER_BATTERY: ! out += sprintf(out, "Power : battery\n"); ! break; ! case NJB_POWER_AC_CHARGED: ! out += sprintf(out, "Power : AC charged\n"); ! break; ! case NJB_POWER_AC_CHARGING: ! out += sprintf(out, "Power : AC charging\n"); ! break; ! default: ! out += sprintf(out, "Power : ?\n"); ! break; ! } ! } ! else { ! out += sprintf(out, "Can't ping, status = %d\n", status ); ! } ! } ! out: ! len = out - page; ! len -= off; ! if (len < count) { ! *eof = 1; ! if (len <= 0) ! return 0; ! } ! else len = count; ! *start = page + off; ! return len; } --- 55,134 ---- static int njb_read_proc_driver(char *page, char **start, off_t off, ! int count, int *eof, void *data) { ! char *out = page; ! int len; ! struct nomad_usb_data *nomad = (struct nomad_usb_data *) data; ! njbid_t njbid; ! int status; ! int i; ! out += sprintf(out, "Nomad Jukebox Driver Status\n"); ! out += sprintf(out, "---------------------------\n"); ! out += ! sprintf(out, "NJB File System Version : %s\n", NJBFS_VERSION); ! if (!nomad) { ! err("no data"); ! goto out; ! } ! out += sprintf(out, "Connected : %s\n", CHECK(nomad->present)); ! if (nomad->present) { ! /* ping device */ ! status = njb_usb_ping(nomad, &njbid); ! if (status == 0) { ! out += sprintf(out, "Jukebox ID : "); ! for (i = 0; i < 16; i++) { ! out += sprintf(out, "%02x ", njbid.id[i]); ! } ! out += sprintf(out, "\nFirmware : %d.%d\n", ! njbid.fwMajor, njbid.fwMinor); ! out += ! sprintf(out, "Product Name : %s\n", ! njbid.productName); ! switch (njbid.power) { ! case NJB_POWER_BATTERY: ! out += ! sprintf(out, ! "Power : battery\n"); ! break; ! case NJB_POWER_AC_CHARGED: ! out += ! sprintf(out, ! "Power : AC charged\n"); ! break; ! case NJB_POWER_AC_CHARGING: ! out += ! sprintf(out, ! "Power : AC charging\n"); ! break; ! default: ! out += ! sprintf(out, "Power : ?\n"); ! break; ! } ! } else { ! out += ! sprintf(out, "Can't ping, status = %d\n", ! status); ! } ! } ! out: ! len = out - page; ! len -= off; ! if (len < count) { ! *eof = 1; ! if (len <= 0) ! return 0; ! } else ! len = count; ! *start = page + off; ! return len; } *************** *** 129,174 **** static int proc_njb_create(struct nomad_usb_data *nomad) { ! if (!nomad) ! return -1; ! proc_dir = create_proc_entry("njb", S_IFDIR, proc_entry); ! if (proc_dir == NULL) { ! err("proc_njb_create: could not create/proc/njb entry"); ! return -1; ! } ! info("/proc/njb created"); ! if (proc_entry != NULL) ! proc_entry->owner = THIS_MODULE; ! proc_driver = create_proc_read_entry("driver", ! S_IFREG|S_IRUGO|S_IWUSR, proc_dir, ! njb_read_proc_driver, nomad); ! if (!proc_driver) { ! err("proc_njb_create: could not create /proc/njb/driver entry"); ! return -1; ! } ! info("/proc/njb/driver created"); ! return 0; } static void proc_njb_destroy() { ! if (!proc_driver) ! return; ! remove_proc_entry("driver", proc_dir); ! proc_driver = NULL; ! if (!proc_dir) { ! err("proc_njb_destroy: could not destroy /proc/njb"); ! return; ! } ! remove_proc_entry("njb", proc_entry); ! proc_dir = NULL; ! return; } --- 140,187 ---- static int proc_njb_create(struct nomad_usb_data *nomad) { ! if (!nomad) ! return -1; ! proc_dir = create_proc_entry("njb", S_IFDIR, proc_entry); ! if (proc_dir == NULL) { ! err("proc_njb_create: could not create/proc/njb entry"); ! return -1; ! } ! info("/proc/njb created"); ! if (proc_entry != NULL) ! proc_entry->owner = THIS_MODULE; ! proc_driver = create_proc_read_entry("driver", ! S_IFREG | S_IRUGO | S_IWUSR, ! proc_dir, ! njb_read_proc_driver, nomad); ! if (!proc_driver) { ! err ! ("proc_njb_create: could not create /proc/njb/driver entry"); ! return -1; ! } ! info("/proc/njb/driver created"); ! return 0; } static void proc_njb_destroy() { ! if (!proc_driver) ! return; ! remove_proc_entry("driver", proc_dir); ! proc_driver = NULL; ! if (!proc_dir) { ! err("proc_njb_destroy: could not destroy /proc/njb"); ! return; ! } ! remove_proc_entry("njb", proc_entry); ! proc_dir = NULL; ! return; } *************** *** 176,178 **** EXPORT_SYMBOL(proc_njb_destroy); ! #endif \ No newline at end of file --- 189,191 ---- EXPORT_SYMBOL(proc_njb_destroy); ! #endif Index: file.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/file.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** file.c 4 Nov 2001 13:46:00 -0000 1.1.1.1 --- file.c 10 Feb 2002 21:59:23 -0000 1.2 *************** *** 40,45 **** extern int njbfs_close(struct inode *inode, struct file *file); ! static int ! njbfs_file_readpage(struct file *f, struct page *p) { struct dentry *dentry = f->f_dentry; --- 40,44 ---- extern int njbfs_close(struct inode *inode, struct file *file); ! static int njbfs_file_readpage(struct file *f, struct page *p) { struct dentry *dentry = f->f_dentry; *************** *** 54,60 **** count = PAGE_SIZE; ! do{ result = njbfs_read(dentry, offset, count, buffer); ! if(result < 0){ err("read error"); goto io_error; --- 53,59 ---- count = PAGE_SIZE; ! do { result = njbfs_read(dentry, offset, count, buffer); ! if (result < 0) { err("read error"); goto io_error; *************** *** 64,69 **** buffer += result; dentry->d_inode->i_atime = CURRENT_TIME; ! if(!result) break; ! }while(count); memset(buffer, 0, count); --- 63,69 ---- buffer += result; dentry->d_inode->i_atime = CURRENT_TIME; ! if (!result) ! break; ! } while (count); memset(buffer, 0, count); *************** *** 71,92 **** SetPageUptodate(p); result = 0; ! io_error: UnlockPage(p); put_page(p); ! switch(result){ ! case -ERESTARTSYS: ! if(sigismember(¤t->pending.signal, SIGPIPE)){ ! sigdelset(¤t->pending.signal, SIGPIPE); ! current->sigpending--; ! } ! result = -EINTR; ! break; } return result; } ! static int ! njbfs_file_writepage(struct page *p) { dbg("This shouldn't happen"); --- 71,91 ---- SetPageUptodate(p); result = 0; ! io_error: UnlockPage(p); put_page(p); ! switch (result) { ! case -ERESTARTSYS: ! if (sigismember(¤t->pending.signal, SIGPIPE)) { ! sigdelset(¤t->pending.signal, SIGPIPE); ! current->sigpending--; ! } ! result = -EINTR; ! break; } return result; } ! static int njbfs_file_writepage(struct page *p) { dbg("This shouldn't happen"); *************** *** 95,99 **** static int ! njbfs_file_preparewrite(struct file *f, struct page *p, unsigned offset, unsigned to) { kmap(p); --- 94,99 ---- static int ! njbfs_file_preparewrite(struct file *f, struct page *p, unsigned offset, ! unsigned to) { kmap(p); *************** *** 102,106 **** static int ! njbfs_file_commitwrite(struct file *f, struct page *p, unsigned offset, unsigned to) { struct dentry *dentry = f->f_dentry; --- 102,107 ---- static int ! njbfs_file_commitwrite(struct file *f, struct page *p, unsigned offset, ! unsigned to) { struct dentry *dentry = f->f_dentry; *************** *** 113,119 **** lock_kernel(); ! do{ result = njbfs_write(dentry, offset, count, buffer); ! if(result < 0){ err("write error"); goto error; --- 114,120 ---- lock_kernel(); ! do { result = njbfs_write(dentry, offset, count, buffer); ! if (result < 0) { err("write error"); goto error; *************** *** 124,148 **** buffer += result; written += result; ! dentry->d_inode->i_mtime = dentry->d_inode->i_atime = CURRENT_TIME; ! if(!result) break; ! }while(count); memset(buffer, 0, count); result = 0; ! error: unlock_kernel(); kunmap(p); ! switch(result){ ! case -ERESTARTSYS: ! if(sigismember(¤t->pending.signal, SIGPIPE)){ ! sigdelset(¤t->pending.signal, SIGPIPE); ! current->sigpending--; ! } ! result = -EINTR; ! break; } --- 125,150 ---- buffer += result; written += result; ! dentry->d_inode->i_mtime = dentry->d_inode->i_atime = ! CURRENT_TIME; ! if (!result) break; ! } while (count); memset(buffer, 0, count); result = 0; ! error: unlock_kernel(); kunmap(p); ! switch (result) { ! case -ERESTARTSYS: ! if (sigismember(¤t->pending.signal, SIGPIPE)) { ! sigdelset(¤t->pending.signal, SIGPIPE); ! current->sigpending--; ! } ! result = -EINTR; ! break; } *************** *** 150,193 **** } ! static int ! njbfs_file_permission(struct inode *inode, int mask) { int mode = inode->i_mode; mode >>= 6; ! if((mode & 7 & mask) != mask) return -EACCES; return 0; } ! static int ! njbfs_file_open(struct inode *inode, struct file *f) ! { ! return njbfs_open(inode, f); } ! static int ! njbfs_file_release(struct inode *inode, struct file *f) { ! return njbfs_close(inode, f); } struct file_operations njbfs_file_operations = { ! read: generic_file_read, ! write: generic_file_write, ! mmap: generic_file_mmap, ! open: njbfs_file_open, ! release: njbfs_file_release, }; struct inode_operations njbfs_file_inode_operations = { ! permission: njbfs_file_permission, }; struct address_space_operations njbfs_file_aops = { ! readpage: njbfs_file_readpage, ! writepage: njbfs_file_writepage, ! prepare_write: njbfs_file_preparewrite, ! commit_write: njbfs_file_commitwrite }; - --- 152,191 ---- } ! static int njbfs_file_permission(struct inode *inode, int mask) { int mode = inode->i_mode; mode >>= 6; ! if ((mode & 7 & mask) != mask) return -EACCES; return 0; } ! static int njbfs_file_open(struct inode *inode, struct file *f) ! { ! return njbfs_open(inode, f); } ! static int njbfs_file_release(struct inode *inode, struct file *f) { ! return njbfs_close(inode, f); } struct file_operations njbfs_file_operations = { ! read:generic_file_read, ! write:generic_file_write, ! mmap:generic_file_mmap, ! open:njbfs_file_open, ! release:njbfs_file_release, }; struct inode_operations njbfs_file_inode_operations = { ! permission:njbfs_file_permission, }; struct address_space_operations njbfs_file_aops = { ! readpage:njbfs_file_readpage, ! writepage:njbfs_file_writepage, ! prepare_write:njbfs_file_preparewrite, ! commit_write:njbfs_file_commitwrite }; Index: inode.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/inode.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** inode.c 10 Feb 2002 20:07:45 -0000 1.4 --- inode.c 10 Feb 2002 21:59:23 -0000 1.5 *************** *** 40,44 **** MODULE_DESCRIPTION("USB Nomad Jukebox File System for Linux"); #ifdef MODULE_LICENSE ! MODULE_LICENSE("GPL"); #endif --- 40,44 ---- MODULE_DESCRIPTION("USB Nomad Jukebox File System for Linux"); #ifdef MODULE_LICENSE ! MODULE_LICENSE("GPL"); #endif *************** *** 61,74 **** extern struct inode_operations njbfs_symlink_inode_operations; ! static void njbfs_delete_inode(struct inode*); ! static void njbfs_put_super(struct super_block*); ! static int njbfs_statfs(struct super_block*, struct statfs*); ! static void njbfs_set_inode_attr(struct inode*, struct njbfs_fattr*); static struct super_operations njbfs_sops = { ! put_inode: force_delete, ! delete_inode: njbfs_delete_inode, ! put_super: njbfs_put_super, ! statfs: njbfs_statfs, }; --- 61,74 ---- extern struct inode_operations njbfs_symlink_inode_operations; ! static void njbfs_delete_inode(struct inode *); ! static void njbfs_put_super(struct super_block *); ! static int njbfs_statfs(struct super_block *, struct statfs *); ! static void njbfs_set_inode_attr(struct inode *, struct njbfs_fattr *); static struct super_operations njbfs_sops = { ! put_inode:force_delete, ! delete_inode:njbfs_delete_inode, ! put_super:njbfs_put_super, ! statfs:njbfs_statfs, }; *************** *** 76,93 **** struct inode *njbfs_iget(struct super_block *sb, struct njbfs_fattr *fattr) { ! struct inode *res; ! res = new_inode(sb); ! if (!res) ! return NULL; ! res->i_ino = fattr->f_ino; ! njbfs_set_inode_attr(res, fattr); ! if(S_ISDIR(res->i_mode)){ res->i_op = &njbfs_dir_inode_operations; res->i_fop = &njbfs_dir_operations;; ! }else if(S_ISLNK(res->i_mode)){ res->i_op = &njbfs_symlink_inode_operations; ! }else{ res->i_op = &njbfs_file_inode_operations; res->i_fop = &njbfs_file_operations; --- 76,93 ---- struct inode *njbfs_iget(struct super_block *sb, struct njbfs_fattr *fattr) { ! struct inode *res; ! res = new_inode(sb); ! if (!res) ! return NULL; ! res->i_ino = fattr->f_ino; ! njbfs_set_inode_attr(res, fattr); ! if (S_ISDIR(res->i_mode)) { res->i_op = &njbfs_dir_inode_operations; res->i_fop = &njbfs_dir_operations;; ! } else if (S_ISLNK(res->i_mode)) { res->i_op = &njbfs_symlink_inode_operations; ! } else { res->i_op = &njbfs_file_inode_operations; res->i_fop = &njbfs_file_operations; *************** *** 102,121 **** njbfs_set_inode_attr(struct inode *inode, struct njbfs_fattr *fattr) { ! inode->i_mode = fattr->f_mode; ! inode->i_nlink = fattr->f_nlink; ! inode->i_uid = fattr->f_uid; ! inode->i_gid = fattr->f_gid; ! inode->i_rdev = fattr->f_rdev; ! inode->i_ctime = fattr->f_ctime; ! inode->i_atime = fattr->f_atime; ! inode->i_mtime = fattr->f_mtime; ! inode->i_blksize= fattr->f_blksize; ! inode->i_blocks = fattr->f_blocks; ! inode->i_size = fattr->f_size; } ! static void ! njbfs_delete_inode(struct inode *inode) { lock_kernel(); --- 102,120 ---- njbfs_set_inode_attr(struct inode *inode, struct njbfs_fattr *fattr) { ! inode->i_mode = fattr->f_mode; ! inode->i_nlink = fattr->f_nlink; ! inode->i_uid = fattr->f_uid; ! inode->i_gid = fattr->f_gid; ! inode->i_rdev = fattr->f_rdev; ! inode->i_ctime = fattr->f_ctime; ! inode->i_atime = fattr->f_atime; ! inode->i_mtime = fattr->f_mtime; ! inode->i_blksize = fattr->f_blksize; ! inode->i_blocks = fattr->f_blocks; ! inode->i_size = fattr->f_size; } ! static void njbfs_delete_inode(struct inode *inode) { lock_kernel(); *************** *** 124,131 **** } ! static void ! njbfs_put_super(struct super_block *sb) { ! struct njbfs_sb_info *info = (struct njbfs_sb_info*)sb->u.generic_sbp; njbfs_disconnect(info); --- 123,130 ---- } ! static void njbfs_put_super(struct super_block *sb) { ! struct njbfs_sb_info *info = ! (struct njbfs_sb_info *) sb->u.generic_sbp; njbfs_disconnect(info); *************** *** 135,140 **** } ! static int ! njbfs_statfs(struct super_block *sb, struct statfs *attr) { attr->f_type = NJBFS_SUPER_MAGIC; --- 134,138 ---- } ! static int njbfs_statfs(struct super_block *sb, struct statfs *attr) { attr->f_type = NJBFS_SUPER_MAGIC; *************** *** 148,160 **** } ! struct super_block* ! njbfs_read_super(struct super_block *sb, void *opts, int silent) { ! struct njbfs_sb_info *info; struct njbfs_fattr root; struct inode *root_inode; ! info = (struct njbfs_sb_info*)kmalloc(sizeof(struct njbfs_sb_info), GFP_KERNEL); ! if(!info){ info("not enough kmem to allocate info"); goto out; --- 146,160 ---- } ! struct super_block *njbfs_read_super(struct super_block *sb, void *opts, ! int silent) { ! struct njbfs_sb_info *info; struct njbfs_fattr root; struct inode *root_inode; ! info = ! (struct njbfs_sb_info *) kmalloc(sizeof(struct njbfs_sb_info), ! GFP_KERNEL); ! if (!info) { info("not enough kmem to allocate info"); goto out; *************** *** 175,184 **** info->mnt.gid = current->gid; ! info->njb = &nomad_instance; ! info->virtual_mode = 0; ! strcpy(info->virtual_dir, ""); ! init_MUTEX(&info->sem); info->mnt.mount_point[0] = 0; --- 175,184 ---- info->mnt.gid = current->gid; ! info->njb = &nomad_instance; ! info->virtual_mode = 0; ! strcpy(info->virtual_dir, ""); ! init_MUTEX(&info->sem); info->mnt.mount_point[0] = 0; *************** *** 201,205 **** goto out_no_root; ! sb->s_root = d_alloc_root(root_inode); if (!sb->s_root) goto out_no_root; --- 201,205 ---- goto out_no_root; ! sb->s_root = d_alloc_root(root_inode); if (!sb->s_root) goto out_no_root; *************** *** 208,221 **** return sb; ! out_no_root: iput(root_inode); ! out_no_opts: kfree(info); ! out: dbg("mount failed"); return NULL; } ! static DECLARE_FSTYPE (njbfs_fs_type, "njbfs", njbfs_read_super, 0); --- 208,221 ---- return sb; ! out_no_root: iput(root_inode); ! out_no_opts: kfree(info); ! out: dbg("mount failed"); return NULL; } ! static DECLARE_FSTYPE(njbfs_fs_type, "njbfs", njbfs_read_super, 0); *************** *** 223,239 **** static int init_njb_module(void) { ! int ret; ! ret = usb_nomad_init(); ! if (ret < 0) ! return ret; #if defined(CONFIG_PROC_FS) ! ret = proc_njb_create( &nomad_instance ); ! if (ret < 0) ! return ret; #endif ! return register_filesystem(&njbfs_fs_type); } --- 223,239 ---- static int init_njb_module(void) { ! int ret; ! ret = usb_nomad_init(); ! if (ret < 0) ! return ret; #if defined(CONFIG_PROC_FS) ! ret = proc_njb_create(&nomad_instance); ! if (ret < 0) ! return ret; #endif ! return register_filesystem(&njbfs_fs_type); } *************** *** 242,250 **** unregister_filesystem(&njbfs_fs_type); #if defined(CONFIG_PROC_FS) ! proc_njb_destroy(); #endif ! usb_nomad_cleanup(); ! return; } --- 242,250 ---- unregister_filesystem(&njbfs_fs_type); #if defined(CONFIG_PROC_FS) ! proc_njb_destroy(); #endif ! usb_nomad_cleanup(); ! return; } Index: njb_usb.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/njb_usb.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** njb_usb.c 10 Feb 2002 20:03:03 -0000 1.3 --- njb_usb.c 10 Feb 2002 21:59:23 -0000 1.4 *************** *** 44,54 **** static int njb_usb_connect(struct nomad_usb_data *nomad); static int njb_usb_disconnect(struct nomad_usb_data *nomad); ! static int njb_usb_open(struct nomad_usb_data *nomad, struct njbfs_fattr *fattr); ! static int njb_usb_close(struct nomad_usb_data *nomad, struct njbfs_fattr *fattr); static int njb_usb_write(struct nomad_usb_data *nomad, char *name, ! u_int32_t offset, u_int32_t count, void *buffer); static int njb_usb_read(struct nomad_usb_data *nomad, char *name, ! u_int32_t offset, u_int32_t count, void *buffer); ! static int njb_usb_rename(struct nomad_usb_data *nomad, struct njbfs_fattr *fattr); static int njb_usb_delete(struct nomad_usb_data *nomad, char *file); [...2679 lines suppressed...] --- 1609,1627 ---- void dump_data(unsigned char *data, int count) { ! unsigned char *ptr; ! unsigned char buf[50]; ! unsigned char chars[18]; ! int x, y; ! ptr = data; ! for (y = 0; y < count; y += 16) { ! for (x = 0; x < 16 && x < count; x++) { ! sprintf(&buf[x * 3], "%02x ", *ptr); ! chars[x] = isalnum(*ptr) ? *ptr : '.'; ! ptr++; ! } ! chars[16] = '\0'; ! info("dump: %s %s", buf, chars); ! } } #endif Index: njbfs.h =================================================================== RCS file: /cvsroot/njbfs/njbfs/njbfs.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** njbfs.h 4 Dec 2001 21:09:31 -0000 1.3 --- njbfs.h 10 Feb 2002 21:59:23 -0000 1.4 *************** *** 17,22 **** #define NJBFS_MAXVIRTUALDIRLEN 32 ! #define NJBFS_BLOCKSIZE 4096 /* max 4096 */ ! #define NJBFS_BLOCKSIZE_BITS 12 /* 2^x = blocksize */ struct njbfs_mount_data { --- 17,22 ---- #define NJBFS_MAXVIRTUALDIRLEN 32 ! #define NJBFS_BLOCKSIZE 4096 /* max 4096 */ ! #define NJBFS_BLOCKSIZE_BITS 12 /* 2^x = blocksize */ struct njbfs_mount_data { *************** *** 27,31 **** __kernel_mode_t file_mode; __kernel_mode_t dir_mode; ! char root[NJBFS_MAXPATHLEN]; /* root directory */ char mount_point[NJBFS_MAXPATHLEN]; }; --- 27,31 ---- __kernel_mode_t file_mode; __kernel_mode_t dir_mode; ! char root[NJBFS_MAXPATHLEN]; /* root directory */ char mount_point[NJBFS_MAXPATHLEN]; }; *************** *** 40,72 **** struct semaphore sem; struct njbfs_dir_cache cache; ! struct nomad_usb_data *njb; ! int virtual_mode; ! char virtual_dir[NJBFS_MAXVIRTUALDIRLEN]; }; struct njbfs_fattr { ! unsigned long f_ino; ! umode_t f_mode; ! nlink_t f_nlink; ! uid_t f_uid; ! gid_t f_gid; ! kdev_t f_rdev; ! off_t f_size; ! time_t f_atime; ! time_t f_mtime; ! time_t f_ctime; ! unsigned long f_blksize; ! unsigned long f_blocks; ! u_int32_t fileid; /* file id of the NJB */ ! /* file name parsing */ ! u_int32_t size; /* size */ ! char *codec; /* codec frame */ ! char *title; /* title frame */ ! char *artist; /* artist frame */ ! char *album; /* album frame */ ! char *genre; /* genre frame */ ! u_int32_t length; /* optional frame: length in seconds */ ! u_int32_t tracknum; /* optional frame: album track number */ ! track_t *track; /* track */ }; --- 40,72 ---- struct semaphore sem; struct njbfs_dir_cache cache; ! struct nomad_usb_data *njb; ! int virtual_mode; ! char virtual_dir[NJBFS_MAXVIRTUALDIRLEN]; }; struct njbfs_fattr { ! unsigned long f_ino; ! umode_t f_mode; ! nlink_t f_nlink; ! uid_t f_uid; ! gid_t f_gid; ! kdev_t f_rdev; ! off_t f_size; ! time_t f_atime; ! time_t f_mtime; ! time_t f_ctime; ! unsigned long f_blksize; ! unsigned long f_blocks; ! u_int32_t fileid; /* file id of the NJB */ ! /* file name parsing */ ! u_int32_t size; /* size */ ! char *codec; /* codec frame */ ! char *title; /* title frame */ ! char *artist; /* artist frame */ ! char *album; /* album frame */ ! char *genre; /* genre frame */ ! u_int32_t length; /* optional frame: length in seconds */ ! u_int32_t tracknum; /* optional frame: album track number */ ! track_t *track; /* track */ }; Index: njbfs_cache.h =================================================================== RCS file: /cvsroot/njbfs/njbfs/njbfs_cache.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** njbfs_cache.h 4 Dec 2001 21:09:31 -0000 1.3 --- njbfs_cache.h 10 Feb 2002 21:59:23 -0000 1.4 *************** *** 78,83 **** typedef struct track_struct { ! njbttaghdr_t header; ! u_int16_t nframes; track_frame_t *first; track_frame_t *last; --- 78,83 ---- typedef struct track_struct { ! njbttaghdr_t header; ! u_int16_t nframes; track_frame_t *first; track_frame_t *last; *************** *** 119,133 **** unsigned long blocks; time_t atime; ! u_int32_t fileid; /* the NJB file id*/ ! /* NJB attributes */ ! char *codec; /* codec frame */ ! char *title; /* title frame */ ! char *artist; /* artist frame */ ! char *album; /* album frame */ ! char *genre; /* genre frame */ ! u_int32_t length; /* optional frame: length in seconds */ ! u_int32_t tracknum; /* optional frame: album track number */ ! track_t *track; /* track */ ! int update_track_tag; /* should track tag be updated? 1=yes 0=no */ }; --- 119,133 ---- unsigned long blocks; time_t atime; ! u_int32_t fileid; /* the NJB file id */ ! /* NJB attributes */ ! char *codec; /* codec frame */ ! char *title; /* title frame */ ! char *artist; /* artist frame */ ! char *album; /* album frame */ ! char *genre; /* genre frame */ ! u_int32_t length; /* optional frame: length in seconds */ ! u_int32_t tracknum; /* optional frame: album track number */ ! track_t *track; /* track */ ! int update_track_tag; /* should track tag be updated? 1=yes 0=no */ }; *************** *** 139,143 **** struct njbfs_directory { struct njbfs_dirlist_node *head; ! int valid; time_t time; char *name; --- 139,143 ---- struct njbfs_directory { struct njbfs_dirlist_node *head; ! int valid; time_t time; char *name; *************** *** 146,150 **** struct njbfs_hashlist_node { struct njbfs_hashlist_node *prev, *next; ! struct njbfs_directory directory; }; --- 146,150 ---- struct njbfs_hashlist_node { struct njbfs_hashlist_node *prev, *next; ! struct njbfs_directory directory; }; *************** *** 156,163 **** struct njbfs_sb_info; ! void njbfs_cache_init(struct njbfs_sb_info*); ! int njbfs_cache_empty(struct njbfs_sb_info*); ! int njbfs_cache_get(struct njbfs_sb_info*, char*, struct njbfs_directory**); ! void njbfs_cache_invalidate(struct dentry*); #endif --- 156,164 ---- struct njbfs_sb_info; ! void njbfs_cache_init(struct njbfs_sb_info *); ! int njbfs_cache_empty(struct njbfs_sb_info *); ! int njbfs_cache_get(struct njbfs_sb_info *, char *, ! struct njbfs_directory **); ! void njbfs_cache_invalidate(struct dentry *); #endif Index: njbfs_proc.h =================================================================== RCS file: /cvsroot/njbfs/njbfs/njbfs_proc.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** njbfs_proc.h 4 Dec 2001 21:09:31 -0000 1.2 --- njbfs_proc.h 10 Feb 2002 21:59:23 -0000 1.3 *************** *** 6,24 **** void njbfs_init_root_dirent(struct njbfs_sb_info *, struct njbfs_fattr *); int njbfs_parse_options(struct njbfs_sb_info *, void *); ! int njbfs_connect(struct njbfs_sb_info*); ! void njbfs_disconnect(struct njbfs_sb_info*); ! int njbfs_loaddir(struct njbfs_sb_info*, char*, struct njbfs_directory*); ! int njbfs_get_name(struct dentry*, char*); ! inline void njbfs_lock(struct njbfs_sb_info*); ! inline void njbfs_unlock(struct njbfs_sb_info*); ! int njbfs_get_attr(struct dentry*, struct njbfs_fattr*, struct njbfs_sb_info*); ! struct inode* njbfs_iget(struct super_block*, struct njbfs_fattr*); ! int njbfs_read(struct dentry*, unsigned long, unsigned long, char*); ! int njbfs_proc_mkdir(struct njbfs_sb_info*, char*); ! int njbfs_proc_rmdir(struct njbfs_sb_info*, char*); ! int njbfs_proc_rename(struct njbfs_sb_info*, struct inode*, struct dentry*, struct inode*, struct dentry*); ! int njbfs_proc_unlink(struct njbfs_sb_info*, char*); ! int njbfs_proc_create(struct njbfs_sb_info*, char*); ! int njbfs_write(struct dentry*, unsigned long, unsigned long, char*); #endif --- 6,27 ---- void njbfs_init_root_dirent(struct njbfs_sb_info *, struct njbfs_fattr *); int njbfs_parse_options(struct njbfs_sb_info *, void *); ! int njbfs_connect(struct njbfs_sb_info *); ! void njbfs_disconnect(struct njbfs_sb_info *); ! int njbfs_loaddir(struct njbfs_sb_info *, char *, ! struct njbfs_directory *); ! int njbfs_get_name(struct dentry *, char *); ! inline void njbfs_lock(struct njbfs_sb_info *); ! inline void njbfs_unlock(struct njbfs_sb_info *); ! int njbfs_get_attr(struct dentry *, struct njbfs_fattr *, ! struct njbfs_sb_info *); ! struct inode *njbfs_iget(struct super_block *, struct njbfs_fattr *); ! int njbfs_read(struct dentry *, unsigned long, unsigned long, char *); ! int njbfs_proc_mkdir(struct njbfs_sb_info *, char *); ! int njbfs_proc_rmdir(struct njbfs_sb_info *, char *); ! int njbfs_proc_rename(struct njbfs_sb_info *, struct inode *, ! struct dentry *, struct inode *, struct dentry *); ! int njbfs_proc_unlink(struct njbfs_sb_info *, char *); ! int njbfs_proc_create(struct njbfs_sb_info *, char *); ! int njbfs_write(struct dentry *, unsigned long, unsigned long, char *); #endif Index: nomad.c =================================================================== RCS file: /cvsroot/njbfs/njbfs/nomad.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** nomad.c 4 Dec 2001 21:09:31 -0000 1.2 --- nomad.c 10 Feb 2002 21:59:23 -0000 1.3 *************** *** 64,69 **** static struct nomad_usb_data nomad_instance; ! static int ! open_nomad(struct inode *inode, struct file *file) { struct nomad_usb_data *nomad = &nomad_instance; --- 64,68 ---- static struct nomad_usb_data nomad_instance; ! static int open_nomad(struct inode *inode, struct file *file) { struct nomad_usb_data *nomad = &nomad_instance; *************** *** 72,76 **** if (nomad->isopen || !nomad->present) { ! unlock_kernel(); return -EBUSY; } --- 71,75 ---- if (nomad->isopen || !nomad->present) { ! unlock_kernel(); return -EBUSY; } *************** *** 89,94 **** } ! static int ! close_nomad(struct inode *inode, struct file *file) { struct nomad_usb_data *nomad = &nomad_instance; --- 88,92 ---- } ! static int close_nomad(struct inode *inode, struct file *file) { struct nomad_usb_data *nomad = &nomad_instance; *************** *** 103,109 **** static int ! ioctl_nomad(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { ! struct Nomad_cmd nomad_cmd; struct nomad_usb_data *nomad = &nomad_instance; void *data; --- 101,108 ---- static int ! ioctl_nomad(struct inode *inode, struct file *file, unsigned int cmd, ! unsigned long arg) { ! struct Nomad_cmd nomad_cmd; struct nomad_usb_data *nomad = &nomad_instance; void *data; *************** *** 115,122 **** /* Sanity check to make sure Nomad is connected, powered, etc */ ! if ( nomad == NULL || ! nomad->present == 0 || ! nomad->nomad_dev == NULL || ! nomad->isopen == 0 ) return -EIO; --- 114,120 ---- /* Sanity check to make sure Nomad is connected, powered, etc */ ! if (nomad == NULL || ! nomad->present == 0 || ! nomad->nomad_dev == NULL || nomad->isopen == 0) return -EIO; *************** *** 126,131 **** if (data == NULL) break; ! if(copy_from_user(&nomad_cmd, data, sizeof(struct Nomad_cmd))) ! return -EFAULT; if (nomad_cmd.length > PAGE_SIZE) --- 124,130 ---- if (data == NULL) break; ! if (copy_from_user ! (&nomad_cmd, data, ! sizeof(struct Nomad_cmd))) return -EFAULT; if (nomad_cmd.length > PAGE_SIZE) *************** *** 137,148 **** return -ENOMEM; ! if(copy_from_user(buffer, nomad_cmd.buffer, nomad_cmd.length)) ! return -EFAULT; ! requesttype = nomad_cmd.requesttype | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE; ! info ("sending command: reqtype=%0x req=%0x value=%0x index=%0x len=%0x", ! requesttype, nomad_cmd.request, nomad_cmd.value, ! nomad_cmd.index, nomad_cmd.length); /* Send nomad control message */ --- 136,152 ---- return -ENOMEM; ! if (copy_from_user ! (buffer, nomad_cmd.buffer, ! nomad_cmd.length)) return -EFAULT; ! requesttype = ! nomad_cmd. ! requesttype | USB_DIR_IN | USB_TYPE_VENDOR | ! USB_RECIP_DEVICE; ! info ! ("sending command: reqtype=%0x req=%0x value=%0x index=%0x len=%0x", ! requesttype, nomad_cmd.request, nomad_cmd.value, ! nomad_cmd.index, nomad_cmd.length); /* Send nomad control message */ *************** *** 151,155 **** result = usb_control_msg(nomad->nomad_dev, ! usb_rcvctrlpipe(nomad->nomad_dev, ENDPOINT_CONTROL), nomad_cmd.request, requesttype, --- 155,161 ---- result = usb_control_msg(nomad->nomad_dev, ! usb_rcvctrlpipe(nomad-> ! nomad_dev, ! ENDPOINT_CONTROL), nomad_cmd.request, requesttype, *************** *** 164,176 **** else if (result < 0) { ! err("Error executing ioctl. code = %d", le32_to_cpu(result)); retries = 0; } else { ! info("Executed ioctl. Result = %d (data=%04x)", le32_to_cpu(result), le32_to_cpu(*((long *) buffer))); ! if(copy_to_user(nomad_cmd.buffer, buffer, nomad_cmd.length)) ! return -EFAULT; retries = 0; --- 170,186 ---- else if (result < 0) { ! err("Error executing ioctl. code = %d", ! le32_to_cpu(result)); retries = 0; } else { ! info ! ("Executed ioctl. Result = %d (data=%04x)", ! le32_to_cpu(result), le32_to_cpu(*((long *) buffer))); ! if (copy_to_user ! (nomad_cmd.buffer, buffer, ! nomad_cmd.length)) return -EFAULT; retries = 0; *************** *** 188,193 **** break; ! if(copy_from_user(&nomad_cmd, data, sizeof(struct Nomad_cmd))) ! return -EFAULT; if (nomad_cmd.length > PAGE_SIZE) --- 198,204 ---- break; ! if (copy_from_user ! (&nomad_cmd, data, ! sizeof(struct Nomad_cmd))) return -EFAULT; if (nomad_cmd.length > PAGE_SIZE) *************** *** 199,208 **** return -ENOMEM; ! if(copy_from_user(buffer, nomad_cmd.buffer, nomad_cmd.length)) ! return -EFAULT; ! requesttype = nomad_cmd.requesttype | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE; ! info("sending command: reqtype=%0x req=%0x value=%0x index=%0x len=%0x", requesttype, nomad_cmd.request, nomad_cmd.value, nomad_cmd.index, nomad_cmd.length); --- 210,224 ---- return -ENOMEM; ! if (copy_from_user ! (buffer, nomad_cmd.buffer, ! nomad_cmd.length)) return -EFAULT; ! requesttype = ! nomad_cmd. ! requesttype | USB_DIR_OUT | USB_TYPE_VENDOR | ! USB_RECIP_DEVICE; ! info ! ("sending command: reqtype=%0x req=%0x value=%0x index=%0x len=%0x", requesttype, nomad_cmd.request, nomad_cmd.value, nomad_cmd.index, nomad_cmd.length); *************** *** 213,217 **** result = usb_control_msg(nomad->nomad_dev, ! usb_sndctrlpipe(nomad->nomad_dev, ENDPOINT_CONTROL), nomad_cmd.request, requesttype, --- 229,235 ---- result = usb_control_msg(nomad->nomad_dev, ! usb_sndctrlpipe(nomad-> ! nomad_dev, ! ENDPOINT_CONTROL), nomad_cmd.request, requesttype, ***************... [truncated message content] |
From: J?rg P. <jp...@us...> - 2002-01-03 11:25:25
|
Update of /cvsroot/njbfs/njbfs/tools In directory usw-pr-cvs1:/tmp/cvs-serv28658 Added Files: Makefile id3tool.c njbutil.pl Log Message: Some tools for njbfs --- NEW FILE: Makefile --- # Directories to search for header files SEARCHDIRS := -I- -I${MYCODEDIR} -I/usr/src/linux/include # makemake variables # C preprocessor CPPFLAGS = # C compiler CC := gcc CFLAGS = -g -Wall -Werror ${SEARCHDIRS} %.o : %.c ${CC} ${CPPFLAGS} ${CFLAGS} -c $< -o $@ id3tool : ./id3tool.o ${LINKER} ${LDFLAGS} -o $@ ${filter-out %.a %.so, $^} ${LOADLIBES} # C linker LINKER = gcc LDFLAGS = -lmp LOADLIBES := # target for making everything .PHONY : all all: id3tool # target for removing all object files .PHONY : tidy tidy:: @${RM} core ./id3tool.o # target for removing all object files .PHONY : clean clean:: tidy @${RM} id3tool.o # list of all source files MM_ALL_SOURCES := ./id3tool.c # target for checking a source file CHECKSYNTAXFILE := ${basename ${filter %${CHECKSTRING}, ${MM_ALL_SOURCES}}} .PHONY : checksyntax checksyntax: ifneq (${CHECKSYNTAXFILE},) @${MAKE} ${addsuffix .o, ${CHECKSYNTAXFILE}} else @echo No target to make ${CHECKSTRING} endif # target for touching appropriate source files .PHONY : touch touch:: @list=$$(grep -l ${TOUCHSTRING} ${MM_ALL_SOURCES}); \ for file in $$list; do { echo $$file; touch $$file; } done # target for calculating dependencies (MAKEMAKE) .PHONY : jdepend jdepend: @${MAKEMAKE} --depend Makefile -- ${DEPENDFLAGS} -- ./id3.c install: id3tool rm -f /usr/local/bin/id3tool install -m644 --owner=0 --group=0 -b -D id3 /usr/local/bin/id3tool depmod -aq @echo "id3tool successfully installed." uninstall: rm -rf /usr/local/bin/id3tool @echo "id3tool is now uninstalled." --- NEW FILE: id3tool.c --- /* * ID3 tool using mplib 0.6 * * Install mplib 0.6 from http://mplib.sourceforge.net * with shared libs before building this tool: * * tar zxvf mplib-0.6.tar.gz * cd mplib-0.6 * ./configure --enable-shared=yes * make * su -> root * make install * * This tool only shows the information of the ID3 tags of given MP3 files * and does no modification at all. The format of information display * is compatible to the njbfs file name parser format. * * Copyright (C) 2001 Jörg Prante <joe...@gm...> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <strings.h> #include <unistd.h> #include <mplib.h> int main(int argc, char *argv[]) { id3_tag_list *taglist; id3_tag *tag; id3_content *content; id3_text_content *textcontent; int i, ret; int size; struct stat st; if (argc == 1) printf("Usage: id3tool <mp3-files>"); for (i = 1; i < argc; i++) { printf("\nFile: %s\n", argv[i]); ret =stat(argv[i], &st); if (ret == 0) size = st.st_size; else size = 0; printf(" size={%d}", size); taglist = mp_get_tag_list_from_file(argv[i]); if (taglist) { do { tag = taglist->tag; if (tag) { content = mp_get_content(tag, MP_ARTIST); if (content) { textcontent = mp_parse_artist(content); printf(",artist={%s}", textcontent->text ); } content = mp_get_content(tag, MP_TITLE); if (content) { textcontent = mp_parse_title(content); printf(",title={%s}", textcontent->text ); } content = mp_get_content(tag, MP_ALBUM); if (content) { textcontent = mp_parse_album(content); printf(",album={%s}", textcontent->text ); } content = mp_get_content(tag, MP_GENRE); if (content) { textcontent = mp_parse_genre(content); printf(",genre={%s}", textcontent->text ); } content = mp_get_content(tag, MP_TRACK); if (content) { textcontent = mp_parse_track(content); printf(",track={%s}", textcontent->text ); } /* mplib 0.6 does not provide track size code */ content = mp_get_content_custom_at_pos(tag, "TSIZ", 0); if (content) { textcontent = mp_parse_text(content); printf(",size={%s}", textcontent->text ); } } taglist = taglist->next; } while (taglist); } else { printf("<no tags found>"); } } printf("\n"); return 0; } --- NEW FILE: njbutil.pl --- #!/usr/bin/perl -w use strict; #written: Tue Jan 1 14:47:18 EST 2002 #author: me...@ne... # #This program is just a quick proof of concept piece I was inspired to #write after seeing njbfs. # #I needed a tool to set missing id3 tags and copy lots of files to the #nomad jukebox. # #This is a handy module I found on cpan, debian users can #apt-get install libmp3-info-perl #Other distributions may have it packaged, if not download it from #cpan.org. use MP3::Info; #These (should) be core perl modules. use File::Find; use File::Copy; use Getopt::Std; our $opt_c; our $opt_e; our $opt_m; getopts('cem'); my $dir = shift || die usage(); die usage() unless -d $dir; finddepth( \&fix_missing_tags, $dir ) if $opt_m || $opt_e; finddepth( \©_files, $dir ) if $opt_c; sub fix_missing_tags { my $file = $_; #I only want mp3's. At least until Creative decides to support .ogg's if ( $file =~ /\.mp3$/ ) { my $taginfo = get_mp3tag($file); return undef if ($taginfo) && !defined($opt_e); my $fileinfo = get_mp3info($file); print "Editing data for $file\n"; get_taginfo( \$taginfo, 'ARTIST' ); get_taginfo( \$taginfo, 'TITLE' ); print "Storing data....\n"; # store tag info set_mp3tag( $file, $taginfo ) || warn "Unable to save tag info for this file $!\n"; } } sub get_taginfo { my $tagref = shift; my $tag = shift; my $confirmation = 'n'; while ( 'y' ne $confirmation || 'Y' ne $confirmation ) { if ( ${$tagref}->{$tag} ) { print( "\nTag is set to:\"", ${$tagref}->{$tag}, "\"\n" ); my $edit_flag = input_data("Edit tag? (y/n):"); return undef unless ( 'y' eq $edit_flag || 'Y' eq $edit_flag ); } ${$tagref}->{$tag} = input_data("\nEnter $tag information:"); $confirmation = input_data( 'You entered: ' . ${$tagref}->{$tag} . '. Is this correct (Y/N)?:' ); } } sub input_data { my $string = shift; print "$string"; my $input = <STDIN>; chomp($input); return $input; } sub copy_files { my $file = $_; #I only want mp3's. At least until Creative decides to support .ogg's if ( $file =~ /\.mp3$/ ) { #if there's no id3tag, skip it. if ( my $taginfo = get_mp3tag($file) ) { my $fileinfo = get_mp3info($file); #Make sure all the required data is there. next unless ( $taginfo->{'TITLE'} && $taginfo->{'ARTIST'} ); #Ok, this is kind of ugly, but it needs done. my $destfile = "/mnt/njbfs/tracks/" . $taginfo->{'ARTIST'} . " - " . $taginfo->{'TITLE'} . ".mp3,size=" . $fileinfo->{'SIZE'}; print("Copyiny file to:$destfile\n\n"); #I like feedback... copy ($file,$destfile)||die "Unable to copy file:$file\n"; } } } sub usage { print "Usage: $0 <opts> <path>\n\n"; print "Opts are:\n", "copy files to nomad jukebox: -c\n"; print "override (edit) existing id3tags: -e\n"; print "find and edit missing tags: -m\n\n"; print "Options are additive. eg:\n"; print "$0 -e -c ~/mp3\n"; print "Will first let you edit all id3tags, then copy every mp3 that has an id3tag in ~/mp3 to the Nomad Jukebox.\n"; exit; } |
From: J?rg P. <jp...@us...> - 2002-01-03 11:24:33
|
Update of /cvsroot/njbfs/njbfs/tools In directory usw-pr-cvs1:/tmp/cvs-serv28468/tools Log Message: Directory /cvsroot/njbfs/njbfs/tools added to the repository |
From: Danish Q. <dq...@us...> - 2001-12-23 20:17:00
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv22187 Modified Files: track.h njb_usb.h playlist.h Log Message: Added newlines (\n) to the end of these header files, to stop make from complaining about it. Index: track.h =================================================================== RCS file: /cvsroot/njbfs/njbfs/track.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** track.h 2001/12/04 21:09:31 1.2 --- track.h 2001/12/23 20:16:56 1.3 *************** *** 17,19 **** extern void track_updateframe(track_t *track, track_frame_t *frame); ! #endif \ No newline at end of file --- 17,19 ---- extern void track_updateframe(track_t *track, track_frame_t *frame); ! #endif Index: njb_usb.h =================================================================== RCS file: /cvsroot/njbfs/njbfs/njb_usb.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** njb_usb.h 2001/12/04 21:09:31 1.2 --- njb_usb.h 2001/12/23 20:16:56 1.3 *************** *** 141,143 **** #define NJB_UNDEFINED_ERR 0xff ! #endif \ No newline at end of file --- 141,143 ---- #define NJB_UNDEFINED_ERR 0xff ! #endif Index: playlist.h =================================================================== RCS file: /cvsroot/njbfs/njbfs/playlist.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** playlist.h 2001/11/13 00:56:59 1.1 --- playlist.h 2001/12/23 20:16:56 1.2 *************** *** 17,19 **** extern void playlist_track_destroy (playlist_track_t *pl); ! #endif \ No newline at end of file --- 17,19 ---- extern void playlist_track_destroy (playlist_track_t *pl); ! #endif |
From: Danish Q. <dq...@us...> - 2001-12-23 05:59:11
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv9013 Modified Files: INSTALL Makefile Log Message: Added mnt point creation to Makefile and updated INSTALL docs. Index: INSTALL =================================================================== RCS file: /cvsroot/njbfs/njbfs/INSTALL,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** INSTALL 2001/12/23 05:52:25 1.2 --- INSTALL 2001/12/23 05:59:08 1.3 *************** *** 28,32 **** automountable '/mnt/njbfs' directory. ! If you're not up to playing with the automounter (you really should :), here are the mount commands to mount your NJB. First make sure that the following mount points exists (create them). mount -t njbfs -o dir=tracks none /mnt/njbfs/tracks --- 28,32 ---- automountable '/mnt/njbfs' directory. ! If you're not up to playing with the automounter (you really should :), here are the mount commands to mount your NJB. mount -t njbfs -o dir=tracks none /mnt/njbfs/tracks Index: Makefile =================================================================== RCS file: /cvsroot/njbfs/njbfs/Makefile,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Makefile 2001/12/04 21:09:31 1.3 --- Makefile 2001/12/23 05:59:08 1.4 *************** *** 91,94 **** --- 91,98 ---- rm -f ${MODULESDIR}/kernel/fs/njbfs/njbfs.o install -m644 --owner=0 --group=0 -b -D njbfs.o ${MODULESDIR}/kernel/fs/njbfs/njbfs.o + install -d -m755 --owner=0 --group=0 /mnt/njbfs/tracks + install -d -m755 --owner=0 --group=0 /mnt/njbfs/playlists + install -d -m755 --owner=0 --group=0 /mnt/njbfs/albums + install -d -m755 --owner=0 --group=0 /mnt/njbfs/artists depmod -aq @echo "njbfs successfully installed." |
From: Danish Q. <dq...@us...> - 2001-12-23 05:52:28
|
Update of /cvsroot/njbfs/njbfs In directory usw-pr-cvs1:/tmp/cvs-serv7719 Modified Files: INSTALL Log Message: Added mount commands as well as the entries for /etc/fstab. Index: INSTALL =================================================================== RCS file: /cvsroot/njbfs/njbfs/INSTALL,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** INSTALL 2001/11/04 13:46:03 1.1.1.1 --- INSTALL 2001/12/23 05:52:25 1.2 *************** *** 28,31 **** --- 28,49 ---- automountable '/mnt/njbfs' directory. + If you're not up to playing with the automounter (you really should :), here are the mount commands to mount your NJB. First make sure that the following mount points exists (create them). + + mount -t njbfs -o dir=tracks none /mnt/njbfs/tracks + mount -t njbfs -o dir=playlists none /mnt/njbfs/playlists + mount -t njbfs -o dir=albums none /mnt/njbfs/albums + mount -t njbfs -o dir=artists none /mnt/njbfs/artists + + And for those who do not like typing those long commands, put these in your /etc/fstab + + none /mnt/njbfs/tracks njbfs dir=tracks 0 0 + none /mnt/njbfs/playlists njbfs dir=playlists 0 0 + none /mnt/njbfs/albums njbfs dir=albums 0 0 + none /mnt/njbfs/artists njbfs dir=artists 0 0 + + + [Note: Most Linux distros will try to mount all entries in /etc/fstab on boot. You may or may not like the results.] + + If you have 'usbmgr' running, I recommend automatic installation of 'njbfs' when you plug the device into the computer. Edit '/etc/usbmgr/usbmgr.conf' as root *************** *** 57,59 **** The 'rc' control executables are part of the SuSe Linux distribution. On other distributions, there are similar executables called 'service'. ! Try 'service autofs restart' and the like, or consult the manuals. \ No newline at end of file --- 75,77 ---- The 'rc' control executables are part of the SuSe Linux distribution. On other distributions, there are similar executables called 'service'. ! Try 'service autofs restart' and the like, or consult the manuals. |
From: J?rg P. <jp...@us...> - 2001-12-15 21:22:09
|
Update of /cvsroot/njbfs/njbfs/docs In directory usw-pr-cvs1:/tmp/cvs-serv26953/docs Modified Files: towards-a-linux-kernel-audio-track-subsystem.txt Log Message: patch for 'sscanf' extended Index: towards-a-linux-kernel-audio-track-subsystem.txt =================================================================== RCS file: /cvsroot/njbfs/njbfs/docs/towards-a-linux-kernel-audio-track-subsystem.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** towards-a-linux-kernel-audio-track-subsystem.txt 2001/12/14 23:16:23 1.2 --- towards-a-linux-kernel-audio-track-subsystem.txt 2001/12/15 21:22:07 1.3 *************** *** 219,223 **** --- 219,247 ---- the Archos. For this, no extra Linux drivers seem to be required. + Pontis/Grundig mpaxx MP100 + + http://mpaxx.grundig.de + http://www.pontis.de + + http://members.chello.at/andreas.thell/pontisctrl.html (Perl script for mpl3) + + Compaq iPAQ + Compaq iPAQ PA-1 + http://www.compaq.com/athome/support/internetdevices/ipaq-pa1.html + + + Compaq iPAQ H3650 + http://www.the-gadgeteer.com/ipaq-review.html + + Compaq Personal Jukebox for Linux + System Research Center + Main Page: http://research.compaq.com/SRC/pjb + Downloads: http://www.research.compaq.com/downloads.html + + Apple iPod + + + 4. The basic design of a Linux kernel audio track subsystem *************** *** 316,319 **** --- 340,380 ---- track subsystem configuration must be extended in order to support the device capabilities completely. + + + USB MP3 portable players overview + + + + Iomega HipZip + 40MB PocketZip drive + no Linux support + http://www.iomega.com/hipzip/ + + + + Intel Pocket Concert Audio Player + + Dimensions (W x H x D) + 97 x 62 x 24 mm + Weight + 97g w/o batteries + Playable music format(s) + MP3, WMA + Battery life + 10 hrs + Storage + 128MB built-in flash + FM tuner / voice recording + yes / no + Software + Intel Audio Manager, Intel Audio Sampler, MusicMatch JukeBox 5.2 Plus + Remote included? + No + Inputs / outputs + Neckphone jack + Power source + 2 AAA batteries + Warranty + One year |